2013-11-27 12:04:19 -07:00
|
|
|
|
(function ($, document, apiClient) {
|
|
|
|
|
|
2013-11-29 09:58:24 -07:00
|
|
|
|
function editTimer(page, id) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteTimer(page, id) {
|
|
|
|
|
|
|
|
|
|
Dashboard.confirm("Are you sure you wish to delete this timer?", "Confirm Timer Deletion", function (result) {
|
|
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
ApiClient.cancelLiveTvTimer(id).done(function () {
|
|
|
|
|
|
|
|
|
|
Dashboard.alert('Timer deleted');
|
|
|
|
|
|
|
|
|
|
reload(page);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-27 12:04:19 -07:00
|
|
|
|
function renderTimers(page, timers) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
var cssClass = "detailTable";
|
|
|
|
|
|
|
|
|
|
html += '<div class="detailTableContainer"><table class="' + cssClass + '">';
|
|
|
|
|
|
|
|
|
|
html += '<tr>';
|
|
|
|
|
|
|
|
|
|
html += '<th> </th>';
|
|
|
|
|
html += '<th>Name</th>';
|
|
|
|
|
html += '<th>Channel</th>';
|
|
|
|
|
html += '<th>Date</th>';
|
|
|
|
|
html += '<th>Start</th>';
|
|
|
|
|
html += '<th>End</th>';
|
|
|
|
|
html += '<th>Status</th>';
|
|
|
|
|
html += '<th>Recurring Schedule</th>';
|
|
|
|
|
|
|
|
|
|
html += '</tr>';
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = timers.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var timer = timers[i];
|
|
|
|
|
|
|
|
|
|
html += '<tr>';
|
|
|
|
|
|
|
|
|
|
html += '<td>';
|
|
|
|
|
html += '<button data-timerid="' + timer.Id + '" class="btnEditTimer" type="button" data-icon="pencil" data-inline="true" data-mini="true" data-iconpos="notext">Edit</button>';
|
|
|
|
|
html += '<button data-timerid="' + timer.Id + '" class="btnDeleteTimer" type="button" data-icon="delete" data-inline="true" data-mini="true" data-iconpos="notext">Delete</button>';
|
|
|
|
|
html += '</td>';
|
|
|
|
|
|
|
|
|
|
html += '<td>' + (timer.Name || '') + '</td>';
|
|
|
|
|
html += '<td>' + (timer.ChannelName || '') + '</td>';
|
|
|
|
|
|
|
|
|
|
var startDate = timer.StartDate;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
startDate = parseISO8601Date(startDate, { toLocal: true });
|
|
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<td>' + startDate.toLocaleDateString() + '</td>';
|
|
|
|
|
|
|
|
|
|
html += '<td>' + LiveTvHelpers.getDisplayTime(timer.StartDate) + '</td>';
|
|
|
|
|
|
|
|
|
|
html += '<td>' + LiveTvHelpers.getDisplayTime(timer.EndDate) + '</td>';
|
|
|
|
|
|
|
|
|
|
html += '<td>' + (timer.Status || '') + '</td>';
|
|
|
|
|
|
|
|
|
|
html += '<td></td>';
|
|
|
|
|
|
|
|
|
|
html += '</tr>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</table></div>';
|
|
|
|
|
|
|
|
|
|
var elem = $('#items', page).html(html).trigger('create');
|
2013-11-29 09:58:24 -07:00
|
|
|
|
|
|
|
|
|
$('.btnEditTimer', elem).on('click', function () {
|
|
|
|
|
|
|
|
|
|
var id = this.getAttribute('data-timerid');
|
|
|
|
|
|
|
|
|
|
editTimer(page, id);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.btnDeleteTimer', elem).on('click', function () {
|
|
|
|
|
|
|
|
|
|
var id = this.getAttribute('data-timerid');
|
|
|
|
|
|
|
|
|
|
deleteTimer(page, id);
|
|
|
|
|
});
|
2013-11-27 12:04:19 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function reload(page) {
|
|
|
|
|
|
|
|
|
|
apiClient.getLiveTvTimers().done(function (result) {
|
|
|
|
|
|
|
|
|
|
renderTimers(page, result.Items);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).on('pagebeforeshow', "#liveTvTimersPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
reload(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document, ApiClient);
|