2014-10-15 20:26:39 -07:00
|
|
|
|
(function ($, document) {
|
2013-12-17 13:02:12 -07:00
|
|
|
|
|
|
|
|
|
var currentProgram;
|
|
|
|
|
|
|
|
|
|
function renderRecording(page, defaultTimer, program) {
|
|
|
|
|
|
|
|
|
|
currentProgram = program;
|
|
|
|
|
|
|
|
|
|
var context = 'livetv';
|
|
|
|
|
|
|
|
|
|
$('.itemName', page).html(program.Name);
|
|
|
|
|
|
2013-12-21 11:37:34 -07:00
|
|
|
|
$('.itemEpisodeName', page).html(program.EpisodeTitle || '');
|
2013-12-17 13:02:12 -07:00
|
|
|
|
|
2014-01-17 22:55:21 -07:00
|
|
|
|
$('.itemCommunityRating', page).html(LibraryBrowser.getRatingHtml(program));
|
2013-12-17 13:02:12 -07:00
|
|
|
|
|
|
|
|
|
LibraryBrowser.renderGenres($('.itemGenres', page), program, context);
|
|
|
|
|
LibraryBrowser.renderOverview($('.itemOverview', page), program);
|
|
|
|
|
|
|
|
|
|
$('.itemMiscInfo', page).html(LibraryBrowser.getMiscInfoHtml(program));
|
|
|
|
|
|
2013-12-22 14:11:32 -07:00
|
|
|
|
LiveTvHelpers.renderMiscProgramInfo($('.miscTvProgramInfo', page), program);
|
|
|
|
|
|
2013-12-17 22:44:46 -07:00
|
|
|
|
$('#chkNewOnly', page).checked(defaultTimer.RecordNewOnly).checkboxradio('refresh');
|
|
|
|
|
$('#chkAllChannels', page).checked(defaultTimer.RecordAnyChannel).checkboxradio('refresh');
|
|
|
|
|
$('#chkAnyTime', page).checked(defaultTimer.RecordAnyTime).checkboxradio('refresh');
|
2013-12-17 13:02:12 -07:00
|
|
|
|
|
2014-11-11 21:51:40 -07:00
|
|
|
|
$('#txtPrePaddingMinutes', page).val(defaultTimer.PrePaddingSeconds / 60);
|
|
|
|
|
$('#txtPostPaddingMinutes', page).val(defaultTimer.PostPaddingSeconds / 60);
|
2013-12-17 22:44:46 -07:00
|
|
|
|
$('#chkPrePaddingRequired', page).checked(defaultTimer.IsPrePaddingRequired).checkboxradio('refresh');
|
|
|
|
|
$('#chkPostPaddingRequired', page).checked(defaultTimer.IsPostPaddingRequired).checkboxradio('refresh');
|
2013-12-17 13:02:12 -07:00
|
|
|
|
|
2013-12-17 22:44:46 -07:00
|
|
|
|
if (program.IsSeries) {
|
|
|
|
|
$('#eligibleForSeriesFields', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#eligibleForSeriesFields', page).hide();
|
2013-12-17 13:02:12 -07:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-17 22:44:46 -07:00
|
|
|
|
selectDays(page, defaultTimer.Days);
|
|
|
|
|
|
2013-12-17 13:02:12 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function reload(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2013-12-17 22:44:46 -07:00
|
|
|
|
var programId = getParameterByName('programid');
|
2013-12-17 13:02:12 -07:00
|
|
|
|
|
2014-10-15 20:26:39 -07:00
|
|
|
|
var promise1 = ApiClient.getNewLiveTvTimerDefaults({ programId: programId });
|
|
|
|
|
var promise2 = ApiClient.getLiveTvProgram(programId, Dashboard.getCurrentUserId());
|
2013-12-17 13:02:12 -07:00
|
|
|
|
|
|
|
|
|
$.when(promise1, promise2).done(function (response1, response2) {
|
|
|
|
|
|
|
|
|
|
var defaults = response1[0];
|
|
|
|
|
var program = response2[0];
|
|
|
|
|
|
|
|
|
|
renderRecording(page, defaults, program);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-17 22:44:46 -07:00
|
|
|
|
function selectDays(page, days) {
|
|
|
|
|
|
2014-05-30 12:23:56 -07:00
|
|
|
|
var daysOfWeek = getDaysOfWeek();
|
2013-12-17 22:44:46 -07:00
|
|
|
|
|
|
|
|
|
for (var i = 0, length = daysOfWeek.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var day = daysOfWeek[i];
|
|
|
|
|
|
|
|
|
|
$('#chk' + day, page).checked(days.indexOf(day) != -1).checkboxradio('refresh');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2014-07-16 20:17:14 -07:00
|
|
|
|
|
2014-05-30 12:23:56 -07:00
|
|
|
|
function getDaysOfWeek() {
|
2014-07-16 20:17:14 -07:00
|
|
|
|
|
2014-05-30 12:23:56 -07:00
|
|
|
|
// Do not localize. These are used as values, not text.
|
2014-07-16 20:17:14 -07:00
|
|
|
|
return LiveTvHelpers.getDaysOfWeek().map(function (d) {
|
|
|
|
|
return d.value;
|
|
|
|
|
});
|
2014-05-30 12:23:56 -07:00
|
|
|
|
}
|
2013-12-17 22:44:46 -07:00
|
|
|
|
|
2013-12-17 13:02:12 -07:00
|
|
|
|
function getDays(page) {
|
|
|
|
|
|
2014-05-30 12:23:56 -07:00
|
|
|
|
var daysOfWeek = getDaysOfWeek();
|
2013-12-17 22:44:46 -07:00
|
|
|
|
|
2013-12-17 13:02:12 -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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onSubmit() {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
var form = this;
|
|
|
|
|
|
2013-12-19 14:51:32 -07:00
|
|
|
|
var programId = getParameterByName('programid');
|
|
|
|
|
|
2014-10-15 20:26:39 -07:00
|
|
|
|
ApiClient.getNewLiveTvTimerDefaults({ programId: programId }).done(function (item) {
|
2013-12-17 13:02:12 -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-17 13:02:12 -07:00
|
|
|
|
|
|
|
|
|
item.RecordNewOnly = $('#chkNewOnly', form).checked();
|
|
|
|
|
item.RecordAnyChannel = $('#chkAllChannels', form).checked();
|
|
|
|
|
item.RecordAnyTime = $('#chkAnyTime', form).checked();
|
|
|
|
|
|
|
|
|
|
item.Days = getDays(form);
|
|
|
|
|
|
|
|
|
|
if ($('#chkRecordSeries', form).checked()) {
|
|
|
|
|
|
2014-10-15 20:26:39 -07:00
|
|
|
|
ApiClient.createLiveTvSeriesTimer(item).done(function () {
|
2013-12-17 13:02:12 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
Dashboard.navigate('livetvseriestimers.html');
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} else {
|
2014-10-15 20:26:39 -07:00
|
|
|
|
ApiClient.createLiveTvTimer(item).done(function () {
|
2013-12-17 13:02:12 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
Dashboard.navigate('livetvtimers.html');
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Disable default form submission
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-22 12:16:14 -07:00
|
|
|
|
$(document).on('pageinitdepends', "#liveTvNewRecordingPage", function () {
|
2013-12-17 13:02:12 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
$('#chkRecordSeries', page).on('change', function () {
|
|
|
|
|
|
|
|
|
|
if (this.checked) {
|
|
|
|
|
$('#seriesFields', page).show();
|
|
|
|
|
} else {
|
|
|
|
|
$('#seriesFields', page).hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
2013-12-19 14:51:32 -07:00
|
|
|
|
|
2013-12-17 22:44:46 -07:00
|
|
|
|
$('#btnCancel', page).on('click', function () {
|
|
|
|
|
|
2013-12-21 11:37:34 -07:00
|
|
|
|
var programId = getParameterByName('programid');
|
|
|
|
|
|
|
|
|
|
Dashboard.navigate('livetvprogram.html?id=' + programId);
|
2013-12-17 22:44:46 -07:00
|
|
|
|
|
|
|
|
|
});
|
2013-12-17 13:02:12 -07:00
|
|
|
|
|
2015-05-22 12:16:14 -07:00
|
|
|
|
$('.liveTvNewRecordingForm').off('submit', onSubmit).on('submit', onSubmit);
|
|
|
|
|
|
|
|
|
|
}).on('pagebeforeshowready', "#liveTvNewRecordingPage", function () {
|
2013-12-17 13:02:12 -07:00
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
reload(page);
|
|
|
|
|
|
2015-06-20 17:49:42 -07:00
|
|
|
|
}).on('pagebeforehide', "#liveTvNewRecordingPage", function () {
|
2013-12-17 13:02:12 -07:00
|
|
|
|
|
|
|
|
|
currentProgram = null;
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
2014-10-15 20:26:39 -07:00
|
|
|
|
})(jQuery, document);
|