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

172 lines
4.4 KiB
JavaScript
Raw Normal View History

2014-10-15 20:26:39 -07:00
(function ($, document) {
2014-01-12 08:58:47 -07:00
2015-05-15 11:28:34 -07:00
function loadRecommendedPrograms(page) {
2015-07-24 08:20:11 -07:00
2014-01-12 08:58:47 -07:00
Dashboard.showLoadingMsg();
2014-10-15 20:26:39 -07:00
ApiClient.getLiveTvRecommendedPrograms({
2014-01-12 08:58:47 -07:00
userId: Dashboard.getCurrentUserId(),
IsAiring: true,
2015-07-24 08:20:11 -07:00
limit: 16
2014-01-12 08:58:47 -07:00
}).done(function (result) {
2014-05-09 12:43:06 -07:00
2014-01-12 08:58:47 -07:00
var html = LibraryBrowser.getPosterViewHtml({
items: result.Items,
2015-03-14 13:56:50 -07:00
shape: "auto",
2014-01-12 08:58:47 -07:00
showTitle: true,
showParentTitle: true,
2014-08-01 19:34:45 -07:00
overlayText: true,
2015-01-22 23:15:15 -07:00
coverImage: true,
2015-07-24 08:20:11 -07:00
lazy: true,
overlayPlayButton: true
2014-01-12 08:58:47 -07:00
});
2015-06-28 07:45:21 -07:00
var elem = page.querySelector('.activeProgramItems');
elem.innerHTML = html;
ImageLoader.lazyChildren(elem);
2015-05-15 11:28:34 -07:00
Dashboard.hideLoadingMsg();
2015-06-29 22:45:20 -07:00
LibraryBrowser.setLastRefreshed(page);
2014-01-12 08:58:47 -07:00
});
2015-05-15 11:28:34 -07:00
}
function reload(page) {
loadRecommendedPrograms(page);
2014-01-12 08:58:47 -07:00
2014-10-15 20:26:39 -07:00
ApiClient.getLiveTvRecommendedPrograms({
2014-01-12 08:58:47 -07:00
userId: Dashboard.getCurrentUserId(),
IsAiring: false,
HasAired: false,
2015-07-24 08:20:11 -07:00
limit: 8,
2015-04-03 09:31:56 -07:00
IsMovie: false,
IsSports: false
2014-01-12 08:58:47 -07:00
}).done(function (result) {
var html = LibraryBrowser.getPosterViewHtml({
items: result.Items,
2015-03-14 13:56:50 -07:00
shape: "auto",
2014-01-12 08:58:47 -07:00
showTitle: true,
showParentTitle: true,
2014-08-01 19:34:45 -07:00
overlayText: true,
2015-01-22 23:15:15 -07:00
coverImage: true,
2015-07-24 08:20:11 -07:00
lazy: true,
overlayMoreButton: true
2014-01-12 08:58:47 -07:00
});
2015-06-28 07:45:21 -07:00
var elem = page.querySelector('.upcomingProgramItems');
elem.innerHTML = html;
ImageLoader.lazyChildren(elem);
2014-01-12 08:58:47 -07:00
});
2015-03-14 13:56:50 -07:00
ApiClient.getLiveTvRecommendedPrograms({
userId: Dashboard.getCurrentUserId(),
IsAiring: false,
HasAired: false,
2015-07-24 08:20:11 -07:00
limit: 8,
2015-03-14 13:56:50 -07:00
IsMovie: true
}).done(function (result) {
var html = LibraryBrowser.getPosterViewHtml({
items: result.Items,
shape: "auto",
2015-04-11 18:38:38 -07:00
showTitle: false,
2015-03-14 13:56:50 -07:00
coverImage: true,
overlayText: false,
2015-07-24 08:20:11 -07:00
lazy: true,
overlayMoreButton: true
2015-03-14 13:56:50 -07:00
});
2015-06-28 07:45:21 -07:00
var elem = page.querySelector('.upcomingTvMovieItems');
elem.innerHTML = html;
ImageLoader.lazyChildren(elem);
2015-03-14 13:56:50 -07:00
});
2015-04-03 09:31:56 -07:00
ApiClient.getLiveTvRecommendedPrograms({
userId: Dashboard.getCurrentUserId(),
IsAiring: false,
HasAired: false,
2015-07-24 08:20:11 -07:00
limit: 8,
2015-04-03 09:31:56 -07:00
IsSports: true
}).done(function (result) {
var html = LibraryBrowser.getPosterViewHtml({
items: result.Items,
shape: "auto",
2015-04-11 18:38:38 -07:00
showTitle: false,
2015-04-03 09:31:56 -07:00
coverImage: true,
overlayText: false,
2015-07-24 08:20:11 -07:00
lazy: true,
overlayMoreButton: true
2015-04-03 09:31:56 -07:00
});
2015-06-28 07:45:21 -07:00
var elem = page.querySelector('.upcomingSportsItems');
elem.innerHTML = html;
ImageLoader.lazyChildren(elem);
2015-04-03 09:31:56 -07:00
});
2014-01-12 08:58:47 -07:00
}
2015-08-02 16:47:31 -07:00
function loadSuggestedTab(page) {
2014-01-12 08:58:47 -07:00
2015-08-02 16:47:31 -07:00
var tabContent = page.querySelector('.suggestedTabContent');
if (LibraryBrowser.needsRefresh(tabContent)) {
reload(tabContent);
}
}
function loadTab(page, index) {
2014-01-12 08:58:47 -07:00
2015-08-02 16:47:31 -07:00
switch (index) {
case 0:
loadSuggestedTab(page);
break;
default:
break;
2015-06-29 21:33:53 -07:00
}
2015-08-02 16:47:31 -07:00
}
$(document).on('pageinitdepends', "#liveTvSuggestedPage", function () {
var page = this;
var tabs = page.querySelector('paper-tabs');
var pages = page.querySelector('neon-animated-pages');
LibraryBrowser.configurePaperLibraryTabs(page, tabs, pages);
$(tabs).on('iron-select', function () {
var selected = this.selected;
if (LibraryBrowser.navigateOnLibraryTabSelect()) {
if (selected) {
2015-08-02 16:56:21 -07:00
Dashboard.navigate('livetv.html?tab=' + selected);
2015-08-02 16:47:31 -07:00
} else {
2015-08-02 16:56:21 -07:00
Dashboard.navigate('livetv.html');
2015-08-02 16:47:31 -07:00
}
} else {
page.querySelector('neon-animated-pages').selected = selected;
}
});
$(pages).on('tabchange', function () {
loadTab(page, parseInt(this.selected));
});
2014-01-12 08:58:47 -07:00
});
2014-10-15 20:26:39 -07:00
})(jQuery, document);