(function ($, document, apiClient) { function editTimer(page, id) { } function deleteTimer(page, id) { Dashboard.confirm("Are you sure you wish to delete this timer?", "Confirm Timer Deletion", function (result) { if (result) { Dashboard.showLoadingMsg(); ApiClient.cancelLiveTvTimer(id).done(function () { Dashboard.alert('Timer deleted'); reload(page); }); } }); } function renderTimers(page, timers) { var html = ''; var cssClass = "detailTable"; html += '
'; html += ''; html += ''; 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 += ''; var startDate = timer.StartDate; try { startDate = parseISO8601Date(startDate, { toLocal: true }); } catch (err) { } html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; } html += '
 NameChannelDateStartEndStatusRecurring Schedule
'; html += ''; html += ''; html += '' + (timer.Name || '') + '' + (timer.ChannelName || '') + '' + startDate.toLocaleDateString() + '' + LiveTvHelpers.getDisplayTime(timer.StartDate) + '' + LiveTvHelpers.getDisplayTime(timer.EndDate) + '' + (timer.Status || '') + '
'; var elem = $('#items', page).html(html).trigger('create'); $('.btnEditTimer', elem).on('click', function () { var id = this.getAttribute('data-timerid'); editTimer(page, id); }); $('.btnDeleteTimer', elem).on('click', function () { var id = this.getAttribute('data-timerid'); deleteTimer(page, id); }); } function reload(page) { apiClient.getLiveTvTimers().done(function (result) { renderTimers(page, result.Items); }); } $(document).on('pagebeforeshow', "#liveTvTimersPage", function () { var page = this; reload(page); }); })(jQuery, document, ApiClient);