jellyfin-web/dashboard-ui/scripts/livetvseriestimers.js

114 lines
2.9 KiB
JavaScript
Raw Normal View History

2013-12-14 18:17:57 -07:00
(function ($, document, apiClient) {
function deleteTimer(page, id) {
2013-12-19 14:51:32 -07:00
Dashboard.confirm("Are you sure you wish to cancel this series?", "Confirm Series Cancellation", function (result) {
2013-12-14 18:17:57 -07:00
if (result) {
Dashboard.showLoadingMsg();
ApiClient.cancelLiveTvSeriesTimer(id).done(function () {
2013-12-19 14:51:32 -07:00
Dashboard.alert('Series cancelled.');
2013-12-14 18:17:57 -07:00
reload(page);
});
}
});
}
function renderTimers(page, timers) {
var html = '';
var cssClass = "detailTable";
html += '<div class="detailTableContainer"><table class="' + cssClass + '">';
html += '<tr>';
html += '<th class="tabletColumn">&nbsp;</th>';
html += '<th>Name</th>';
html += '<th class="desktopColumn">Channel</th>';
2013-12-16 23:08:06 -07:00
html += '<th>Days</th>';
html += '<th>Time</th>';
2013-12-14 18:17:57 -07:00
html += '</tr>';
for (var i = 0, length = timers.length; i < length; i++) {
var timer = timers[i];
html += '<tr>';
html += '<td class="tabletColumn">';
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>';
html += '<a href="livetvseriestimer.html?id=' + timer.Id + '">' + timer.Name + '</a>';
html += '</td>';
html += '<td class="desktopColumn">';
2013-12-15 07:19:24 -07:00
2013-12-16 11:44:03 -07:00
if (timer.RecordAnyChannel) {
2013-12-15 07:19:24 -07:00
html += 'All Channels';
}
else if (timer.ChannelId) {
2013-12-14 18:17:57 -07:00
html += '<a href="livetvchannel.html?id=' + timer.ChannelId + '">' + timer.ChannelName + '</a>';
}
html += '</td>';
2013-12-16 23:08:06 -07:00
html += '<td>';
2013-12-14 18:17:57 -07:00
if (timer.DayPattern) {
html += timer.DayPattern;
}
else {
var days = timer.Days || [];
html += days.join(', ');
}
html += '</td>';
2013-12-16 23:08:06 -07:00
html += '<td>' + LiveTvHelpers.getDisplayTime(timer.StartDate) + '</td>';
2013-12-15 07:19:24 -07:00
2013-12-14 18:17:57 -07:00
html += '</tr>';
}
html += '</table></div>';
var elem = $('#items', page).html(html).trigger('create');
$('.btnDeleteTimer', elem).on('click', function () {
var id = this.getAttribute('data-timerid');
deleteTimer(page, id);
});
Dashboard.hideLoadingMsg();
}
function reload(page) {
Dashboard.showLoadingMsg();
apiClient.getLiveTvSeriesTimers().done(function (result) {
renderTimers(page, result.Items);
});
}
$(document).on('pagebeforeshow', "#liveTvSeriesTimersPage", function () {
var page = this;
reload(page);
});
})(jQuery, document, ApiClient);