2013-12-14 18:17:57 -07:00
|
|
|
|
(function (window, $, document, apiClient) {
|
2013-12-05 09:50:21 -07:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-05 09:50:21 -07:00
|
|
|
|
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-05 09:50:21 -07:00
|
|
|
|
|
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: ' + 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();
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
}
|
2013-12-05 09:50:21 -07:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2013-12-05 09:50:21 -07:00
|
|
|
|
}).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-05 09:50:21 -07:00
|
|
|
|
|
2013-12-14 18:17:57 -07:00
|
|
|
|
})(window, jQuery, document, ApiClient);
|