mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-18 11:28:23 -07:00
71 lines
2.0 KiB
JavaScript
71 lines
2.0 KiB
JavaScript
define(['datetime', 'listView'], function (datetime, listView) {
|
|
|
|
function isSameDay(date1, date2) {
|
|
|
|
return date1.toDateString() === date2.toDateString();
|
|
}
|
|
|
|
function renderPrograms(page, result) {
|
|
|
|
var html = '';
|
|
var currentItems = [];
|
|
var currentStartDate = null;
|
|
|
|
for (var i = 0, length = result.Items.length; i < length; i++) {
|
|
|
|
var item = result.Items[i];
|
|
|
|
var itemStartDate = datetime.parseISO8601Date(item.StartDate);
|
|
if (!currentStartDate || !isSameDay(currentStartDate, itemStartDate)) {
|
|
|
|
if (currentItems.length) {
|
|
|
|
html += '<h1>' + datetime.toLocaleDateString(itemStartDate, { weekday: 'long', month: 'long', day: 'numeric' }) + '</h1>';
|
|
|
|
html += '<div is="emby-itemscontainer" class="vertical-list">' + listView.getListViewHtml({
|
|
items: currentItems,
|
|
enableUserDataButtons: false,
|
|
showParentTitle: true,
|
|
image: false,
|
|
showProgramTime: true,
|
|
mediaInfo: false,
|
|
parentTitleWithTitle: true
|
|
|
|
}) + '</div>';
|
|
}
|
|
|
|
currentStartDate = itemStartDate;
|
|
currentItems = [];
|
|
|
|
}
|
|
|
|
currentItems.push(item);
|
|
}
|
|
|
|
page.querySelector('#childrenContent').innerHTML = html;
|
|
}
|
|
|
|
function loadPrograms(page, channelId) {
|
|
|
|
ApiClient.getLiveTvPrograms({
|
|
|
|
ChannelIds: channelId,
|
|
UserId: Dashboard.getCurrentUserId(),
|
|
HasAired: false,
|
|
SortBy: "StartDate",
|
|
EnableTotalRecordCount: false,
|
|
EnableImages: false,
|
|
ImageTypeLimit: 0
|
|
|
|
}).then(function (result) {
|
|
|
|
renderPrograms(page, result);
|
|
Dashboard.hideLoadingMsg();
|
|
});
|
|
}
|
|
|
|
window.LiveTvChannelPage = {
|
|
renderPrograms: loadPrograms
|
|
};
|
|
|
|
}); |