2016-07-30 11:24:43 -07:00
|
|
|
|
define(['datetime', 'cardBuilder'], function (datetime, cardBuilder) {
|
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-30 11:24:43 -07:00
|
|
|
|
html += '<div is="emby-itemscontainer" class="itemsContainer vertical-wrap">';
|
2016-05-07 23:31:08 -07:00
|
|
|
|
}
|
|
|
|
|
|
2016-07-30 11:24:43 -07:00
|
|
|
|
html += cardBuilder.getCardsHtml({
|
2016-05-07 23:31:08 -07:00
|
|
|
|
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-09-14 09:20:03 -07:00
|
|
|
|
action: 'edit',
|
|
|
|
|
cardFooterAside: 'none'
|
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
|
|
|
|
|
|
|
|
|
};
|
2016-03-18 21:26:17 -07:00
|
|
|
|
});
|