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

117 lines
3.1 KiB
JavaScript
Raw Normal View History

2013-12-14 18:17:57 -07:00
(function (window, $, document, apiClient) {
var currentItem;
2013-12-14 08:49:11 -07:00
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 () {
2013-12-14 18:17:57 -07:00
Dashboard.alert('Timer cancelled.');
2013-12-14 08:49:11 -07:00
reload(page);
});
}
});
}
function renderTimer(page, item) {
currentItem = item;
2013-12-12 21:06:38 -07:00
$('.program', page).html(item.Name);
2013-12-14 18:17:57 -07:00
$('.channel', page).html('<a href="livetvchannel.html?id=' + item.ChannelId + '">' + item.ChannelName + '</a>').trigger('create');
2013-12-12 21:06:38 -07:00
$('.overview', page).html(item.Overview || '');
2013-12-17 22:44:46 -07:00
$('#txtPrePaddingSeconds', page).val(item.PrePaddingSeconds);
$('#txtPostPaddingSeconds', page).val(item.PostPaddingSeconds);
$('#chkPrePaddingRequired', page).checked(item.IsPrePaddingRequired).checkboxradio('refresh');
$('#chkPostPaddingRequired', page).checked(item.IsPostPaddingRequired).checkboxradio('refresh');
2013-12-12 21:57:01 -07:00
2013-12-14 08:49:11 -07:00
$('.itemMiscInfo', page).html(LibraryBrowser.getMiscInfoHtml(item));
$('.status', page).html('Status:&nbsp;&nbsp;&nbsp;' + 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();
}
2013-12-17 22:44:46 -07:00
2013-12-14 18:17:57 -07:00
function onSubmit() {
2013-12-17 22:44:46 -07:00
2013-12-14 18:17:57 -07:00
Dashboard.showLoadingMsg();
var form = this;
apiClient.getLiveTvTimer(currentItem.Id).done(function (item) {
2013-12-17 22:44:46 -07:00
item.PrePaddingSeconds = $('#txtPrePaddingSeconds', form).val();
item.PostPaddingSeconds = $('#txtPostPaddingSeconds', form).val();
item.IsPrePaddingRequired = $('#chkPrePaddingRequired', form).checked();
item.IsPostPaddingRequired = $('#chkPostPaddingRequired', form).checked();
2013-12-14 18:17:57 -07:00
2013-12-17 22:44:46 -07:00
ApiClient.updateLiveTvTimer(item).done(function () {
2013-12-14 18:17:57 -07:00
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;
2013-12-14 08:49:11 -07:00
$('#btnCancelTimer', page).on('click', function () {
deleteTimer(page, currentItem.Id);
});
}).on('pagebeforeshow', "#liveTvTimerPage", function () {
var page = this;
reload(page);
}).on('pagehide', "#liveTvTimerPage", function () {
currentItem = null;
});
2013-12-17 22:44:46 -07:00
2013-12-14 18:17:57 -07:00
function liveTvTimerPage() {
var self = this;
2013-12-17 22:44:46 -07:00
2013-12-14 18:17:57 -07:00
self.onSubmit = onSubmit;
}
window.LiveTvTimerPage = new liveTvTimerPage();
2013-12-14 18:17:57 -07:00
})(window, jQuery, document, ApiClient);