2015-03-14 13:56:50 -07:00
|
|
|
|
(function ($, document) {
|
|
|
|
|
|
2015-04-11 18:38:38 -07:00
|
|
|
|
var view = LibraryBrowser.getDefaultItemsView('Poster', 'Poster');
|
2015-03-14 13:56:50 -07:00
|
|
|
|
|
|
|
|
|
var currentDate = new Date();
|
|
|
|
|
currentDate.setHours(0, 0, 0, 0);
|
|
|
|
|
|
|
|
|
|
// The base query options
|
|
|
|
|
var query = {
|
|
|
|
|
UserId: Dashboard.getCurrentUserId(),
|
2015-04-03 09:31:56 -07:00
|
|
|
|
SortBy: "StartDate,SortName",
|
2015-03-14 13:56:50 -07:00
|
|
|
|
SortOrder: "Ascending",
|
2015-08-18 12:45:41 -07:00
|
|
|
|
StartIndex: 0,
|
|
|
|
|
HasAired: false
|
2015-03-14 13:56:50 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function getSavedQueryKey() {
|
2015-10-14 21:32:10 -07:00
|
|
|
|
return LibraryBrowser.getSavedQueryKey();
|
2015-03-14 13:56:50 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function reloadItems(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
ApiClient.getLiveTvPrograms(query).done(function (result) {
|
|
|
|
|
|
|
|
|
|
// Scroll back up so they can see the results from the beginning
|
2015-06-28 07:45:21 -07:00
|
|
|
|
window.scrollTo(0, 0);
|
2015-03-14 13:56:50 -07:00
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
var pagingHtml = LibraryBrowser.getQueryPagingHtml({
|
|
|
|
|
startIndex: query.StartIndex,
|
|
|
|
|
limit: query.Limit,
|
|
|
|
|
totalRecordCount: result.TotalRecordCount,
|
2015-03-19 10:34:53 -07:00
|
|
|
|
showLimit: false
|
2015-03-14 13:56:50 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
page.querySelector('.listTopPaging').innerHTML = pagingHtml;
|
2015-03-14 13:56:50 -07:00
|
|
|
|
|
|
|
|
|
if (view == "Poster") {
|
|
|
|
|
html = LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
2015-08-23 19:08:20 -07:00
|
|
|
|
shape: query.IsMovie ? 'portrait' : "auto",
|
2015-03-14 13:56:50 -07:00
|
|
|
|
context: 'livetv',
|
|
|
|
|
showTitle: false,
|
|
|
|
|
centerText: true,
|
|
|
|
|
lazy: true,
|
2015-03-19 10:34:53 -07:00
|
|
|
|
showStartDateIndex: true,
|
2015-03-19 09:16:33 -07:00
|
|
|
|
overlayText: false,
|
2015-08-24 20:13:04 -07:00
|
|
|
|
showProgramAirInfo: true,
|
|
|
|
|
overlayMoreButton: true
|
2015-03-14 13:56:50 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if (view == "PosterCard") {
|
|
|
|
|
html = LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
shape: "portrait",
|
|
|
|
|
context: 'livetv',
|
|
|
|
|
showTitle: true,
|
2015-03-19 10:34:53 -07:00
|
|
|
|
showStartDateIndex: true,
|
2015-03-14 13:56:50 -07:00
|
|
|
|
lazy: true,
|
2015-03-19 09:16:33 -07:00
|
|
|
|
cardLayout: true,
|
2015-08-24 20:13:04 -07:00
|
|
|
|
showProgramAirInfo: true,
|
|
|
|
|
overlayMoreButton: true
|
2015-03-14 13:56:50 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-28 07:45:21 -07:00
|
|
|
|
var elem = page.querySelector('.itemsContainer');
|
|
|
|
|
elem.innerHTML = html + pagingHtml;
|
|
|
|
|
ImageLoader.lazyChildren(elem);
|
2015-03-14 13:56:50 -07:00
|
|
|
|
|
|
|
|
|
$('.btnNextPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex += query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnPreviousPage', page).on('click', function () {
|
|
|
|
|
query.StartIndex -= query.Limit;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
LibraryBrowser.saveQueryValues(getSavedQueryKey(), query);
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-05 09:58:27 -07:00
|
|
|
|
$(document).on('pagebeforeshow', "#liveTvItemsPage", function () {
|
2015-03-14 13:56:50 -07:00
|
|
|
|
|
|
|
|
|
query.ParentId = LibraryMenu.getTopParentId();
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
var limit = LibraryBrowser.getDefaultPageSize();
|
|
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
query.IsMovie = getParameterByName('type') == 'movies' ? true : null;
|
2015-04-03 09:31:56 -07:00
|
|
|
|
query.IsSports = getParameterByName('type') == 'sports' ? true : null;
|
2015-08-18 23:12:58 -07:00
|
|
|
|
query.IsKids = getParameterByName('type') == 'kids' ? true : null;
|
2015-03-14 13:56:50 -07:00
|
|
|
|
|
|
|
|
|
var viewkey = getSavedQueryKey();
|
|
|
|
|
|
|
|
|
|
LibraryBrowser.loadSavedQueryValues(viewkey, query);
|
|
|
|
|
|
|
|
|
|
QueryFilters.onPageShow(page, query);
|
|
|
|
|
|
2015-09-05 09:58:27 -07:00
|
|
|
|
reloadItems(page);
|
2015-03-14 13:56:50 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document);
|