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",
|
|
|
|
|
StartIndex: 0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function getSavedQueryKey() {
|
2015-04-11 18:38:38 -07:00
|
|
|
|
return 'livetvitems2' + (query.ParentId || '');
|
2015-03-14 13:56:50 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateFilterControls(page) {
|
|
|
|
|
|
|
|
|
|
$('#selectView', page).val(view).selectmenu('refresh');
|
|
|
|
|
$('.alphabetPicker', page).alphaValue(query.NameStartsWithOrGreater);
|
|
|
|
|
$('#selectPageSize', page).val(query.Limit).selectmenu('refresh');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function reloadItems(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
ApiClient.getLiveTvPrograms(query).done(function (result) {
|
|
|
|
|
|
|
|
|
|
// Scroll back up so they can see the results from the beginning
|
|
|
|
|
$(document).scrollTop(0);
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
var pagingHtml = LibraryBrowser.getQueryPagingHtml({
|
|
|
|
|
startIndex: query.StartIndex,
|
|
|
|
|
limit: query.Limit,
|
|
|
|
|
totalRecordCount: result.TotalRecordCount,
|
|
|
|
|
viewButton: true,
|
2015-03-19 10:34:53 -07:00
|
|
|
|
showLimit: false
|
2015-03-14 13:56:50 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.listTopPaging', page).html(pagingHtml).trigger('create');
|
|
|
|
|
|
|
|
|
|
updateFilterControls(page);
|
|
|
|
|
|
|
|
|
|
if (view == "Poster") {
|
|
|
|
|
html = LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: result.Items,
|
|
|
|
|
shape: "portrait",
|
|
|
|
|
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,
|
|
|
|
|
showProgramAirInfo: 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,
|
|
|
|
|
showProgramAirInfo: true
|
2015-03-14 13:56:50 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var elem = $('.itemsContainer', page).html(html).lazyChildren();
|
|
|
|
|
|
|
|
|
|
$(pagingHtml).appendTo(elem).trigger('create');
|
|
|
|
|
|
|
|
|
|
$('.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();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).on('pageinit', "#liveTvItemsPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('#selectView', this).on('change', function () {
|
|
|
|
|
|
|
|
|
|
view = this.value;
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
|
|
|
|
|
LibraryBrowser.saveViewSetting(getSavedQueryKey(), view);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#radioBasicFilters', this).on('change', function () {
|
|
|
|
|
|
|
|
|
|
if (this.checked) {
|
|
|
|
|
$('.basicFilters', page).show();
|
|
|
|
|
$('.advancedFilters', page).hide();
|
|
|
|
|
} else {
|
|
|
|
|
$('.basicFilters', page).hide();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#radioAdvancedFilters', this).on('change', function () {
|
|
|
|
|
|
|
|
|
|
if (this.checked) {
|
|
|
|
|
$('.advancedFilters', page).show();
|
|
|
|
|
$('.basicFilters', page).hide();
|
|
|
|
|
} else {
|
|
|
|
|
$('.advancedFilters', page).hide();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.itemsContainer', page).on('needsrefresh', function () {
|
|
|
|
|
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#selectPageSize', page).on('change', function () {
|
|
|
|
|
query.Limit = parseInt(this.value);
|
|
|
|
|
query.StartIndex = 0;
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}).on('pagebeforeshow', "#liveTvItemsPage", function () {
|
|
|
|
|
|
|
|
|
|
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-03-14 13:56:50 -07:00
|
|
|
|
|
|
|
|
|
var viewkey = getSavedQueryKey();
|
|
|
|
|
|
|
|
|
|
LibraryBrowser.loadSavedQueryValues(viewkey, query);
|
|
|
|
|
|
|
|
|
|
QueryFilters.onPageShow(page, query);
|
|
|
|
|
|
|
|
|
|
LibraryBrowser.getSavedViewSetting(viewkey).done(function (val) {
|
|
|
|
|
|
|
|
|
|
if (val) {
|
|
|
|
|
$('#selectView', page).val(val).selectmenu('refresh').trigger('change');
|
|
|
|
|
} else {
|
|
|
|
|
reloadItems(page);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}).on('pageshow', "#liveTvItemsPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
updateFilterControls(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document);
|