2014-10-15 20:26:39 -07:00
|
|
|
|
(function (window, $, document) {
|
2013-12-05 09:50:21 -07:00
|
|
|
|
|
|
|
|
|
var currentItem;
|
|
|
|
|
|
2013-12-14 08:49:11 -07:00
|
|
|
|
function deleteTimer(page, id) {
|
|
|
|
|
|
2016-02-22 12:12:06 -07:00
|
|
|
|
require(['confirm'], function (confirm) {
|
2013-12-14 08:49:11 -07:00
|
|
|
|
|
2016-02-22 12:12:06 -07:00
|
|
|
|
confirm(Globalize.translate('MessageConfirmRecordingCancellation'), Globalize.translate('HeaderConfirmRecordingCancellation')).then(function () {
|
2013-12-14 08:49:11 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.cancelLiveTvTimer(id).then(function () {
|
2013-12-14 08:49:11 -07:00
|
|
|
|
|
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
|
|
|
|
});
|
2016-02-22 12:12:06 -07:00
|
|
|
|
});
|
2013-12-14 08:49:11 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-05 09:50:21 -07:00
|
|
|
|
function renderTimer(page, item) {
|
|
|
|
|
|
|
|
|
|
currentItem = item;
|
|
|
|
|
|
2013-12-22 10:16:24 -07:00
|
|
|
|
var programInfo = item.ProgramInfo || {};
|
2013-12-05 09:50:21 -07:00
|
|
|
|
|
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
|
|
|
|
|
2015-08-20 20:21:27 -07:00
|
|
|
|
LibraryBrowser.renderGenres($('.itemGenres', page), programInfo);
|
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) {
|
|
|
|
|
|
2014-05-23 16:58:28 -07:00
|
|
|
|
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")
|
2014-05-23 16:58:28 -07:00
|
|
|
|
.html('<img src="' + imgUrl + '" style="max-width:200px;max-height:200px;" />');
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$('.timerPageImageContainer', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-18 12:45:41 -07:00
|
|
|
|
$('.itemMiscInfo', page).html(LibraryBrowser.getMiscInfoHtml(programInfo));
|
2013-12-22 10:16:24 -07:00
|
|
|
|
|
2014-11-11 21:51:40 -07:00
|
|
|
|
$('#txtPrePaddingMinutes', page).val(item.PrePaddingSeconds / 60);
|
|
|
|
|
$('#txtPostPaddingMinutes', page).val(item.PostPaddingSeconds / 60);
|
2013-12-12 21:57:01 -07:00
|
|
|
|
|
2015-08-16 21:08:33 -07:00
|
|
|
|
if (item.Status == 'New') {
|
|
|
|
|
$('.timerStatus', page).hide();
|
|
|
|
|
} else {
|
|
|
|
|
$('.timerStatus', page).show().html('Status: ' + item.Status);
|
|
|
|
|
}
|
2013-12-14 08:49:11 -07:00
|
|
|
|
|
2013-12-05 09:50:21 -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;
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getLiveTvTimer(currentItem.Id).then(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-14 18:17:57 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.updateLiveTvTimer(item).then(function () {
|
2015-08-16 21:08:33 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
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;
|
|
|
|
|
|
|
|
|
|
}
|
2013-12-05 09:50:21 -07:00
|
|
|
|
|
|
|
|
|
function reload(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var id = getParameterByName('id');
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getLiveTvTimer(id).then(function (result) {
|
2013-12-05 09:50:21 -07:00
|
|
|
|
|
|
|
|
|
renderTimer(page, result);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-01 07:01:59 -07:00
|
|
|
|
$(document).on('pageinit', "#liveTvTimerPage", function () {
|
2013-12-05 09:50:21 -07:00
|
|
|
|
|
|
|
|
|
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-08-31 23:22:46 -07:00
|
|
|
|
}).on('pagebeforeshow', "#liveTvTimerPage", function () {
|
2013-12-05 09:50:21 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
reload(page);
|
|
|
|
|
|
2015-06-20 17:49:42 -07:00
|
|
|
|
}).on('pagebeforehide', "#liveTvTimerPage", function () {
|
2013-12-05 09:50:21 -07:00
|
|
|
|
|
|
|
|
|
currentItem = null;
|
|
|
|
|
});
|
2013-12-17 22:44:46 -07:00
|
|
|
|
|
2014-10-15 20:26:39 -07:00
|
|
|
|
})(window, jQuery, document);
|