(function ($, document) {
var query = {
SortBy: "SortName",
SortOrder: "Ascending"
};
function deleteSeriesTimer(page, id) {
Dashboard.confirm(Globalize.translate('MessageConfirmSeriesCancellation'), Globalize.translate('HeaderConfirmSeriesCancellation'), function (result) {
if (result) {
Dashboard.showLoadingMsg();
ApiClient.cancelLiveTvSeriesTimer(id).done(function () {
Dashboard.alert(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).done(function (result) {
renderTimers(page, result.Items);
LibraryBrowser.setLastRefreshed(page);
});
}
window.LiveTvPage.renderSeriesTimersTab = function (page, tabContent) {
if (LibraryBrowser.needsRefresh(tabContent)) {
reload(tabContent);
}
};
})(jQuery, document);