define(['datetime', 'paper-icon-button-light', 'emby-button', 'listViewStyle'], function (datetime) { var query = { SortBy: "SortName", SortOrder: "Ascending" }; function deleteSeriesTimer(context, 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(context); }); }); }); } function renderTimers(context, timers) { var html = ''; if (timers.length) { html += '
'; } for (var i = 0, length = timers.length; i < length; i++) { var timer = timers[i]; html += '
'; html += ''; html += ''; html += ''; html += '
'; } if (timers.length) { html += '
'; } var elem = context.querySelector('#items'); elem.innerHTML = html; if (timers.length) { elem.querySelector('.paperList').addEventListener('click', function (e) { var btnCancelSeries = parentWithClass(e.target, 'btnCancelSeries'); if (btnCancelSeries) { deleteSeriesTimer(context, btnCancelSeries.getAttribute('data-seriestimerid')); } }); } Dashboard.hideLoadingMsg(); } function parentWithClass(elem, className) { while (!elem.classList || !elem.classList.contains(className)) { elem = elem.parentNode; if (!elem) { return null; } } return elem; } function reload(context) { Dashboard.showLoadingMsg(); ApiClient.getLiveTvSeriesTimers(query).then(function (result) { renderTimers(context, result.Items); }); } return function (view, params, tabContent) { var self = this; self.renderTab = function () { reload(tabContent); }; }; });