(function ($, document, apiClient) { function deleteRecording(page, id) { Dashboard.confirm("Are you sure you wish to delete this recording?", "Confirm Recording Deletion", function (result) { if (result) { Dashboard.showLoadingMsg(); ApiClient.deleteLiveTvRecording(id).done(function () { Dashboard.alert('Recording deleted'); reload(page); }); } }); } function renderRecordings(page, recordings) { var html = ''; for (var i = 0, length = recordings.length; i < length; i++) { var recording = recordings[i]; html += ''; html += ''; html += ''; html += ''; html += ''; html += '' + recording.Name + ''; html += ''; html += ''; if (recording.ChannelId) { html += '' + recording.ChannelName + ''; } html += ''; var startDate = recording.StartDate; try { startDate = parseISO8601Date(startDate, { toLocal: true }); } catch (err) { } html += '' + startDate.toLocaleDateString() + ''; html += '' + LiveTvHelpers.getDisplayTime(recording.StartDate) + ''; html += '' + LiveTvHelpers.getDisplayTime(recording.EndDate) + ''; html += '' + (recording.Status || '') + ''; html += ''; } var elem = $('#table-column-toggle tbody', page).html(html).trigger('create'); $('.btnDeleteRecording', elem).on('click', function () { var recordingId = this.getAttribute('data-recordingid'); deleteRecording(page, recordingId); }); Dashboard.hideLoadingMsg(); } function reload(page) { Dashboard.showLoadingMsg(); apiClient.getLiveTvRecordings().done(function (result) { renderRecordings(page, result.Items); }); } $(document).on('pagebeforeshow', "#liveTvRecordingsPage", function () { var page = this; reload(page); }); })(jQuery, document, ApiClient);