2016-09-07 16:11:16 -04:00
|
|
|
|
define(['datetime', 'listView'], function (datetime, listView) {
|
2016-10-23 01:11:46 -04:00
|
|
|
|
'use strict';
|
2013-11-24 18:37:38 -05:00
|
|
|
|
|
2016-09-07 16:11:16 -04:00
|
|
|
|
function isSameDay(date1, date2) {
|
2013-11-25 15:39:23 -05:00
|
|
|
|
|
2016-09-07 16:11:16 -04:00
|
|
|
|
return date1.toDateString() === date2.toDateString();
|
|
|
|
|
}
|
2013-11-25 15:39:23 -05:00
|
|
|
|
|
2016-09-07 16:11:16 -04:00
|
|
|
|
function renderPrograms(page, result) {
|
2013-11-25 15:39:23 -05:00
|
|
|
|
|
2016-09-07 16:11:16 -04:00
|
|
|
|
var html = '';
|
|
|
|
|
var currentItems = [];
|
|
|
|
|
var currentStartDate = null;
|
2014-01-07 13:39:35 -05:00
|
|
|
|
|
2013-11-25 15:39:23 -05:00
|
|
|
|
for (var i = 0, length = result.Items.length; i < length; i++) {
|
|
|
|
|
|
2016-09-07 16:11:16 -04:00
|
|
|
|
var item = result.Items[i];
|
2013-11-25 16:53:06 -05:00
|
|
|
|
|
2016-09-07 16:11:16 -04:00
|
|
|
|
var itemStartDate = datetime.parseISO8601Date(item.StartDate);
|
2016-11-19 00:52:49 -05:00
|
|
|
|
|
2016-09-07 16:11:16 -04:00
|
|
|
|
if (!currentStartDate || !isSameDay(currentStartDate, itemStartDate)) {
|
2013-11-25 15:39:23 -05:00
|
|
|
|
|
2016-09-07 16:11:16 -04:00
|
|
|
|
if (currentItems.length) {
|
2013-11-25 15:39:23 -05:00
|
|
|
|
|
2016-11-19 00:52:49 -05:00
|
|
|
|
html += '<h1>' + datetime.toLocaleDateString(currentStartDate, { weekday: 'long', month: 'long', day: 'numeric' }) + '</h1>';
|
2014-01-07 13:39:35 -05:00
|
|
|
|
|
2016-09-07 16:11:16 -04:00
|
|
|
|
html += '<div is="emby-itemscontainer" class="vertical-list">' + listView.getListViewHtml({
|
|
|
|
|
items: currentItems,
|
|
|
|
|
enableUserDataButtons: false,
|
|
|
|
|
showParentTitle: true,
|
|
|
|
|
image: false,
|
2016-10-03 02:28:45 -04:00
|
|
|
|
showProgramTime: true,
|
|
|
|
|
mediaInfo: false,
|
|
|
|
|
parentTitleWithTitle: true
|
2014-01-07 13:39:35 -05:00
|
|
|
|
|
2016-09-07 16:11:16 -04:00
|
|
|
|
}) + '</div>';
|
|
|
|
|
}
|
2013-11-25 15:39:23 -05:00
|
|
|
|
|
2016-09-07 16:11:16 -04:00
|
|
|
|
currentStartDate = itemStartDate;
|
|
|
|
|
currentItems = [];
|
2013-11-25 15:39:23 -05:00
|
|
|
|
}
|
2013-12-17 01:08:06 -05:00
|
|
|
|
|
2016-09-07 16:11:16 -04:00
|
|
|
|
currentItems.push(item);
|
2013-12-20 15:09:49 -05:00
|
|
|
|
}
|
2016-03-19 18:31:00 -04:00
|
|
|
|
|
2016-05-05 22:55:15 -04:00
|
|
|
|
page.querySelector('#childrenContent').innerHTML = html;
|
2013-11-25 15:39:23 -05:00
|
|
|
|
}
|
|
|
|
|
|
2015-08-18 00:22:45 -04:00
|
|
|
|
function loadPrograms(page, channelId) {
|
2013-11-25 15:39:23 -05:00
|
|
|
|
|
|
|
|
|
ApiClient.getLiveTvPrograms({
|
2013-12-17 01:08:06 -05:00
|
|
|
|
|
2015-08-18 00:22:45 -04:00
|
|
|
|
ChannelIds: channelId,
|
2015-08-25 22:13:28 -04:00
|
|
|
|
UserId: Dashboard.getCurrentUserId(),
|
|
|
|
|
HasAired: false,
|
2016-09-07 16:11:16 -04:00
|
|
|
|
SortBy: "StartDate",
|
2016-09-17 13:01:58 -04:00
|
|
|
|
EnableTotalRecordCount: false,
|
|
|
|
|
EnableImages: false,
|
2016-10-18 14:23:41 -04:00
|
|
|
|
ImageTypeLimit: 0,
|
|
|
|
|
EnableUserData: false
|
2013-11-25 15:39:23 -05:00
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
}).then(function (result) {
|
2013-11-25 15:39:23 -05:00
|
|
|
|
|
|
|
|
|
renderPrograms(page, result);
|
2013-11-26 16:36:11 -05:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
2013-11-25 15:39:23 -05:00
|
|
|
|
});
|
|
|
|
|
}
|
2013-11-24 18:37:38 -05:00
|
|
|
|
|
2016-10-18 14:23:41 -04:00
|
|
|
|
return {
|
2015-08-18 00:22:45 -04:00
|
|
|
|
renderPrograms: loadPrograms
|
|
|
|
|
};
|
2013-11-24 18:37:38 -05:00
|
|
|
|
|
2016-03-19 05:26:17 +01:00
|
|
|
|
});
|