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

130 lines
3.4 KiB
JavaScript
Raw Normal View History

2014-10-15 20:26:39 -07:00
(function ($, document) {
2013-12-01 09:09:05 -07:00
var currentItem;
2013-12-01 09:09:05 -07:00
function deleteRecording() {
2013-12-01 09:09:05 -07:00
2014-06-09 12:16:14 -07:00
Dashboard.confirm(Globalize.translate('MessageConfirmRecordingDeletion'), Globalize.translate('HeaderConfirmRecordingDeletion'), function (result) {
2013-12-01 09:09:05 -07:00
if (result) {
2013-12-01 09:09:05 -07:00
Dashboard.showLoadingMsg();
2013-12-01 09:09:05 -07:00
ApiClient.deleteLiveTvRecording(currentItem.Id).done(function () {
2014-06-09 12:16:14 -07:00
Dashboard.alert(Globalize.translate('MessageRecordingDeleted'));
Dashboard.navigate('livetvrecordings.html');
});
}
});
}
2013-12-21 11:37:34 -07:00
function play() {
var userdata = currentItem.UserData || {};
var mediaType = currentItem.MediaType;
2015-06-19 15:01:47 -07:00
LibraryBrowser.showPlayMenu(null, currentItem.Id, currentItem.Type, false, mediaType, userdata.PlaybackPositionTicks);
2013-12-21 11:37:34 -07:00
}
function renderRecording(page, item) {
currentItem = item;
2013-12-04 13:55:42 -07:00
var context = 'livetv';
var name = item.Name;
$('#itemImage', page).html(LibraryBrowser.getDetailImageHtml(item));
Dashboard.setPageTitle(name);
$('.itemName', page).html(name);
2013-12-12 21:06:38 -07:00
2013-12-21 11:37:34 -07:00
$('.itemEpisodeName', page).html(item.EpisodeTitle || '');
2014-01-17 22:55:21 -07:00
$('.itemCommunityRating', page).html(LibraryBrowser.getRatingHtml(item));
2013-12-04 13:55:42 -07:00
$('.userDataIcons', page).html(LibraryBrowser.getUserDataIconsHtml(item));
2013-12-04 13:55:42 -07:00
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', [{
2014-04-13 10:27:13 -07:00
item: item,
context: 'livetv'
}]);
2014-03-14 21:14:07 -07:00
$('.recordingStatus', page).html('Status:   ' + item.Status);
2013-12-01 09:09:05 -07:00
2015-02-05 22:39:07 -07:00
if (MediaController.canPlay(item)) {
$('#playButtonContainer', page).show();
} else {
$('#playButtonContainer', page).hide();
}
if (item.CanDelete) {
$('#deleteButtonContainer', page).show();
} else {
$('#deleteButtonContainer', page).hide();
}
2013-12-21 11:37:34 -07:00
LiveTvHelpers.renderOriginalAirDate($('.airDate', page), item);
Dashboard.hideLoadingMsg();
2015-04-12 22:12:02 -07:00
Dashboard.getCurrentUser().done(function(user) {
if (SyncManager.isAvailable(item, user)) {
$('.btnSync', page).removeClass('hide');
} else {
$('.btnSync', page).addClass('hide');
}
});
}
function reload(page) {
Dashboard.showLoadingMsg();
var id = getParameterByName('id');
2014-10-15 20:26:39 -07:00
ApiClient.getLiveTvRecording(id, Dashboard.getCurrentUserId()).done(function (result) {
renderRecording(page, result);
});
}
2015-05-22 12:16:14 -07:00
$(document).on('pageinitdepends', "#liveTvRecordingPage", function () {
var page = this;
2015-06-20 17:49:42 -07:00
$('.btnDelete', page).on('click', deleteRecording);
$('.btnPlay', page).on('click', play);
2015-04-12 22:12:02 -07:00
$('.btnSync', page).on('click', function () {
SyncManager.showMenu({
items: [currentItem]
});
});
2015-05-22 12:16:14 -07:00
}).on('pagebeforeshowready', "#liveTvRecordingPage", function () {
var page = this;
reload(page);
2015-06-20 17:49:42 -07:00
}).on('pagebeforehide', "#liveTvRecordingPage", function () {
currentItem = null;
2013-12-01 09:09:05 -07:00
});
2014-10-15 20:26:39 -07:00
})(jQuery, document);