(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 = ''; var index = ''; for (var i = 0, length = timers.length; i < length; i++) { var timer = timers[i]; var startDateText = LibraryBrowser.getFutureDateText(parseISO8601Date(timer.StartDate, { toLocal: true })); if (startDateText != index) { if (index) { html += ''; html += ''; } html += '
'; html += '

' + startDateText + '

'; html += '
'; index = startDateText; } html += ''; var program = timer.ProgramInfo || {}; var imgUrl; if (program.ImageTags && program.ImageTags.Primary) { imgUrl = ApiClient.getScaledImageUrl(program.Id, { height: 80, tag: program.ImageTags.Primary, type: "Primary" }); } if (imgUrl) { html += ''; } else if (program.IsKids) { html += ''; } else if (program.IsSports) { html += ''; } else if (program.IsMovie) { html += ''; } else if (program.IsNews) { html += ''; } else { html += ''; } html += ''; html += ''; html += '
'; html += timer.Name; html += '
'; html += '
'; html += LibraryBrowser.getDisplayTime(timer.StartDate); html += ' - ' + LibraryBrowser.getDisplayTime(timer.EndDate); html += '
'; html += '
'; html += '
'; if (timer.SeriesTimerId) { html += '
'; html += '
'; html += '
'; html += '
'; html += '
'; } html += ''; html += '
'; } if (timers.length) { 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); }); } window.LiveTvPage.renderTimersTab = function (page, tabContent) { if (LibraryBrowser.needsRefresh(tabContent)) { reload(tabContent); } }; })(jQuery, document);