2013-11-20 16:08:12 -05:00
|
|
|
|
(function ($, document, apiClient) {
|
|
|
|
|
|
2014-01-10 08:52:01 -05:00
|
|
|
|
var query = {
|
|
|
|
|
|
|
|
|
|
StartIndex: 0
|
|
|
|
|
};
|
|
|
|
|
|
2013-11-20 16:08:12 -05:00
|
|
|
|
function getChannelsHtml(channels) {
|
|
|
|
|
|
2014-01-07 13:39:35 -05:00
|
|
|
|
return LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: channels,
|
2014-01-20 11:09:53 -05:00
|
|
|
|
shape: "smallBackdrop",
|
2014-01-07 13:39:35 -05:00
|
|
|
|
centerText: true
|
|
|
|
|
});
|
2013-11-20 16:08:12 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-10 08:52:01 -05:00
|
|
|
|
function renderChannels(page, result) {
|
|
|
|
|
|
|
|
|
|
$('.listTopPaging', page).html(LibraryBrowser.getPagingHtml(query, result.TotalRecordCount, true)).trigger('create');
|
|
|
|
|
|
|
|
|
|
var html = getChannelsHtml(result.Items);
|
|
|
|
|
|
|
|
|
|
html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount);
|
|
|
|
|
|
|
|
|
|
$('#items', page).html(html).trigger('create');
|
2013-11-20 16:08:12 -05:00
|
|
|
|
|
2014-01-10 08:52:01 -05:00
|
|
|
|
$('.btnNextPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex += query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnPreviousPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex -= query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.selectPageSize', page).on('change', function () {
|
|
|
|
|
query.Limit = parseInt(this.value);
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
LibraryBrowser.saveQueryValues('movies', query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function reloadItems(page) {
|
|
|
|
|
apiClient.getLiveTvChannels(query).done(function (result) {
|
|
|
|
|
|
|
|
|
|
renderChannels(page, result);
|
|
|
|
|
});
|
2013-11-20 16:08:12 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).on('pagebeforeshow', "#liveTvChannelsPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2014-01-10 08:52:01 -05:00
|
|
|
|
var limit = LibraryBrowser.getDefaultPageSize();
|
2013-11-25 21:53:48 -05:00
|
|
|
|
|
2014-01-10 08:52:01 -05:00
|
|
|
|
// If the default page size has changed, the start index will have to be reset
|
|
|
|
|
if (limit != query.Limit) {
|
|
|
|
|
query.Limit = limit;
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
}
|
2013-11-20 16:08:12 -05:00
|
|
|
|
|
2014-01-10 08:52:01 -05:00
|
|
|
|
query.UserId = Dashboard.getCurrentUserId();
|
|
|
|
|
|
|
|
|
|
LibraryBrowser.loadSavedQueryValues('movies', query);
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
2013-11-20 16:08:12 -05:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document, ApiClient);
|