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

129 lines
3.8 KiB
JavaScript
Raw Normal View History

2014-10-15 20:26:39 -07:00
(function (window, $, document) {
var currentItem;
2013-12-14 08:49:11 -07:00
function deleteTimer(page, id) {
2014-05-30 12:23:56 -07:00
Dashboard.confirm(Globalize.translate('MessageConfirmRecordingCancellation'), Globalize.translate('HeaderConfirmRecordingCancellation'), function (result) {
2013-12-14 08:49:11 -07:00
if (result) {
Dashboard.showLoadingMsg();
ApiClient.cancelLiveTvTimer(id).done(function () {
2014-05-30 12:23:56 -07:00
Dashboard.alert(Globalize.translate('MessageRecordingCancelled'));
2013-12-14 08:49:11 -07:00
2015-08-02 16:56:21 -07:00
Dashboard.navigate('livetv.html');
2013-12-14 08:49:11 -07:00
});
}
});
}
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 || {};
2014-01-02 14:21:06 -07:00
$('.itemName', page).html(item.Name);
2014-01-07 22:25:21 -07:00
2013-12-22 10:16:24 -07:00
$('.itemEpisodeName', page).html(programInfo.EpisodeTitle || '');
2013-12-19 14:51:32 -07:00
2014-01-17 22:55:21 -07:00
$('.itemCommunityRating', page).html(LibraryBrowser.getRatingHtml(programInfo));
2013-12-19 14:51:32 -07:00
2013-12-22 10:16:24 -07:00
LibraryBrowser.renderGenres($('.itemGenres', page), programInfo, context);
2015-07-06 07:20:23 -07:00
LibraryBrowser.renderOverview(page.querySelectorAll('.itemOverview'), programInfo);
2013-12-19 14:51:32 -07:00
2014-01-07 22:25:21 -07:00
if (programInfo.ImageTags && programInfo.ImageTags.Primary) {
var imgUrl = ApiClient.getScaledImageUrl(programInfo.Id, {
maxWidth: 200,
maxHeight: 200,
2014-01-07 22:25:21 -07:00
tag: programInfo.ImageTags.Primary,
type: "Primary"
});
$('.timerPageImageContainer', page).css("display", "inline-block")
.html('<img src="' + imgUrl + '" style="max-width:200px;max-height:200px;" />');
2014-01-07 22:25:21 -07:00
} else {
$('.timerPageImageContainer', page).hide();
}
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);
2014-11-11 21:51:40 -07:00
$('#txtPrePaddingMinutes', page).val(item.PrePaddingSeconds / 60);
$('#txtPostPaddingMinutes', 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
2014-03-14 21:14:07 -07:00
$('.timerStatus', page).html('Status:&nbsp;&nbsp;&nbsp;' + item.Status);
2013-12-14 08:49:11 -07:00
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;
2014-10-15 20:26:39 -07:00
ApiClient.getLiveTvTimer(currentItem.Id).done(function (item) {
2013-12-14 18:17:57 -07:00
2014-11-11 21:51:40 -07:00
item.PrePaddingSeconds = $('#txtPrePaddingMinutes', form).val() * 60;
item.PostPaddingSeconds = $('#txtPostPaddingMinutes', 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 () {
2014-05-30 12:23:56 -07:00
Dashboard.alert(Globalize.translate('MessageRecordingSaved'));
2013-12-14 18:17:57 -07:00
});
});
// Disable default form submission
return false;
}
function reload(page) {
Dashboard.showLoadingMsg();
var id = getParameterByName('id');
2014-10-15 20:26:39 -07:00
ApiClient.getLiveTvTimer(id).done(function (result) {
renderTimer(page, result);
});
}
2015-05-22 12:16:14 -07:00
$(document).on('pageinitdepends', "#liveTvTimerPage", function () {
var page = this;
2013-12-14 08:49:11 -07:00
$('#btnCancelTimer', page).on('click', function () {
deleteTimer(page, currentItem.Id);
});
2015-06-08 14:32:20 -07:00
$('.liveTvTimerForm').off('submit', onSubmit).on('submit', onSubmit);
2015-05-22 12:16:14 -07:00
}).on('pagebeforeshowready', "#liveTvTimerPage", function () {
var page = this;
reload(page);
2015-06-20 17:49:42 -07:00
}).on('pagebeforehide', "#liveTvTimerPage", function () {
currentItem = null;
});
2013-12-17 22:44:46 -07:00
2014-10-15 20:26:39 -07:00
})(window, jQuery, document);