(function ($, document, apiClient) { function deleteTimer(page, id) { Dashboard.confirm("Are you sure you wish to cancel this series?", "Confirm Series Cancellation", function (result) { if (result) { Dashboard.showLoadingMsg(); ApiClient.cancelLiveTvSeriesTimer(id).done(function () { Dashboard.alert('Series cancelled.'); reload(page); }); } }); } function renderTimers(page, timers) { var html = ''; var cssClass = "detailTable"; html += '
'; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; for (var i = 0, length = timers.length; i < length; i++) { var timer = timers[i]; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; } html += '
 NameChannelDaysTime
'; html += ''; html += ''; html += '' + timer.Name + ''; html += ''; if (timer.RecordAnyChannel) { html += 'All Channels'; } else if (timer.ChannelId) { html += '' + timer.ChannelName + ''; } html += ''; if (timer.DayPattern) { html += timer.DayPattern; } else { var days = timer.Days || []; html += days.join(', '); } html += '' + LiveTvHelpers.getDisplayTime(timer.StartDate) + '
'; 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.getLiveTvSeriesTimers().done(function (result) { renderTimers(page, result.Items); }); } $(document).on('pagebeforeshow', "#liveTvSeriesTimersPage", function () { var page = this; reload(page); }); })(jQuery, document, ApiClient);