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

132 lines
3.1 KiB
JavaScript
Raw Normal View History

2016-05-05 19:55:15 -07:00
define(['datetime'], function (datetime) {
2015-05-22 12:16:14 -07:00
2016-05-07 23:31:08 -07:00
function enableScrollX() {
return browserInfo.mobile && AppInfo.enableAppLayouts;
}
2016-05-10 19:21:28 -07:00
function getSquareShape() {
return enableScrollX() ? 'overflowSquare' : 'square';
}
2016-06-19 10:41:49 -07:00
function getTimersHtml(timers, options) {
2015-09-07 21:22:38 -07:00
2016-06-19 10:41:49 -07:00
options = options || {};
2016-05-06 11:17:02 -07:00
var items = timers.map(function (t) {
t.Type = 'Timer';
return t;
});
2016-05-07 23:31:08 -07:00
var groups = [];
var currentGroupName = '';
var currentGroup = [];
var i, length;
for (i = 0, length = items.length; i < length; i++) {
var item = items[i];
var dateText = '';
2016-06-19 10:41:49 -07:00
if (options.indexByDate !== false && item.StartDate) {
2016-05-07 23:31:08 -07:00
try {
var premiereDate = datetime.parseISO8601Date(item.StartDate, true);
dateText = LibraryBrowser.getFutureDateText(premiereDate, true);
} catch (err) {
}
}
if (dateText != currentGroupName) {
if (currentGroup.length) {
groups.push({
name: currentGroupName,
items: currentGroup
});
}
currentGroupName = dateText;
currentGroup = [item];
} else {
currentGroup.push(item);
}
}
2016-06-19 10:41:49 -07:00
if (currentGroup.length) {
groups.push({
name: currentGroupName,
items: currentGroup
});
}
2016-05-07 23:31:08 -07:00
var html = '';
for (i = 0, length = groups.length; i < length; i++) {
var group = groups[i];
2016-06-19 10:41:49 -07:00
if (group.name) {
html += '<div class="homePageSection">';
html += '<h1 class="listHeader">' + group.name + '</h1>';
}
2016-05-07 23:31:08 -07:00
if (enableScrollX()) {
2016-07-16 21:20:36 -07:00
html += '<div is="emby-itemscontainer" class="itemsContainer hiddenScrollX">';
2016-05-07 23:31:08 -07:00
} else {
2016-07-16 21:20:36 -07:00
html += '<div is="emby-itemscontainer" class="itemsContainer">';
2016-05-07 23:31:08 -07:00
}
html += LibraryBrowser.getPosterViewHtml({
items: group.items,
2016-05-10 19:21:28 -07:00
shape: getSquareShape(),
2016-05-07 23:31:08 -07:00
showTitle: true,
showAirTime: true,
showChannelName: true,
lazy: true,
cardLayout: true,
2016-05-09 20:36:43 -07:00
defaultAction: 'edit'
2016-05-07 23:31:08 -07:00
});
html += '</div>';
2016-06-19 10:41:49 -07:00
if (group.name) {
html += '</div>';
}
2016-05-07 23:31:08 -07:00
}
2016-05-06 11:17:02 -07:00
return Promise.resolve(html);
2015-09-07 21:22:38 -07:00
}
2015-05-22 12:16:14 -07:00
window.LiveTvHelpers = {
getDaysOfWeek: function () {
var days = [
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday'
];
return days.map(function (d) {
return {
name: d,
value: d
};
});
},
2015-09-07 21:22:38 -07:00
getTimersHtml: getTimersHtml
2015-05-22 12:16:14 -07:00
};
});