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

120 lines
2.8 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';
}
2015-09-07 21:22:38 -07:00
function getTimersHtml(timers) {
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 = '';
if (item.StartDate) {
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);
}
}
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,
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
showDetailsMenu: true,
defaultAction: 'edit'
2016-05-07 23:31:08 -07:00
});
html += '</div>';
html += '</div>';
}
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
};
});