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

135 lines
4.0 KiB
JavaScript
Raw Normal View History

2014-10-15 20:26:39 -07:00
(function ($, document) {
2013-12-20 13:09:49 -07:00
var currentItem;
2014-01-12 22:41:00 -07:00
function deleteTimer(page, id) {
2014-05-30 12:23:56 -07:00
Dashboard.confirm(Globalize.translate('MessageConfirmRecordingCancellation'), Globalize.translate('HeaderConfirmRecordingCancellation'), function (result) {
2014-01-12 22:41:00 -07:00
if (result) {
Dashboard.showLoadingMsg();
ApiClient.cancelLiveTvTimer(id).done(function () {
2014-05-30 12:23:56 -07:00
Dashboard.alert(Globalize.translate('MessageRecordingCancelled'));
2014-01-12 22:41:00 -07:00
reload(page);
});
}
});
}
2013-12-20 13:09:49 -07:00
function reload(page) {
Dashboard.showLoadingMsg();
ApiClient.getLiveTvProgram(getParameterByName('id'), Dashboard.getCurrentUserId()).done(function (item) {
var context = 'livetv';
currentItem = item;
var name = item.Name;
2013-12-20 13:09:49 -07:00
$('#itemImage', page).html(LibraryBrowser.getDetailImageHtml(item));
Dashboard.setPageTitle(name);
$('.itemName', page).html(name);
2013-12-21 11:37:34 -07:00
$('.itemEpisodeName', page).html(item.EpisodeTitle || '');
2013-12-20 13:09:49 -07:00
2014-01-17 22:55:21 -07:00
$('.itemCommunityRating', page).html(LibraryBrowser.getRatingHtml(item));
2013-12-20 13:09:49 -07:00
$('.userDataIcons', page).html(LibraryBrowser.getUserDataIconsHtml(item));
LibraryBrowser.renderGenres($('.itemGenres', page), item, context);
LibraryBrowser.renderOverview($('.itemOverview', page), item);
$('.itemMiscInfo', page).html(LibraryBrowser.getMiscInfoHtml(item));
2013-12-21 11:37:34 -07:00
LiveTvHelpers.renderMiscProgramInfo($('.miscTvProgramInfo', page), item);
2014-04-13 10:27:13 -07:00
$(page).trigger('displayingitem', [{
2013-12-20 13:09:49 -07:00
2014-04-13 10:27:13 -07:00
item: item,
context: 'livetv'
}]);
2013-12-20 13:09:49 -07:00
2014-01-12 22:41:00 -07:00
if (item.TimerId) {
$('#cancelRecordingButtonContainer', page).show();
} else {
$('#cancelRecordingButtonContainer', page).hide();
}
if (!item.TimerId && !item.SeriesTimerId) {
$('#recordButtonContainer', page).show();
} else {
$('#recordButtonContainer', page).hide();
}
2013-12-21 11:37:34 -07:00
2014-01-11 20:29:55 -07:00
var startDateLocal = parseISO8601Date(item.StartDate, { toLocal: true });
var endDateLocal = parseISO8601Date(item.EndDate, { toLocal: true });
var now = new Date();
if (now >= startDateLocal && now < endDateLocal) {
2013-12-20 13:09:49 -07:00
$('#playButtonContainer', page).show();
} else {
$('#playButtonContainer', page).hide();
}
Dashboard.getCurrentUser().done(function (user) {
2014-12-19 23:06:27 -07:00
if (user.Policy.IsAdministrator && item.LocationType !== "Offline") {
2013-12-20 13:09:49 -07:00
$('#editButtonContainer', page).show();
} else {
$('#editButtonContainer', page).hide();
}
});
2013-12-21 11:37:34 -07:00
LiveTvHelpers.renderOriginalAirDate($('.airDate', page), item);
2013-12-20 13:09:49 -07:00
Dashboard.hideLoadingMsg();
});
}
2015-05-22 12:16:14 -07:00
$(document).on('pageinitdepends', "#liveTvProgramPage", function () {
2013-12-20 13:09:49 -07:00
var page = this;
2013-12-21 11:37:34 -07:00
$('#btnRecord', page).on('click', function() {
var id = getParameterByName('id');
Dashboard.navigate('livetvnewrecording.html?programid=' + id);
});
2014-01-11 20:29:55 -07:00
$('#btnPlay', page).on('click', function () {
ApiClient.getLiveTvChannel(currentItem.ChannelId, Dashboard.getCurrentUserId()).done(function (channel) {
var userdata = channel.UserData || {};
2014-03-29 08:40:32 -07:00
LibraryBrowser.showPlayMenu(this, channel.Id, channel.Type, false, channel.MediaType, userdata.PlaybackPositionTicks);
2014-01-11 20:29:55 -07:00
});
});
2014-01-12 22:41:00 -07:00
$('#btnCancelRecording', page).on('click', function () {
deleteTimer(page, currentItem.TimerId);
});
2015-05-22 12:16:14 -07:00
}).on('pageshowready', "#liveTvProgramPage", function () {
2013-12-20 13:09:49 -07:00
var page = this;
reload(page);
}).on('pagehide', "#liveTvProgramPage", function () {
currentItem = null;
});
2014-10-15 20:26:39 -07:00
})(jQuery, document);