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) {
|
|
|
|
|
|
2013-12-12 21:57:01 -07:00
|
|
|
|
Dashboard.confirm("Are you sure you wish to cancel this timer?", "Confirm Timer Cancellation", function (result) {
|
2013-11-29 09:58:24 -07:00
|
|
|
|
|
|
|
|
|
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>';
|
|
|
|
|
|
2013-11-30 23:25:19 -07:00
|
|
|
|
html += '<th class="tabletColumn"> </th>';
|
2013-11-27 12:04:19 -07:00
|
|
|
|
html += '<th>Name</th>';
|
2013-11-30 23:25:19 -07:00
|
|
|
|
html += '<th class="desktopColumn">Channel</th>';
|
2013-11-27 12:04:19 -07:00
|
|
|
|
html += '<th>Date</th>';
|
|
|
|
|
html += '<th>Start</th>';
|
2013-12-03 21:18:50 -07:00
|
|
|
|
html += '<th class="tabletColumn">Length</th>';
|
2013-11-30 23:25:19 -07:00
|
|
|
|
html += '<th class="tabletColumn">Status</th>';
|
|
|
|
|
html += '<th class="desktopColumn">Recurring</th>';
|
2013-11-27 12:04:19 -07:00
|
|
|
|
|
|
|
|
|
html += '</tr>';
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = timers.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
var timer = timers[i];
|
|
|
|
|
|
|
|
|
|
html += '<tr>';
|
|
|
|
|
|
2013-11-30 23:25:19 -07:00
|
|
|
|
html += '<td class="tabletColumn">';
|
2013-11-27 12:04:19 -07:00
|
|
|
|
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>';
|
|
|
|
|
|
2013-11-29 13:10:31 -07:00
|
|
|
|
html += '<td>';
|
2013-11-30 23:25:19 -07:00
|
|
|
|
html += '<a href="livetvtimer.html?id=' + timer.Id + '">' + timer.Name + '</a>';
|
|
|
|
|
html += '</td>';
|
|
|
|
|
|
|
|
|
|
html += '<td class="desktopColumn">';
|
2013-11-29 13:10:31 -07:00
|
|
|
|
if (timer.ChannelId) {
|
|
|
|
|
html += '<a href="livetvchannel.html?id=' + timer.ChannelId + '">' + timer.ChannelName + '</a>';
|
|
|
|
|
}
|
|
|
|
|
html += '</td>';
|
2013-11-27 12:04:19 -07:00
|
|
|
|
|
|
|
|
|
var startDate = timer.StartDate;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
startDate = parseISO8601Date(startDate, { toLocal: true });
|
|
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '<td>' + startDate.toLocaleDateString() + '</td>';
|
|
|
|
|
|
|
|
|
|
html += '<td>' + LiveTvHelpers.getDisplayTime(timer.StartDate) + '</td>';
|
|
|
|
|
|
2013-12-03 21:18:50 -07:00
|
|
|
|
var minutes = timer.DurationMs / 60000;
|
|
|
|
|
|
|
|
|
|
html += '<td class="tabletColumn">' + minutes.toFixed(0) + ' mins</td>';
|
2013-11-27 12:04:19 -07:00
|
|
|
|
|
2013-11-30 23:25:19 -07:00
|
|
|
|
html += '<td class="tabletColumn">' + (timer.Status || '') + '</td>';
|
2013-11-27 12:04:19 -07:00
|
|
|
|
|
2013-11-30 23:25:19 -07:00
|
|
|
|
html += '<td class="desktopColumn">';
|
2013-11-29 11:44:51 -07:00
|
|
|
|
|
|
|
|
|
if (timer.IsRecurring) {
|
|
|
|
|
html += ' ';
|
|
|
|
|
html += '✓';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</td>';
|
2013-11-27 12:04:19 -07:00
|
|
|
|
|
|
|
|
|
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-29 11:44:51 -07:00
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
2013-11-27 12:04:19 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function reload(page) {
|
|
|
|
|
|
2013-11-29 11:44:51 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2013-11-27 12:04:19 -07:00
|
|
|
|
apiClient.getLiveTvTimers().done(function (result) {
|
|
|
|
|
|
|
|
|
|
renderTimers(page, result.Items);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).on('pagebeforeshow', "#liveTvTimersPage", function () {
|
|
|
|
|
|
|
|
|
|
var page = this;
|
|
|
|
|
|
|
|
|
|
reload(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
})(jQuery, document, ApiClient);
|