(function ($, document, apiClient) { function deleteTimer(page, id) { Dashboard.confirm("Are you sure you wish to cancel this recording?", "Confirm Recording Cancellation", function (result) { if (result) { Dashboard.showLoadingMsg(); ApiClient.cancelLiveTvTimer(id).done(function () { Dashboard.alert('Recording cancelled.'); reload(page); }); } }); } function renderTimers(page, timers) { var html = ''; html += ''; //var cssClass = "detailTable"; //html += '
'; //html += ''; //html += ''; //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 += ''; // var minutes = timer.RunTimeTicks / 600000000; // minutes = minutes || 1; // html += ''; // html += ''; // html += ''; // html += ''; //} //html += ''; //html += '
 NameChannelDateTimeLengthStatusSeries
'; // html += ''; // html += ''; // html += '' + timer.Name + ''; // html += ''; // if (timer.ChannelId) { // html += '' + timer.ChannelName + ''; // } // html += '' + startDate.toLocaleDateString() + '' + LiveTvHelpers.getDisplayTime(timer.StartDate) + '' + Math.round(minutes) + 'min'; // if (timer.Status == 'ConflictedNotOk' || timer.Status == 'Error') { // html += ''; // html += timer.Status; // html += ''; // } else { // html += timer.Status; // } // html += ''; // if (timer.SeriesTimerId) { // html += ''; // html += '
'; // html += '
'; // html += '
'; // 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('pagebeforeshow', "#liveTvTimersPage", function () { var page = this; reload(page); }); })(jQuery, document, ApiClient);