(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).then(function () { Dashboard.alert(Globalize.translate('MessageSeriesCancelled')); reload(page); }); } }); } function renderTimers(page, 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 += '
'; html += timer.Name; html += '
'; html += '
'; if (timer.DayPattern) { html += timer.DayPattern; } else { var days = timer.Days || []; html += days.join(', '); } if (timer.RecordAnyTime) { html += ' - ' + Globalize.translate('LabelAnytime'); } else { html += ' - ' + LibraryBrowser.getDisplayTime(timer.StartDate); } html += '
'; html += '
'; if (timer.RecordAnyChannel) { html += Globalize.translate('LabelAllChannels'); } else if (timer.ChannelId) { html += timer.ChannelName; } html += '
'; html += '
'; html += '
'; html += ''; 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); } }; })(jQuery, document);