2014-10-15 20:26:39 -07:00
|
|
|
|
(function (window, $, document) {
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
|
|
|
|
var currentItem;
|
|
|
|
|
|
2014-01-07 22:25:21 -07:00
|
|
|
|
function deleteTimer(page, id) {
|
|
|
|
|
|
2014-05-30 12:23:56 -07:00
|
|
|
|
Dashboard.confirm(Globalize.translate('MessageConfirmRecordingCancellation'), Globalize.translate('HeaderConfirmRecordingCancellation'), function (result) {
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.cancelLiveTvTimer(id).then(function () {
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
2016-01-19 20:48:37 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
2014-05-30 12:23:56 -07:00
|
|
|
|
Dashboard.alert(Globalize.translate('MessageRecordingCancelled'));
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
|
|
|
|
reload(page);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-14 18:17:57 -07:00
|
|
|
|
function renderTimer(page, item) {
|
|
|
|
|
|
|
|
|
|
currentItem = item;
|
|
|
|
|
|
|
|
|
|
$('.itemName', page).html(item.Name);
|
|
|
|
|
|
2014-11-11 21:51:40 -07:00
|
|
|
|
$('#txtPrePaddingMinutes', page).val(item.PrePaddingSeconds / 60);
|
|
|
|
|
$('#txtPostPaddingMinutes', page).val(item.PostPaddingSeconds / 60);
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
2015-08-16 21:08:33 -07:00
|
|
|
|
$('#chkNewOnly', page).checked(item.RecordNewOnly);
|
|
|
|
|
$('#chkAllChannels', page).checked(item.RecordAnyChannel);
|
|
|
|
|
$('#chkAnyTime', page).checked(item.RecordAnyTime);
|
2013-12-16 23:08:06 -07:00
|
|
|
|
|
2013-12-15 07:19:24 -07:00
|
|
|
|
var channelHtml = '';
|
2014-07-16 20:17:14 -07:00
|
|
|
|
if (item.RecordAnyChannel) {
|
|
|
|
|
channelHtml += Globalize.translate('LabelAllChannels');
|
2013-12-15 07:19:24 -07:00
|
|
|
|
}
|
|
|
|
|
else if (item.ChannelId) {
|
2015-08-17 21:22:45 -07:00
|
|
|
|
channelHtml += '<a href="itemdetails.html?id=' + item.ChannelId + '">' + item.ChannelName + '</a>';
|
2013-12-15 07:19:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-07-16 20:17:14 -07:00
|
|
|
|
$('.channel', page).html(channelHtml).trigger('create');
|
2013-12-15 07:19:24 -07:00
|
|
|
|
|
|
|
|
|
selectDays(page, item.Days);
|
|
|
|
|
|
2014-07-16 20:17:14 -07:00
|
|
|
|
if (item.RecordAnyTime) {
|
|
|
|
|
$('.time', page).html(Globalize.translate('LabelAnytime')).trigger('create');
|
|
|
|
|
}
|
|
|
|
|
else if (item.ChannelId) {
|
2015-05-22 12:16:14 -07:00
|
|
|
|
$('.time', page).html(LibraryBrowser.getDisplayTime(item.StartDate)).trigger('create');
|
2014-07-16 20:17:14 -07:00
|
|
|
|
}
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-16 20:17:14 -07:00
|
|
|
|
function getDaysOfWeek() {
|
|
|
|
|
|
|
|
|
|
// Do not localize. These are used as values, not text.
|
|
|
|
|
return LiveTvHelpers.getDaysOfWeek().map(function (d) {
|
|
|
|
|
return d.value;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-15 07:19:24 -07:00
|
|
|
|
function selectDays(page, days) {
|
|
|
|
|
|
2014-07-16 20:17:14 -07:00
|
|
|
|
var daysOfWeek = getDaysOfWeek();
|
2013-12-15 07:19:24 -07:00
|
|
|
|
|
|
|
|
|
for (var i = 0, length = daysOfWeek.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var day = daysOfWeek[i];
|
|
|
|
|
|
2015-08-16 21:08:33 -07:00
|
|
|
|
$('#chk' + day, page).checked(days.indexOf(day) != -1);
|
2013-12-15 07:19:24 -07:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getDays(page) {
|
|
|
|
|
|
2014-07-16 20:17:14 -07:00
|
|
|
|
var daysOfWeek = getDaysOfWeek();
|
2013-12-15 07:19:24 -07:00
|
|
|
|
|
|
|
|
|
var days = [];
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = daysOfWeek.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var day = daysOfWeek[i];
|
|
|
|
|
|
|
|
|
|
if ($('#chk' + day, page).checked()) {
|
|
|
|
|
days.push(day);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return days;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-14 18:17:57 -07:00
|
|
|
|
function onSubmit() {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var form = this;
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getLiveTvSeriesTimer(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-16 23:08:06 -07:00
|
|
|
|
|
|
|
|
|
item.RecordNewOnly = $('#chkNewOnly', form).checked();
|
|
|
|
|
item.RecordAnyChannel = $('#chkAllChannels', form).checked();
|
|
|
|
|
item.RecordAnyTime = $('#chkAnyTime', form).checked();
|
2013-12-15 07:19:24 -07:00
|
|
|
|
|
|
|
|
|
item.Days = getDays(form);
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.updateLiveTvSeriesTimer(item).then(function () {
|
2016-01-19 20:48:37 -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;
|
|
|
|
|
|
|
|
|
|
}
|
2014-05-09 12:43:06 -07:00
|
|
|
|
|
2014-01-07 22:25:21 -07:00
|
|
|
|
function renderRecordings(page, result) {
|
2014-05-09 12:43:06 -07:00
|
|
|
|
|
2014-01-07 22:25:21 -07:00
|
|
|
|
$('.recordingsTab', page).html(LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
|
|
|
|
|
items: result.Items,
|
2014-08-15 09:35:41 -07:00
|
|
|
|
shape: "detailPageSquare",
|
2014-01-07 22:25:21 -07:00
|
|
|
|
showTitle: true,
|
2015-08-23 19:08:20 -07:00
|
|
|
|
centerText: true,
|
2014-01-07 22:25:21 -07:00
|
|
|
|
coverImage: true
|
|
|
|
|
|
2015-01-22 23:15:15 -07:00
|
|
|
|
}));
|
2014-01-07 22:25:21 -07:00
|
|
|
|
}
|
2014-05-09 12:43:06 -07:00
|
|
|
|
|
2014-01-07 22:25:21 -07:00
|
|
|
|
function renderSchedule(page, result) {
|
|
|
|
|
|
|
|
|
|
var timers = result.Items;
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
LiveTvHelpers.getTimersHtml(timers).then(function(html) {
|
|
|
|
|
var elem = $('.scheduleTab', page).html(html);
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
$('.btnDeleteTimer', elem).on('click', function () {
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
var id = this.getAttribute('data-timerid');
|
2014-01-10 22:49:18 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
deleteTimer(page, id);
|
|
|
|
|
});
|
2014-01-07 22:25:21 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
|
|
|
|
function reload(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var id = getParameterByName('id');
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getLiveTvSeriesTimer(id).then(function (result) {
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
|
|
|
|
renderTimer(page, result);
|
|
|
|
|
|
|
|
|
|
});
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
2014-10-15 20:26:39 -07:00
|
|
|
|
ApiClient.getLiveTvRecordings({
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
|
|
|
|
userId: Dashboard.getCurrentUserId(),
|
|
|
|
|
seriesTimerId: id
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
}).then(function (recordingResult) {
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
2014-03-05 19:13:08 -07:00
|
|
|
|
renderRecordings(page, recordingResult);
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2014-10-15 20:26:39 -07:00
|
|
|
|
ApiClient.getLiveTvTimers({
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
|
|
|
|
seriesTimerId: id
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
}).then(function (timerResult) {
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
2014-03-05 19:13:08 -07:00
|
|
|
|
renderSchedule(page, timerResult);
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
|
|
|
|
});
|
2013-12-14 18:17:57 -07:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-01 07:01:59 -07:00
|
|
|
|
$(document).on('pageinit', "#liveTvSeriesTimerPage", function () {
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('.radioSeriesTimerTab', page).on('change', function () {
|
|
|
|
|
|
|
|
|
|
$('.tab', page).hide();
|
|
|
|
|
$('.' + this.value + 'Tab', page).show();
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
$('.liveTvSeriesTimerForm').off('submit', onSubmit).on('submit', onSubmit);
|
|
|
|
|
|
2015-08-31 23:22:46 -07:00
|
|
|
|
}).on('pagebeforeshow', "#liveTvSeriesTimerPage", function () {
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
2014-03-27 12:30:21 -07:00
|
|
|
|
$('.radioProfileTab', page).checked(false).checkboxradio('refresh');
|
2014-01-07 22:25:21 -07:00
|
|
|
|
$('#radioSettings', page).checked(true).checkboxradio('refresh').trigger('change');
|
|
|
|
|
|
2013-12-14 18:17:57 -07:00
|
|
|
|
reload(page);
|
|
|
|
|
|
2015-06-20 17:49:42 -07:00
|
|
|
|
}).on('pagebeforehide', "#liveTvSeriesTimerPage", function () {
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
|
|
|
|
currentItem = null;
|
|
|
|
|
});
|
|
|
|
|
|
2014-10-15 20:26:39 -07:00
|
|
|
|
})(window, jQuery, document);
|