mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-17 10:58:20 -07:00
livetvcomponents.js
This commit is contained in:
parent
ecccf00fcb
commit
44ba92261d
@ -1,57 +1,92 @@
|
||||
define(["layoutManager", "datetime", "cardBuilder", "apphost"], function(layoutManager, datetime, cardBuilder, appHost) {
|
||||
define(["layoutManager", "datetime", "cardBuilder", "apphost"], function (layoutManager, datetime, cardBuilder, appHost) {
|
||||
"use strict";
|
||||
|
||||
function enableScrollX() {
|
||||
return !layoutManager.desktop
|
||||
return !layoutManager.desktop;
|
||||
}
|
||||
|
||||
function getBackdropShape() {
|
||||
return enableScrollX() ? "overflowBackdrop" : "backdrop"
|
||||
if (enableScrollX()) {
|
||||
return "overflowBackdrop";
|
||||
}
|
||||
|
||||
return "backdrop";
|
||||
}
|
||||
|
||||
function getTimersHtml(timers, options) {
|
||||
options = options || {};
|
||||
var i, length, items = timers.map(function(t) {
|
||||
return t.Type = "Timer", t
|
||||
}),
|
||||
groups = [],
|
||||
currentGroupName = "",
|
||||
currentGroup = [];
|
||||
var i;
|
||||
var length;
|
||||
var items = timers.map(function (t) {
|
||||
t.Type = "Timer";
|
||||
return t;
|
||||
});
|
||||
var groups = [];
|
||||
var currentGroupName = "";
|
||||
var currentGroup = [];
|
||||
|
||||
for (i = 0, length = items.length; i < length; i++) {
|
||||
var item = items[i],
|
||||
dateText = "";
|
||||
if (!1 !== options.indexByDate && item.StartDate) try {
|
||||
var premiereDate = datetime.parseISO8601Date(item.StartDate, !0);
|
||||
dateText = datetime.toLocaleDateString(premiereDate, {
|
||||
weekday: "long",
|
||||
month: "short",
|
||||
day: "numeric"
|
||||
})
|
||||
} catch (err) {}
|
||||
dateText != currentGroupName ? (currentGroup.length && groups.push({
|
||||
var item = items[i];
|
||||
var dateText = "";
|
||||
|
||||
if (false !== options.indexByDate && item.StartDate) {
|
||||
try {
|
||||
var premiereDate = datetime.parseISO8601Date(item.StartDate, true);
|
||||
dateText = datetime.toLocaleDateString(premiereDate, {
|
||||
weekday: "long",
|
||||
month: "short",
|
||||
day: "numeric"
|
||||
});
|
||||
} catch (err) {}
|
||||
}
|
||||
|
||||
if (dateText != currentGroupName) {
|
||||
if (currentGroup.length) {
|
||||
groups.push({
|
||||
name: currentGroupName,
|
||||
items: currentGroup
|
||||
});
|
||||
}
|
||||
|
||||
currentGroupName = dateText;
|
||||
currentGroup = [item];
|
||||
} else {
|
||||
currentGroup.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentGroup.length) {
|
||||
groups.push({
|
||||
name: currentGroupName,
|
||||
items: currentGroup
|
||||
}), currentGroupName = dateText, currentGroup = [item]) : currentGroup.push(item)
|
||||
});
|
||||
}
|
||||
currentGroup.length && groups.push({
|
||||
name: currentGroupName,
|
||||
items: currentGroup
|
||||
});
|
||||
|
||||
var html = "";
|
||||
|
||||
for (i = 0, length = groups.length; i < length; i++) {
|
||||
var group = groups[i],
|
||||
supportsImageAnalysis = appHost.supports("imageanalysis"),
|
||||
cardLayout = appHost.preferVisualCards || supportsImageAnalysis;
|
||||
if (cardLayout = !0, group.name && (html += '<div class="verticalSection">', html += '<h2 class="sectionTitle sectionTitle-cards padded-left">' + group.name + "</h2>"), enableScrollX()) {
|
||||
var group = groups[i];
|
||||
var supportsImageAnalysis = appHost.supports("imageanalysis");
|
||||
var cardLayout = appHost.preferVisualCards || supportsImageAnalysis;
|
||||
|
||||
if (cardLayout = true, group.name && (html += '<div class="verticalSection">', html += '<h2 class="sectionTitle sectionTitle-cards padded-left">' + group.name + "</h2>"), enableScrollX()) {
|
||||
var scrollXClass = "scrollX hiddenScrollX";
|
||||
layoutManager.tv && (scrollXClass += " smoothScrollX"), html += '<div is="emby-itemscontainer" class="itemsContainer ' + scrollXClass + ' padded-left padded-right">'
|
||||
} else html += '<div is="emby-itemscontainer" class="itemsContainer vertical-wrap padded-left padded-right">';
|
||||
|
||||
if (layoutManager.tv) {
|
||||
scrollXClass += " smoothScrollX";
|
||||
}
|
||||
|
||||
html += '<div is="emby-itemscontainer" class="itemsContainer ' + scrollXClass + ' padded-left padded-right">';
|
||||
} else {
|
||||
html += '<div is="emby-itemscontainer" class="itemsContainer vertical-wrap padded-left padded-right">';
|
||||
}
|
||||
|
||||
html += cardBuilder.getCardsHtml({
|
||||
items: group.items,
|
||||
shape: cardLayout ? getBackdropShape() : enableScrollX() ? "autoOverflow" : "autoVertical",
|
||||
showParentTitleOrTitle: !0,
|
||||
showAirTime: !0,
|
||||
showAirEndTime: !0,
|
||||
showParentTitleOrTitle: true,
|
||||
showAirTime: true,
|
||||
showAirEndTime: true,
|
||||
showChannelName: !cardLayout,
|
||||
cardLayout: cardLayout,
|
||||
centerText: !cardLayout,
|
||||
@ -59,15 +94,22 @@ define(["layoutManager", "datetime", "cardBuilder", "apphost"], function(layoutM
|
||||
cardFooterAside: "none",
|
||||
preferThumb: !!cardLayout || "auto",
|
||||
defaultShape: cardLayout ? null : "portrait",
|
||||
coverImage: !0,
|
||||
allowBottomPadding: !1,
|
||||
overlayText: !1,
|
||||
coverImage: true,
|
||||
allowBottomPadding: false,
|
||||
overlayText: false,
|
||||
showChannelLogo: cardLayout
|
||||
}), html += "</div>", group.name && (html += "</div>")
|
||||
});
|
||||
html += "</div>";
|
||||
|
||||
if (group.name) {
|
||||
html += "</div>";
|
||||
}
|
||||
}
|
||||
return Promise.resolve(html)
|
||||
|
||||
return Promise.resolve(html);
|
||||
}
|
||||
|
||||
window.LiveTvHelpers = {
|
||||
getTimersHtml: getTimersHtml
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user