132 lines
5.1 KiB
JavaScript
132 lines
5.1 KiB
JavaScript
define([
|
|
"exports",
|
|
"./../modules/emby-apiclient/connectionmanager.js",
|
|
"./../modules/cardbuilder/cardbuilder.js",
|
|
"./../modules/tabbedview/basetab.js",
|
|
"./../modules/emby-elements/emby-itemscontainer/emby-itemscontainer.js",
|
|
"./../modules/emby-elements/emby-scroller/emby-scroller.js",
|
|
"./../modules/common/globalize.js",
|
|
"./../modules/common/datetime.js",
|
|
], function (
|
|
_exports,
|
|
_connectionmanager,
|
|
_cardbuilder,
|
|
_basetab,
|
|
_embyItemscontainer,
|
|
_embyScroller,
|
|
_globalize,
|
|
_datetime,
|
|
) {
|
|
function UpcomingTab(view, params) {
|
|
_basetab.default.apply(this, arguments),
|
|
(this.view = view),
|
|
(this.params = params),
|
|
(this.apiClient = _connectionmanager.default.getApiClient(
|
|
params.serverId,
|
|
));
|
|
}
|
|
Object.defineProperty(_exports, "__esModule", { value: !0 }),
|
|
(_exports.default = void 0),
|
|
Object.assign(UpcomingTab.prototype, _basetab.default.prototype),
|
|
(UpcomingTab.prototype.onResume = function (options) {
|
|
_basetab.default.prototype.onResume.apply(this, arguments);
|
|
var promises,
|
|
parentId,
|
|
view,
|
|
instance,
|
|
apiClient = this.apiClient;
|
|
options.refresh &&
|
|
((parentId = this.params.parentId),
|
|
(promises = []).push(
|
|
apiClient.getUpcomingEpisodes({
|
|
Limit: 60,
|
|
UserId: apiClient.getCurrentUserId(),
|
|
ImageTypeLimit: 1,
|
|
EnableImageTypes: "Primary,Backdrop,Thumb",
|
|
EnableTotalRecordCount: !1,
|
|
parentId: parentId,
|
|
}),
|
|
),
|
|
(view = this.view),
|
|
(instance = this),
|
|
Promise.all(promises).then(function (responses) {
|
|
return (
|
|
(function (view, items) {
|
|
for (
|
|
var groups = [],
|
|
currentGroupName = "",
|
|
currentGroup = [],
|
|
i = 0,
|
|
length = items.length;
|
|
i < length;
|
|
i++
|
|
) {
|
|
var item = items[i],
|
|
dateText = "";
|
|
if (item.PremiereDate)
|
|
try {
|
|
var premiereDate = new Date(Date.parse(item.PremiereDate)),
|
|
dateText = _datetime.default.isRelativeDay(
|
|
premiereDate,
|
|
-1,
|
|
)
|
|
? _globalize.default.translate("Yesterday")
|
|
: _datetime.default.toLocaleDateString(premiereDate, {
|
|
weekday: "long",
|
|
month: "short",
|
|
day: "numeric",
|
|
});
|
|
} catch (err) {
|
|
dateText = item.PremiereDate;
|
|
}
|
|
dateText !== currentGroupName
|
|
? (currentGroup.length &&
|
|
groups.push({
|
|
name: currentGroupName,
|
|
items: currentGroup,
|
|
}),
|
|
(currentGroupName = dateText),
|
|
(currentGroup = [item]))
|
|
: currentGroup.push(item);
|
|
}
|
|
var html = "";
|
|
for (i = 0, length = groups.length; i < length; i++)
|
|
html =
|
|
(html +=
|
|
'<div class="verticalSection verticalSection-cards focusable" data-focusabletype="nearest">') +
|
|
'<h2 class="sectionTitle sectionTitle-cards padded-left padded-left-page">' +
|
|
groups[i].name +
|
|
'</h2><div is="emby-scroller" class="padded-top-focusscale padded-bottom-focusscale" data-framesize="matchgrandparent" data-focusscroll="true" data-mousewheel="false"><div is="emby-itemscontainer" class="itemsContainer scrollSlider focuscontainer-x padded-left padded-left-page padded-right"></div></div></div>';
|
|
(view = view.classList.contains("upcomingContainer")
|
|
? view
|
|
: view.querySelector(".upcomingContainer")).innerHTML = html;
|
|
var itemContainers = view.querySelectorAll(".itemsContainer");
|
|
for (i = 0, length = groups.length; i < length; i++)
|
|
_cardbuilder.default.buildCards(groups[i].items, {
|
|
showLocationTypeIndicator: !1,
|
|
shape: "backdrop",
|
|
preferThumb: !0,
|
|
showDetailsMenu: !0,
|
|
fields: ["ParentName", "Name"],
|
|
missingIndicator: !1,
|
|
multiSelect: !1,
|
|
itemsContainer: itemContainers[i],
|
|
});
|
|
})(view, responses[0].Items),
|
|
options.autoFocus && instance.autoFocus(),
|
|
Promise.resolve()
|
|
);
|
|
}));
|
|
}),
|
|
(UpcomingTab.prototype.onPause = function () {
|
|
_basetab.default.prototype.onPause.apply(this, arguments);
|
|
}),
|
|
(UpcomingTab.prototype.destroy = function () {
|
|
_basetab.default.prototype.destroy.apply(this, arguments),
|
|
(this.view = null),
|
|
(this.params = null),
|
|
(this.apiClient = null);
|
|
}),
|
|
(_exports.default = UpcomingTab);
|
|
});
|