2014-10-15 20:26:39 -07:00
|
|
|
|
(function ($, document) {
|
2013-11-24 16:37:38 -07:00
|
|
|
|
|
2013-11-25 13:39:23 -07:00
|
|
|
|
var currentItem;
|
2013-11-26 14:36:11 -07:00
|
|
|
|
var programs;
|
2013-11-25 19:53:48 -07:00
|
|
|
|
|
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
|
|
|
|
|
2014-01-07 11:39:35 -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];
|
|
|
|
|
|
2014-01-07 11:39:35 -07:00
|
|
|
|
var startDate = parseISO8601Date(program.StartDate, { toLocal: true });
|
|
|
|
|
var startDateText = LibraryBrowser.getFutureDateText(startDate);
|
2013-12-20 13:09:49 -07:00
|
|
|
|
|
2014-01-07 11:39:35 -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
|
|
|
|
|
2013-12-20 13:09:49 -07:00
|
|
|
|
html += '<h2 class="detailSectionHeader tvProgramSectionHeader">' + startDateText + '</h2>';
|
|
|
|
|
currentIndexValue = startDateText;
|
|
|
|
|
}
|
2013-11-25 13:39:23 -07:00
|
|
|
|
|
2013-12-20 13:09:49 -07:00
|
|
|
|
html += '<a href="livetvprogram.html?id=' + program.Id + '" class="tvProgram">';
|
2013-11-25 13:39:23 -07:00
|
|
|
|
|
2014-01-07 11:39:35 -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
|
|
|
|
|
2014-01-07 11:39:35 -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
|
|
|
|
|
2014-01-07 11:39:35 -07:00
|
|
|
|
var name = program.Name;
|
2014-01-11 16:07:56 -07:00
|
|
|
|
|
2014-01-07 11:39:35 -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) {
|
2014-08-04 20:41:56 -07:00
|
|
|
|
html += '<span class="liveTvProgram">'+Globalize.translate('LabelLiveProgram')+' </span>';
|
2013-12-20 13:09:49 -07:00
|
|
|
|
}
|
|
|
|
|
else if (program.IsPremiere) {
|
2014-08-04 20:41:56 -07:00
|
|
|
|
html += '<span class="premiereTvProgram">'+Globalize.translate('LabelPremiereProgram')+' </span>';
|
2013-12-20 13:09:49 -07:00
|
|
|
|
}
|
|
|
|
|
else if (program.IsSeries && !program.IsRepeat) {
|
2014-08-15 09:35:41 -07:00
|
|
|
|
html += '<span class="newTvProgram">'+Globalize.translate('LabelNewProgram')+' </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 + ' (' + 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>';
|
|
|
|
|
html += '</div>';
|
2013-12-16 23:08:06 -07:00
|
|
|
|
|
2013-12-20 13:09:49 -07:00
|
|
|
|
html += '</a>';
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-15 15:19:45 -07:00
|
|
|
|
$('#programList', page).html(html).trigger('create').createGuideHoverMenu('.tvProgramInfo');
|
2013-11-25 13:39:23 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadPrograms(page) {
|
|
|
|
|
|
|
|
|
|
ApiClient.getLiveTvPrograms({
|
2013-12-16 23:08:06 -07:00
|
|
|
|
|
2013-11-25 19:53:48 -07:00
|
|
|
|
ChannelIds: currentItem.Id,
|
|
|
|
|
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
|
|
|
|
programs = result.Items;
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
2013-11-25 13:39:23 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
2013-11-24 16:37:38 -07:00
|
|
|
|
|
|
|
|
|
function reload(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2013-12-17 13:02:12 -07:00
|
|
|
|
ApiClient.getLiveTvChannel(getParameterByName('id'), Dashboard.getCurrentUserId()).done(function (item) {
|
2013-11-24 16:37:38 -07:00
|
|
|
|
|
|
|
|
|
currentItem = item;
|
|
|
|
|
|
|
|
|
|
var name = item.Name;
|
|
|
|
|
|
|
|
|
|
$('#itemImage', page).html(LibraryBrowser.getDetailImageHtml(item));
|
|
|
|
|
|
|
|
|
|
Dashboard.setPageTitle(name);
|
|
|
|
|
|
2014-01-01 20:53:27 -07:00
|
|
|
|
$('.itemName', page).html(item.Number + ' ' + name);
|
2013-11-27 12:04:19 -07:00
|
|
|
|
|
|
|
|
|
$('.userDataIcons', page).html(LibraryBrowser.getUserDataIconsHtml(item));
|
2013-11-24 16:37:38 -07:00
|
|
|
|
|
2014-04-13 10:27:13 -07:00
|
|
|
|
$(page).trigger('displayingitem', [{
|
2013-11-24 16:37:38 -07:00
|
|
|
|
|
2014-04-13 10:27:13 -07:00
|
|
|
|
item: item,
|
|
|
|
|
context: 'livetv'
|
|
|
|
|
}]);
|
2013-11-24 16:37:38 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.getCurrentUser().done(function (user) {
|
|
|
|
|
|
2014-03-29 08:40:32 -07:00
|
|
|
|
if (MediaController.canPlay(item)) {
|
2014-01-22 19:19:04 -07:00
|
|
|
|
$('#playButtonContainer', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#playButtonContainer', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-19 23:06:27 -07:00
|
|
|
|
if (user.Policy.IsAdministrator && item.LocationType !== "Offline") {
|
2013-11-24 16:37:38 -07:00
|
|
|
|
$('#editButtonContainer', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#editButtonContainer', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2013-11-25 13:39:23 -07:00
|
|
|
|
loadPrograms(page);
|
|
|
|
|
|
2013-11-24 16:37:38 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-22 12:16:14 -07:00
|
|
|
|
$(document).on('pageinitdepends', "#liveTvChannelPage", function () {
|
2013-11-24 16:37:38 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2015-06-20 17:49:42 -07:00
|
|
|
|
$('.btnPlay', page).on('click', function () {
|
2013-11-24 16:37:38 -07:00
|
|
|
|
var userdata = currentItem.UserData || {};
|
2015-06-19 15:01:47 -07:00
|
|
|
|
LibraryBrowser.showPlayMenu(null, currentItem.Id, currentItem.Type, false, currentItem.MediaType, userdata.PlaybackPositionTicks);
|
2013-11-24 16:37:38 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-06-20 17:49:42 -07:00
|
|
|
|
$('.btnEdit', page).on('click', function () {
|
2013-11-24 16:37:38 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.navigate("edititemmetadata.html?channelid=" + currentItem.Id);
|
|
|
|
|
});
|
|
|
|
|
|
2015-06-18 21:23:55 -07:00
|
|
|
|
}).on('pagebeforeshowready', "#liveTvChannelPage", function () {
|
2013-11-24 16:37:38 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
reload(page);
|
|
|
|
|
|
2015-06-20 17:49:42 -07:00
|
|
|
|
}).on('pagebeforehide', "#liveTvChannelPage", function () {
|
2013-11-24 16:37:38 -07:00
|
|
|
|
|
|
|
|
|
currentItem = null;
|
2013-11-26 14:36:11 -07:00
|
|
|
|
programs = null;
|
2013-11-24 16:37:38 -07:00
|
|
|
|
});
|
|
|
|
|
|
2014-10-25 11:32:58 -07:00
|
|
|
|
})(jQuery, document);
|