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

231 lines
6.3 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-08-03 17:09:54 -07:00
limit: 16,
ImageTypeLimit: 1,
EnableImageTypes: "Primary"
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,
2015-08-23 19:08:20 -07:00
centerText: 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,
2015-08-04 07:26:36 -07:00
IsSports: false,
IsKids: false,
IsSeries: true
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,
2015-08-23 19:08:20 -07:00
centerText: 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-08-24 05:54:10 -07:00
limit: 8,
2015-03-14 13:56:50 -07:00
IsMovie: true
}).done(function (result) {
var html = LibraryBrowser.getPosterViewHtml({
items: result.Items,
2015-08-23 19:08:20 -07:00
shape: "portrait",
showTitle: true,
centerText: true,
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-08-23 19:08:20 -07:00
showTitle: true,
centerText: true,
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
});
2015-08-18 23:12:58 -07:00
ApiClient.getLiveTvRecommendedPrograms({
userId: Dashboard.getCurrentUserId(),
IsAiring: false,
HasAired: false,
limit: 8,
IsKids: true
}).done(function (result) {
var html = LibraryBrowser.getPosterViewHtml({
items: result.Items,
shape: "auto",
2015-08-23 19:08:20 -07:00
showTitle: true,
centerText: true,
2015-08-18 23:12:58 -07:00
coverImage: true,
overlayText: false,
lazy: true,
overlayMoreButton: true
});
var elem = page.querySelector('.upcomingKidsItems');
elem.innerHTML = html;
ImageLoader.lazyChildren(elem);
});
2014-01-12 08:58:47 -07:00
}
2015-08-18 08:52:48 -07:00
function renderSuggestedTab(page, tabContent) {
2015-08-02 16:47:31 -07:00
if (LibraryBrowser.needsRefresh(tabContent)) {
reload(tabContent);
}
}
function loadTab(page, index) {
2014-01-12 08:58:47 -07:00
2015-08-18 08:52:48 -07:00
var tabContent = page.querySelector('.pageTabContent[data-index=\'' + index + '\']');
var depends = [];
var scope = 'LiveTvPage';
var renderMethod = '';
var initMethod = '';
2015-08-02 16:47:31 -07:00
switch (index) {
case 0:
2015-08-18 08:52:48 -07:00
renderMethod = 'renderSuggestedTab';
break;
case 1:
depends.push('scripts/registrationservices');
depends.push('scripts/livetvguide');
renderMethod = 'renderGuideTab';
initMethod = 'initGuideTab';
break;
case 2:
depends.push('scripts/livetvchannels');
renderMethod = 'renderChannelsTab';
initMethod = 'initChannelsTab';
break;
case 3:
depends.push('scripts/livetvrecordings');
renderMethod = 'renderRecordingsTab';
break;
case 4:
depends.push('scripts/livetvtimers');
renderMethod = 'renderTimersTab';
break;
case 5:
depends.push('scripts/livetvseriestimers');
renderMethod = 'renderSeriesTimersTab';
2015-08-02 16:47:31 -07:00
break;
default:
break;
2015-06-29 21:33:53 -07:00
}
2015-08-18 08:52:48 -07:00
require(depends, function () {
if (initMethod && !tabContent.initComplete) {
window[scope][initMethod](page, tabContent);
tabContent.initComplete = true;
}
window[scope][renderMethod](page, tabContent);
});
2015-08-02 16:47:31 -07:00
}
2015-09-01 07:01:59 -07:00
$(document).on('pageinit', "#liveTvSuggestedPage", function () {
2015-08-02 16:47:31 -07:00
var page = this;
var tabs = page.querySelector('paper-tabs');
var pages = page.querySelector('neon-animated-pages');
2015-09-01 08:31:50 -07:00
LibraryBrowser.configurePaperLibraryTabs(page, tabs, pages, 'livetv.html');
2015-08-02 16:47:31 -07:00
$(pages).on('tabchange', function () {
loadTab(page, parseInt(this.selected));
});
2014-01-12 08:58:47 -07:00
});
2015-08-18 08:52:48 -07:00
window.LiveTvPage = {
renderSuggestedTab: renderSuggestedTab
};
2014-10-15 20:26:39 -07:00
})(jQuery, document);