define(['jQuery'], function ($) {
var query = {
SortBy: "SortName",
SortOrder: "Ascending"
};
function deleteSeriesTimer(page, id) {
require(['confirm'], function (confirm) {
confirm(Globalize.translate('MessageConfirmSeriesCancellation'), Globalize.translate('HeaderConfirmSeriesCancellation')).then(function () {
Dashboard.showLoadingMsg();
ApiClient.cancelLiveTvSeriesTimer(id).then(function () {
require(['toast'], function (toast) {
toast(Globalize.translate('MessageSeriesCancelled'));
});
reload(page);
});
});
});
}
function renderTimers(page, timers) {
var html = '';
if (timers.length) {
html += '
';
}
var elem = $('#items', page).html(html);
$('.btnCancelSeries', elem).on('click', function () {
deleteSeriesTimer(page, this.getAttribute('data-seriestimerid'));
});
Dashboard.hideLoadingMsg();
}
function reload(page) {
Dashboard.showLoadingMsg();
ApiClient.getLiveTvSeriesTimers(query).then(function (result) {
require(['paper-fab', 'paper-item-body', 'paper-icon-item'], function () {
renderTimers(page, result.Items);
});
LibraryBrowser.setLastRefreshed(page);
});
}
window.LiveTvPage.renderSeriesTimersTab = function (page, tabContent) {
if (LibraryBrowser.needsRefresh(tabContent)) {
reload(tabContent);
}
};
});