2016-10-12 11:23:09 -07:00
|
|
|
|
define(['datetime', 'cardBuilder', 'apphost'], function (datetime, cardBuilder, appHost) {
|
2016-10-22 22:11:46 -07:00
|
|
|
|
'use strict';
|
2015-05-22 12:16:14 -07:00
|
|
|
|
|
2016-05-07 23:31:08 -07:00
|
|
|
|
function enableScrollX() {
|
2017-01-14 01:03:46 -07:00
|
|
|
|
return browserInfo.mobile;
|
2016-05-07 23:31:08 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-09-30 11:43:59 -07:00
|
|
|
|
function getBackdropShape() {
|
|
|
|
|
return enableScrollX() ? 'overflowBackdrop' : 'backdrop';
|
2016-05-10 19:21:28 -07:00
|
|
|
|
}
|
|
|
|
|
|
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-30 11:24:43 -07:00
|
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer vertical-wrap">';
|
2016-05-07 23:31:08 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-12 11:23:09 -07:00
|
|
|
|
var supportsImageAnalysis = appHost.supports('imageanalysis');
|
|
|
|
|
var cardLayout = appHost.preferVisualCards || supportsImageAnalysis;
|
|
|
|
|
|
2016-07-30 11:24:43 -07:00
|
|
|
|
html += cardBuilder.getCardsHtml({
|
2016-05-07 23:31:08 -07:00
|
|
|
|
items: group.items,
|
2016-09-30 11:43:59 -07:00
|
|
|
|
shape: getBackdropShape(),
|
2016-10-17 09:41:18 -07:00
|
|
|
|
showParentTitleOrTitle: true,
|
2016-05-07 23:31:08 -07:00
|
|
|
|
showAirTime: true,
|
2016-09-30 11:43:59 -07:00
|
|
|
|
showAirEndTime: true,
|
2016-05-07 23:31:08 -07:00
|
|
|
|
showChannelName: true,
|
2016-10-12 11:23:09 -07:00
|
|
|
|
cardLayout: cardLayout,
|
|
|
|
|
centerText: !cardLayout,
|
|
|
|
|
vibrant: supportsImageAnalysis,
|
2016-09-14 09:20:03 -07:00
|
|
|
|
action: 'edit',
|
2016-09-30 11:43:59 -07:00
|
|
|
|
cardFooterAside: 'none',
|
|
|
|
|
preferThumb: true,
|
2016-09-30 11:57:56 -07:00
|
|
|
|
coverImage: true,
|
|
|
|
|
overlayText: false
|
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 = {
|
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
getTimersHtml: getTimersHtml
|
2015-05-22 12:16:14 -07:00
|
|
|
|
|
|
|
|
|
};
|
2016-03-18 21:26:17 -07:00
|
|
|
|
});
|