(function ($, document) { function deleteTimer(page, id) { Dashboard.confirm(Globalize.translate('MessageConfirmRecordingCancellation'), Globalize.translate('HeaderConfirmRecordingCancellation'), function (result) { if (result) { Dashboard.showLoadingMsg(); ApiClient.cancelLiveTvTimer(id).done(function () { Dashboard.alert(Globalize.translate('MessageRecordingCancelled')); reload(page); }); } }); } function renderTimers(page, timers) { var html = ''; html += ''; var elem = $('#items', page).html(html).trigger('create'); $('.btnDeleteTimer', elem).on('click', function () { var id = this.getAttribute('data-timerid'); deleteTimer(page, id); }); Dashboard.hideLoadingMsg(); } function reload(page) { Dashboard.showLoadingMsg(); ApiClient.getLiveTvTimers().done(function (result) { renderTimers(page, result.Items); }); } $(document).on('pageinitdepends', "#liveTvSuggestedPage", function () { var page = this; $(page.querySelector('neon-animated-pages')).on('tabchange', function () { if (parseInt(this.selected) == 4) { var tabContent = page.querySelector('.timersTabContent'); if (LibraryBrowser.needsRefresh(tabContent)) { reload(tabContent); } } }); }); })(jQuery, document);