2016-08-11 15:41:25 -07:00
|
|
|
|
define(['datetime', 'dom', 'emby-itemscontainer'], function (datetime, dom) {
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
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];
|
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
page.querySelector('#chk' + day).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];
|
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
if (page.querySelector('#chk' + day).checked) {
|
2013-12-15 07:19:24 -07:00
|
|
|
|
days.push(day);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return days;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
return function (view, params) {
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
function renderTimer(page, item) {
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
page.querySelector('.itemName').innerHTML = item.Name;
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
page.querySelector('#txtPrePaddingMinutes').value = item.PrePaddingSeconds / 60;
|
|
|
|
|
page.querySelector('#txtPostPaddingMinutes').value = item.PostPaddingSeconds / 60;
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
page.querySelector('#chkNewOnly').checked = item.RecordNewOnly;
|
|
|
|
|
page.querySelector('#chkAllChannels').checked = item.RecordAnyChannel;
|
|
|
|
|
page.querySelector('#chkAnyTime').checked = item.RecordAnyTime;
|
2013-12-16 23:08:06 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
selectDays(page, item.Days);
|
2013-12-15 07:19:24 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
function onSubmit(e) {
|
2014-05-09 12:43:06 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
var form = this;
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
var id = params.id;
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
ApiClient.getLiveTvSeriesTimer(id).then(function (item) {
|
2016-02-18 11:19:18 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
item.PrePaddingSeconds = form.querySelector('#txtPrePaddingMinutes').value * 60;
|
|
|
|
|
item.PostPaddingSeconds = form.querySelector('#txtPostPaddingMinutes').value * 60;
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
item.RecordNewOnly = form.querySelector('#chkNewOnly').checked;
|
|
|
|
|
item.RecordAnyChannel = form.querySelector('#chkAllChannels').checked;
|
|
|
|
|
item.RecordAnyTime = form.querySelector('#chkAnyTime').checked;
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
item.Days = getDays(form);
|
2014-01-10 22:49:18 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
ApiClient.updateLiveTvSeriesTimer(item);
|
2015-12-14 08:43:03 -07:00
|
|
|
|
});
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
e.preventDefault();
|
|
|
|
|
// Disable default form submission
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
function renderSchedule(page, result) {
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
var timers = result.Items;
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
LiveTvHelpers.getTimersHtml(timers).then(function (html) {
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
var scheduleTab = page.querySelector('.scheduleTab');
|
|
|
|
|
scheduleTab.innerHTML = html;
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
ImageLoader.lazyChildren(scheduleTab);
|
|
|
|
|
});
|
|
|
|
|
}
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
function reload() {
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
var id = params.id;
|
|
|
|
|
Dashboard.showLoadingMsg();
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
ApiClient.getLiveTvSeriesTimer(id).then(function (result) {
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
renderTimer(view, result);
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
});
|
2015-06-08 14:32:20 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
ApiClient.getLiveTvTimers({
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
seriesTimerId: id
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
}).then(function (timerResult) {
|
2014-01-07 22:25:21 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
renderSchedule(view, timerResult);
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
view.querySelector('form').addEventListener('change', function () {
|
|
|
|
|
view.querySelector('.btnSubmit').click();
|
|
|
|
|
});
|
2013-12-14 18:17:57 -07:00
|
|
|
|
|
2016-08-11 15:41:25 -07:00
|
|
|
|
view.querySelector('.liveTvSeriesTimerForm').addEventListener('submit', onSubmit);
|
|
|
|
|
view.querySelector('.scheduleTab').addEventListener('timercancelled', reload);
|
|
|
|
|
view.addEventListener('viewbeforeshow', reload);
|
|
|
|
|
};
|
2016-03-18 21:26:17 -07:00
|
|
|
|
});
|