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

133 lines
3.4 KiB
JavaScript
Raw Normal View History

2013-10-24 10:49:24 -07:00
(function ($, document) {
2015-06-29 19:52:23 -07:00
function loadUpcoming(page) {
2015-06-15 21:52:01 -07:00
2015-06-16 12:17:12 -07:00
Dashboard.showLoadingMsg();
2015-05-07 07:04:10 -07:00
var limit = AppInfo.hasLowImageBandwidth ?
2015-06-29 19:52:23 -07:00
24 :
40;
2015-05-07 07:04:10 -07:00
var query = {
2013-10-24 10:49:24 -07:00
2015-05-07 07:04:10 -07:00
Limit: limit,
2014-12-18 21:20:07 -07:00
Fields: "AirTime,UserData,SeriesStudio,SyncInfo",
2014-11-30 12:01:33 -07:00
UserId: Dashboard.getCurrentUserId(),
ImageTypeLimit: 1,
2014-12-01 05:43:34 -07:00
EnableImageTypes: "Primary,Backdrop,Banner,Thumb"
2013-10-24 10:49:24 -07:00
};
2014-06-14 16:13:09 -07:00
query.ParentId = LibraryMenu.getTopParentId();
2014-07-01 22:16:59 -07:00
ApiClient.getJSON(ApiClient.getUrl("Shows/Upcoming", query)).done(function (result) {
2014-03-05 22:17:13 -07:00
var items = result.Items;
2014-03-31 14:04:22 -07:00
if (items.length) {
2015-06-28 07:45:21 -07:00
page.querySelector('.noItemsMessage').style.display = 'none';
2014-03-31 14:04:22 -07:00
} else {
2015-06-28 07:45:21 -07:00
page.querySelector('.noItemsMessage').style.display = 'block';
2013-10-24 10:49:24 -07:00
}
2015-06-28 07:45:21 -07:00
var elem = page.querySelector('#upcomingItems');
2015-07-12 12:33:00 -07:00
renderUpcoming(elem, items);
Dashboard.hideLoadingMsg();
LibraryBrowser.setLastRefreshed(page);
});
}
function enableScrollX() {
return $.browser.mobile && AppInfo.enableAppLayouts;
}
function getThumbShape() {
return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
}
function renderUpcoming(elem, items) {
var groups = [];
var currentGroupName = '';
var currentGroup = [];
var i, length;
for (i = 0, length = items.length; i < length; i++) {
var item = items[i];
var dateText = '';
if (item.PremiereDate) {
try {
dateText = LibraryBrowser.getFutureDateText(parseISO8601Date(item.PremiereDate, { toLocal: true }), true);
} catch (err) {
}
}
if (dateText != currentGroupName) {
if (currentGroup.length) {
groups.push({
name: currentGroupName,
items: currentGroup
});
}
currentGroupName = dateText;
2015-08-23 19:08:20 -07:00
currentGroup = [item];
2015-07-12 12:33:00 -07:00
} else {
currentGroup.push(item);
}
}
var html = '';
for (i = 0, length = groups.length; i < length; i++) {
var group = groups[i];
html += '<div class="homePageSection">';
html += '<h1 class="listHeader">' + group.name + '</h1>';
if (enableScrollX()) {
html += '<div class="itemsContainer hiddenScrollX">';
} else {
html += '<div class="itemsContainer">';
}
html += LibraryBrowser.getPosterViewHtml({
items: group.items,
2013-10-24 10:49:24 -07:00
showLocationTypeIndicator: false,
2015-07-12 12:33:00 -07:00
shape: getThumbShape(),
2013-10-24 10:49:24 -07:00
showTitle: true,
showPremiereDate: true,
2014-05-29 12:34:20 -07:00
preferThumb: true,
2014-07-10 21:27:46 -07:00
lazy: true,
2015-07-19 20:43:13 -07:00
showDetailsMenu: true,
centerText: true
2014-03-05 22:17:13 -07:00
2015-06-28 07:45:21 -07:00
});
2015-07-12 12:33:00 -07:00
html += '</div>';
2015-06-28 07:45:21 -07:00
2015-07-12 12:33:00 -07:00
html += '</div>';
}
2015-06-29 22:45:20 -07:00
2015-07-12 12:33:00 -07:00
elem.innerHTML = html;
ImageLoader.lazyChildren(elem);
2015-06-29 19:52:23 -07:00
}
2015-07-12 12:33:00 -07:00
2015-09-21 10:46:02 -07:00
window.TvPage.renderUpcomingTab = function (page, tabContent) {
2015-06-29 19:52:23 -07:00
2015-09-21 10:46:02 -07:00
if (LibraryBrowser.needsRefresh(tabContent)) {
loadUpcoming(tabContent);
2015-06-29 19:52:23 -07:00
}
2015-09-21 10:46:02 -07:00
};
2013-10-24 10:49:24 -07:00
})(jQuery, document);