mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-18 11:28:23 -07:00
117 lines
3.2 KiB
JavaScript
117 lines
3.2 KiB
JavaScript
(function (window, $, document, apiClient) {
|
|
|
|
var currentItem;
|
|
|
|
function deleteTimer(page, id) {
|
|
|
|
Dashboard.confirm("Are you sure you wish to cancel this timer?", "Confirm Timer Cancellation", function (result) {
|
|
|
|
if (result) {
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
ApiClient.cancelLiveTvTimer(id).done(function () {
|
|
|
|
Dashboard.alert('Timer cancelled.');
|
|
|
|
reload(page);
|
|
});
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
function renderTimer(page, item) {
|
|
|
|
currentItem = item;
|
|
|
|
$('.program', page).html(item.Name);
|
|
$('.channel', page).html('<a href="livetvchannel.html?id=' + item.ChannelId + '">' + item.ChannelName + '</a>').trigger('create');
|
|
$('.overview', page).html(item.Overview || '');
|
|
|
|
$('#txtRequestedPrePaddingSeconds', page).val(item.RequestedPrePaddingSeconds);
|
|
$('#txtRequestedPostPaddingSeconds', page).val(item.RequestedPostPaddingSeconds);
|
|
$('#txtRequiredPrePaddingSeconds', page).val(item.RequiredPrePaddingSeconds);
|
|
$('#txtRequiredPostPaddingSeconds', page).val(item.RequiredPostPaddingSeconds);
|
|
|
|
$('.itemMiscInfo', page).html(LibraryBrowser.getMiscInfoHtml(item));
|
|
$('.status', page).html('Status: ' + item.Status);
|
|
|
|
if (item.SeriesTimerId) {
|
|
|
|
$('.seriesTimerLink', page).html('<a href="livetvseriestimer.html?id=' + item.SeriesTimerId + '">View Series</a>').show().trigger('create');
|
|
|
|
} else {
|
|
$('.seriesTimerLink', page).hide();
|
|
}
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
}
|
|
|
|
function onSubmit() {
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
var form = this;
|
|
|
|
apiClient.getLiveTvTimer(currentItem.Id).done(function (item) {
|
|
|
|
item.RequestedPrePaddingSeconds = $('#txtRequestedPrePaddingSeconds', form).val();
|
|
item.RequestedPostPaddingSeconds = $('#txtRequestedPostPaddingSeconds', form).val();
|
|
item.RequiredPrePaddingSeconds = $('#txtRequiredPrePaddingSeconds', form).val();
|
|
item.RequiredPostPaddingSeconds = $('#txtRequiredPostPaddingSeconds', form).val();
|
|
|
|
ApiClient.updateLiveTvTimer(item).done(function() {
|
|
Dashboard.alert('Timer Saved');
|
|
});
|
|
});
|
|
|
|
// Disable default form submission
|
|
return false;
|
|
|
|
}
|
|
|
|
function reload(page) {
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
var id = getParameterByName('id');
|
|
|
|
apiClient.getLiveTvTimer(id).done(function (result) {
|
|
|
|
renderTimer(page, result);
|
|
|
|
});
|
|
}
|
|
|
|
$(document).on('pageinit', "#liveTvTimerPage", function () {
|
|
|
|
var page = this;
|
|
|
|
$('#btnCancelTimer', page).on('click', function () {
|
|
|
|
deleteTimer(page, currentItem.Id);
|
|
|
|
});
|
|
|
|
}).on('pagebeforeshow', "#liveTvTimerPage", function () {
|
|
|
|
var page = this;
|
|
|
|
reload(page);
|
|
|
|
}).on('pagehide', "#liveTvTimerPage", function () {
|
|
|
|
currentItem = null;
|
|
});
|
|
|
|
function liveTvTimerPage() {
|
|
|
|
var self = this;
|
|
|
|
self.onSubmit = onSubmit;
|
|
}
|
|
|
|
window.LiveTvTimerPage = new liveTvTimerPage();
|
|
|
|
})(window, jQuery, document, ApiClient); |