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

121 lines
3.8 KiB
JavaScript
Raw Normal View History

2014-10-15 20:26:39 -07:00
(function ($, document) {
2013-11-25 13:39:23 -07:00
function renderPrograms(page, result) {
var html = '';
2013-12-20 13:09:49 -07:00
var currentIndexValue;
2013-11-25 13:39:23 -07:00
var now = new Date();
2013-11-25 13:39:23 -07:00
for (var i = 0, length = result.Items.length; i < length; i++) {
var program = result.Items[i];
var startDate = parseISO8601Date(program.StartDate, { toLocal: true });
var startDateText = LibraryBrowser.getFutureDateText(startDate);
2013-12-20 13:09:49 -07:00
var endDate = parseISO8601Date(program.EndDate, { toLocal: true });
2013-11-25 14:53:06 -07:00
2013-12-20 13:09:49 -07:00
if (startDateText != currentIndexValue) {
2013-11-25 14:53:06 -07:00
2015-08-19 16:57:27 -07:00
html += '<h1 tvProgramSectionHeader" style="margin-bottom:1em;margin-top:2em;">' + startDateText + '</h1>';
2013-12-20 13:09:49 -07:00
currentIndexValue = startDateText;
}
2013-11-25 13:39:23 -07:00
2015-07-28 20:42:03 -07:00
html += '<a href="itemdetails.html?id=' + program.Id + '" class="tvProgram">';
2013-11-25 13:39:23 -07:00
var cssClass = "tvProgramTimeSlot";
if (now >= startDate && now < endDate) {
cssClass += " tvProgramCurrentTimeSlot";
}
html += '<div class="' + cssClass + '">';
2015-05-22 12:16:14 -07:00
html += '<div class="tvProgramTimeSlotInner">' + LibraryBrowser.getDisplayTime(startDate) + '</div>';
2013-12-20 13:09:49 -07:00
html += '</div>';
2013-11-25 13:39:23 -07:00
cssClass = "tvProgramInfo";
2013-11-25 13:39:23 -07:00
2013-12-20 13:09:49 -07:00
if (program.IsKids) {
cssClass += " childProgramInfo";
}
else if (program.IsSports) {
cssClass += " sportsProgramInfo";
}
else if (program.IsNews) {
cssClass += " newsProgramInfo";
2013-11-25 13:39:23 -07:00
}
2013-12-20 13:09:49 -07:00
else if (program.IsMovie) {
cssClass += " movieProgramInfo";
}
2014-01-15 15:19:45 -07:00
html += '<div data-programid="' + program.Id + '" class="' + cssClass + '">';
2013-12-20 13:09:49 -07:00
var name = program.Name;
2014-01-11 16:07:56 -07:00
html += '<div class="tvProgramName">' + name + '</div>';
2013-12-20 13:09:49 -07:00
html += '<div class="tvProgramTime">';
2013-11-25 13:39:23 -07:00
2013-12-20 13:09:49 -07:00
if (program.IsLive) {
2015-08-17 21:22:45 -07:00
html += '<span class="liveTvProgram">' + Globalize.translate('LabelLiveProgram') + '&nbsp;&nbsp;</span>';
2013-12-20 13:09:49 -07:00
}
else if (program.IsPremiere) {
2015-08-17 21:22:45 -07:00
html += '<span class="premiereTvProgram">' + Globalize.translate('LabelPremiereProgram') + '&nbsp;&nbsp;</span>';
2013-12-20 13:09:49 -07:00
}
else if (program.IsSeries && !program.IsRepeat) {
2015-08-17 21:22:45 -07:00
html += '<span class="newTvProgram">' + Globalize.translate('LabelNewProgram') + '&nbsp;&nbsp;</span>';
2013-12-20 13:09:49 -07:00
}
2013-11-25 19:53:48 -07:00
2013-12-20 13:09:49 -07:00
var minutes = program.RunTimeTicks / 600000000;
2013-11-25 13:39:23 -07:00
2013-12-20 13:09:49 -07:00
minutes = Math.round(minutes || 1) + ' min';
2013-11-25 13:39:23 -07:00
2013-12-20 13:09:49 -07:00
if (program.EpisodeTitle) {
2013-12-16 23:08:06 -07:00
2013-12-20 13:09:49 -07:00
html += program.EpisodeTitle + '&nbsp;&nbsp;(' + minutes + ')';
} else {
html += minutes;
2013-12-16 23:08:06 -07:00
}
2013-12-22 10:16:24 -07:00
2013-12-21 11:37:34 -07:00
if (program.SeriesTimerId) {
html += '<div class="timerCircle seriesTimerCircle"></div>';
html += '<div class="timerCircle seriesTimerCircle"></div>';
html += '<div class="timerCircle seriesTimerCircle"></div>';
}
else if (program.TimerId) {
html += '<div class="timerCircle"></div>';
}
2013-12-16 23:08:06 -07:00
2013-12-20 13:09:49 -07:00
html += '</div>';
2015-08-25 07:33:21 -07:00
html += '<div class="programAccent"></div>';
2013-12-20 13:09:49 -07:00
html += '</div>';
2013-12-16 23:08:06 -07:00
2013-12-20 13:09:49 -07:00
html += '</a>';
}
2015-08-17 21:22:45 -07:00
$('#childrenContent', page).html(html).trigger('create').createGuideHoverMenu('.tvProgramInfo');
2013-11-25 13:39:23 -07:00
}
2015-08-17 21:22:45 -07:00
function loadPrograms(page, channelId) {
2013-11-25 13:39:23 -07:00
ApiClient.getLiveTvPrograms({
2013-12-16 23:08:06 -07:00
2015-08-17 21:22:45 -07:00
ChannelIds: channelId,
2013-11-25 19:53:48 -07:00
UserId: Dashboard.getCurrentUserId()
2013-11-25 13:39:23 -07:00
}).done(function (result) {
renderPrograms(page, result);
2013-11-26 14:36:11 -07:00
Dashboard.hideLoadingMsg();
2013-11-25 13:39:23 -07:00
});
}
2015-08-17 21:22:45 -07:00
window.LiveTvChannelPage = {
renderPrograms: loadPrograms
};
2014-10-25 11:32:58 -07:00
})(jQuery, document);