1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/scripts/livetvchannels.js

135 lines
3.5 KiB
JavaScript
Raw Normal View History

2014-10-15 23:26:39 -04:00
(function ($, document) {
2013-11-20 16:08:12 -05:00
2014-01-10 08:52:01 -05:00
var query = {
2015-04-11 21:38:38 -04:00
StartIndex: 0,
EnableFavoriteSorting: true
2014-01-10 08:52:01 -05:00
};
2013-11-20 16:08:12 -05:00
function getChannelsHtml(channels) {
return LibraryBrowser.getPosterViewHtml({
items: channels,
2014-08-04 23:41:56 -04:00
shape: "smallBackdrop",
2015-05-13 00:55:19 -04:00
centerText: true,
lazy: true
});
2013-11-20 16:08:12 -05:00
}
function showLoadingMessage(page) {
$('.popupLoading', page).popup('open');
}
function hideLoadingMessage(page) {
$('.popupLoading', page).popup('close');
}
2014-01-10 08:52:01 -05:00
function renderChannels(page, result) {
2015-01-23 01:15:15 -05:00
$('.listTopPaging', page).html(LibraryBrowser.getQueryPagingHtml({
2014-07-20 00:46:29 -04:00
startIndex: query.StartIndex,
limit: query.Limit,
totalRecordCount: result.TotalRecordCount,
viewButton: true,
showLimit: false
2015-01-23 01:15:15 -05:00
})).trigger('create');
2014-01-10 08:52:01 -05:00
updateFilterControls(this);
2014-01-10 08:52:01 -05:00
var html = getChannelsHtml(result.Items);
2015-01-23 01:15:15 -05:00
$('#items', page).html(html).lazyChildren();
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);
});
LibraryBrowser.saveQueryValues('movies', query);
}
function reloadItems(page) {
showLoadingMessage(page);
2014-10-15 23:26:39 -04:00
ApiClient.getLiveTvChannels(query).done(function (result) {
2014-01-10 08:52:01 -05:00
renderChannels(page, result);
hideLoadingMessage(page);
2014-01-10 08:52:01 -05:00
});
2013-11-20 16:08:12 -05:00
}
function updateFilterControls(page) {
$('#chkFavorite', page).checked(query.IsFavorite == true).checkboxradio('refresh');
$('#chkLikes', page).checked(query.IsLiked == true).checkboxradio('refresh');
$('#chkDislikes', page).checked(query.IsDisliked == true).checkboxradio('refresh');
2014-07-20 00:46:29 -04:00
$('#selectPageSize', page).val(query.Limit).selectmenu('refresh');
}
2015-05-15 14:28:34 -04:00
$(document).on('pageinitdepends', "#liveTvChannelsPage", function () {
var page = this;
$('#chkFavorite', this).on('change', function () {
query.StartIndex = 0;
query.IsFavorite = this.checked ? true : null;
reloadItems(page);
});
$('#chkLikes', this).on('change', function () {
query.StartIndex = 0;
query.IsLiked = this.checked ? true : null;
reloadItems(page);
});
$('#chkDislikes', this).on('change', function () {
query.StartIndex = 0;
query.IsDisliked = this.checked ? true : null;
reloadItems(page);
});
2014-07-20 00:46:29 -04:00
$('#selectPageSize', page).on('change', function () {
query.Limit = parseInt(this.value);
query.StartIndex = 0;
reloadItems(page);
});
2015-05-15 14:28:34 -04:00
}).on('pageshown', "#liveTvChannelsPage", function () {
2013-11-20 16:08:12 -05:00
2014-06-04 15:39:16 -04:00
// Can't use pagebeforeshow here or the loading popup won't center correctly
2013-11-20 16:08:12 -05:00
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);
updateFilterControls(this);
2014-06-04 15:39:16 -04:00
2013-11-20 16:08:12 -05:00
});
2014-10-15 23:26:39 -04:00
})(jQuery, document);