(function (window, $, document) { var currentItem; 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 renderTimer(page, item) { currentItem = item; $('.itemName', page).html(item.Name); $('#txtPrePaddingMinutes', page).val(item.PrePaddingSeconds / 60); $('#txtPostPaddingMinutes', page).val(item.PostPaddingSeconds / 60); $('#chkPrePaddingRequired', page).checked(item.IsPrePaddingRequired).checkboxradio('refresh'); $('#chkPostPaddingRequired', page).checked(item.IsPostPaddingRequired).checkboxradio('refresh'); $('#chkNewOnly', page).checked(item.RecordNewOnly).checkboxradio('refresh'); $('#chkAllChannels', page).checked(item.RecordAnyChannel).checkboxradio('refresh'); $('#chkAnyTime', page).checked(item.RecordAnyTime).checkboxradio('refresh'); var channelHtml = ''; if (item.RecordAnyChannel) { channelHtml += Globalize.translate('LabelAllChannels'); } else if (item.ChannelId) { channelHtml += '' + item.ChannelName + ''; } $('.channel', page).html(channelHtml).trigger('create'); selectDays(page, item.Days); if (item.RecordAnyTime) { $('.time', page).html(Globalize.translate('LabelAnytime')).trigger('create'); } else if (item.ChannelId) { $('.time', page).html(LiveTvHelpers.getDisplayTime(item.StartDate)).trigger('create'); } Dashboard.hideLoadingMsg(); } function getDaysOfWeek() { // Do not localize. These are used as values, not text. return LiveTvHelpers.getDaysOfWeek().map(function (d) { return d.value; }); } function selectDays(page, days) { var daysOfWeek = getDaysOfWeek(); for (var i = 0, length = daysOfWeek.length; i < length; i++) { var day = daysOfWeek[i]; $('#chk' + day, page).checked(days.indexOf(day) != -1).checkboxradio('refresh'); } } function getDays(page) { var daysOfWeek = getDaysOfWeek(); var days = []; for (var i = 0, length = daysOfWeek.length; i < length; i++) { var day = daysOfWeek[i]; if ($('#chk' + day, page).checked()) { days.push(day); } } return days; } function onSubmit() { Dashboard.showLoadingMsg(); var form = this; ApiClient.getLiveTvSeriesTimer(currentItem.Id).done(function (item) { item.PrePaddingSeconds = $('#txtPrePaddingMinutes', form).val() * 60; item.PostPaddingSeconds = $('#txtPostPaddingMinutes', form).val() * 60; item.IsPrePaddingRequired = $('#chkPrePaddingRequired', form).checked(); item.IsPostPaddingRequired = $('#chkPostPaddingRequired', form).checked(); item.RecordNewOnly = $('#chkNewOnly', form).checked(); item.RecordAnyChannel = $('#chkAllChannels', form).checked(); item.RecordAnyTime = $('#chkAnyTime', form).checked(); item.Days = getDays(form); ApiClient.updateLiveTvSeriesTimer(item).done(function () { Dashboard.alert(Globalize.translate('MessageRecordingSaved')); }); }); // Disable default form submission return false; } function renderRecordings(page, result) { $('.recordingsTab', page).html(LibraryBrowser.getPosterViewHtml({ items: result.Items, shape: "detailPageSquare", showTitle: true, overlayText: true, coverImage: true })).createCardMenus(); } function renderSchedule(page, result) { var timers = result.Items; var html = ''; html += '
'; if (program.IsLive) { html += '' + Globalize.translate('LabelLiveProgram') + ' '; } else if (program.IsPremiere) { html += '' + Globalize.translate('LabelPremiereProgram') + ' '; } else if (program.IsSeries && !program.IsRepeat) { html += '' + Globalize.translate('LabelNewProgram') + ' '; } html += LiveTvHelpers.getDisplayTime(timer.StartDate); html += ' - ' + LiveTvHelpers.getDisplayTime(timer.EndDate); html += '
'; if (timer.SeriesTimerId) { html += '