jellyfin-web/dashboard-ui/scripts/livetvitems.js

178 lines
5.3 KiB
JavaScript
Raw Normal View History

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-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
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,
viewButton: true,
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
updateFilterControls(page);
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-05-17 12:50:37 -07:00
$(document).on('pageinitdepends', "#liveTvItemsPage", function () {
2015-03-14 13:56:50 -07:00
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);
});
2015-06-18 21:23:55 -07:00
}).on('pagebeforeshowready', "#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);
LibraryBrowser.getSavedViewSetting(viewkey).done(function (val) {
if (val) {
$('#selectView', page).val(val).selectmenu('refresh').trigger('change');
} else {
reloadItems(page);
}
});
updateFilterControls(page);
});
})(jQuery, document);