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

124 lines
3.3 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) {
2013-12-19 14:51:32 -07:00
Dashboard.confirm("Are you sure you wish to cancel this recording?", "Confirm Recording Cancellation", function (result) {
2013-12-14 08:49:11 -07:00
if (result) {
Dashboard.showLoadingMsg();
ApiClient.cancelLiveTvTimer(id).done(function () {
2013-12-19 14:51:32 -07:00
Dashboard.alert('Recording cancelled.');
2013-12-14 08:49:11 -07:00
reload(page);
});
}
});
}
function renderTimer(page, item) {
2013-12-19 14:51:32 -07:00
var context = 'livetv';
currentItem = item;
2013-12-22 10:16:24 -07:00
var programInfo = item.ProgramInfo || {};
2013-12-22 10:16:24 -07:00
$('.itemName', page).html(programInfo.Name);
$('.itemEpisodeName', page).html(programInfo.EpisodeTitle || '');
2013-12-19 14:51:32 -07:00
2013-12-22 10:16:24 -07:00
if (programInfo.CommunityRating) {
$('.itemCommunityRating', page).html(LibraryBrowser.getRatingHtml(programInfo)).show();
2013-12-19 14:51:32 -07:00
} else {
$('.itemCommunityRating', page).hide();
}
2013-12-22 10:16:24 -07:00
LibraryBrowser.renderGenres($('.itemGenres', page), programInfo, context);
LibraryBrowser.renderOverview($('.itemOverview', page), programInfo);
2013-12-19 14:51:32 -07:00
$('.itemMiscInfo', page).html(LibraryBrowser.getMiscInfoHtml(item));
2013-12-22 10:16:24 -07:00
LiveTvHelpers.renderMiscProgramInfo($('.miscTvProgramInfo', page), programInfo);
2013-12-19 14:51:32 -07:00
$('#txtPrePaddingSeconds', page).val(item.PrePaddingSeconds / 60);
$('#txtPostPaddingSeconds', page).val(item.PostPaddingSeconds / 60);
2013-12-17 22:44:46 -07:00
$('#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
$('.status', page).html('Status:   ' + item.Status);
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-19 14:51:32 -07:00
item.PrePaddingSeconds = $('#txtPrePaddingSeconds', form).val() * 60;
item.PostPaddingSeconds = $('#txtPostPaddingSeconds', form).val() * 60;
2013-12-17 22:44:46 -07:00
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);