2013-11-27 12:04:19 -07:00
|
|
|
|
(function ($, document, apiClient) {
|
|
|
|
|
|
2013-11-29 09:58:24 -07:00
|
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-27 12:04:19 -07:00
|
|
|
|
function renderRecordings(page, recordings) {
|
2013-11-29 09:58:24 -07:00
|
|
|
|
|
2013-11-27 12:04:19 -07:00
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = recordings.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var recording = recordings[i];
|
|
|
|
|
|
|
|
|
|
html += '<tr>';
|
|
|
|
|
|
2013-11-30 23:25:19 -07:00
|
|
|
|
html += '<td class="desktopColumn">';
|
2013-11-27 12:04:19 -07:00
|
|
|
|
html += '<button data-recordingid="' + recording.Id + '" class="btnDeleteRecording" type="button" data-icon="delete" data-inline="true" data-mini="true" data-iconpos="notext">Delete</button>';
|
|
|
|
|
html += '</td>';
|
|
|
|
|
|
2013-11-29 13:10:31 -07:00
|
|
|
|
html += '<td>';
|
2013-12-03 21:18:50 -07:00
|
|
|
|
html += '<a href="livetvrecording.html?id=' + recording.Id + '">';
|
2013-12-19 14:51:32 -07:00
|
|
|
|
html += recording.Name || '(blank)';
|
2013-12-03 21:18:50 -07:00
|
|
|
|
html += '</a>';
|
2013-11-30 23:25:19 -07:00
|
|
|
|
html += '</td>';
|
|
|
|
|
|
|
|
|
|
html += '<td class="desktopColumn">';
|
2013-11-29 13:10:31 -07:00
|
|
|
|
if (recording.ChannelId) {
|
|
|
|
|
html += '<a href="livetvchannel.html?id=' + recording.ChannelId + '">' + recording.ChannelName + '</a>';
|
|
|
|
|
}
|
|
|
|
|
html += '</td>';
|
2013-11-27 12:04:19 -07:00
|
|
|
|
|
|
|
|
|
var startDate = recording.StartDate;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
startDate = parseISO8601Date(startDate, { toLocal: true });
|
|
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<td>' + startDate.toLocaleDateString() + '</td>';
|
|
|
|
|
|
|
|
|
|
html += '<td>' + LiveTvHelpers.getDisplayTime(recording.StartDate) + '</td>';
|
|
|
|
|
|
2013-12-20 13:09:49 -07:00
|
|
|
|
var minutes = recording.RunTimeTicks / 600000000;
|
2013-12-03 21:18:50 -07:00
|
|
|
|
|
2013-12-20 13:09:49 -07:00
|
|
|
|
minutes = minutes || 1;
|
|
|
|
|
|
|
|
|
|
html += '<td class="tabletColumn">' + Math.round(minutes) + 'min</td>';
|
2013-11-27 12:04:19 -07:00
|
|
|
|
|
2013-11-30 23:25:19 -07:00
|
|
|
|
html += '<td class="tabletColumn">' + (recording.Status || '') + '</td>';
|
2013-11-27 12:04:19 -07:00
|
|
|
|
|
|
|
|
|
html += '</tr>';
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-30 23:25:19 -07:00
|
|
|
|
var elem = $('#table-column-toggle tbody', page).html(html).trigger('create');
|
2013-11-29 09:58:24 -07:00
|
|
|
|
|
|
|
|
|
$('.btnDeleteRecording', elem).on('click', function () {
|
|
|
|
|
|
|
|
|
|
var recordingId = this.getAttribute('data-recordingid');
|
|
|
|
|
|
|
|
|
|
deleteRecording(page, recordingId);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
2013-11-27 12:04:19 -07:00
|
|
|
|
}
|
2013-11-29 09:58:24 -07:00
|
|
|
|
|
2013-11-27 12:04:19 -07:00
|
|
|
|
function reload(page) {
|
|
|
|
|
|
2013-11-29 09:58:24 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
apiClient.getLiveTvRecordings().done(function (result) {
|
2013-11-27 12:04:19 -07:00
|
|
|
|
|
|
|
|
|
renderRecordings(page, result.Items);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-11-29 09:58:24 -07:00
|
|
|
|
|
2013-11-27 12:04:19 -07:00
|
|
|
|
$(document).on('pagebeforeshow', "#liveTvRecordingsPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
reload(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document, ApiClient);
|