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

104 lines
2.5 KiB
JavaScript
Raw Normal View History

2013-12-14 18:17:57 -07:00
(function ($, document, apiClient) {
function deleteSeriesTimer(page, id) {
2013-12-14 18:17:57 -07:00
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 = '';
html += '<ul data-role="listview" data-inset="true" data-split-icon="delete">';
2013-12-14 18:17:57 -07:00
2013-12-27 19:46:32 -07:00
html += '<li data-role="list-divider">Series Recordings</li>';
2013-12-14 18:17:57 -07:00
for (var i = 0, length = timers.length; i < length; i++) {
var timer = timers[i];
2013-12-27 19:46:32 -07:00
html += '<li><a href="livetvseriestimer.html?id=' + timer.Id + '">';
2013-12-14 18:17:57 -07:00
2013-12-27 19:46:32 -07:00
html += '<h3>';
html += timer.Name;
html += '</h3>';
2013-12-14 18:17:57 -07:00
2013-12-27 19:46:32 -07:00
html += '<p>';
2013-12-14 18:17:57 -07:00
if (timer.DayPattern) {
html += timer.DayPattern;
}
else {
var days = timer.Days || [];
html += days.join(', ');
}
2013-12-27 19:46:32 -07:00
if (timer.RecordAnyTime) {
2013-12-14 18:17:57 -07:00
2013-12-27 19:46:32 -07:00
html += ' - Any time.';
} else {
html += ' - ' + LiveTvHelpers.getDisplayTime(timer.StartDate);
}
html += '</p>';
2013-12-14 18:17:57 -07:00
2013-12-27 19:46:32 -07:00
html += '<p>';
if (timer.RecordAnyChannel) {
html += 'All Channels';
}
else if (timer.ChannelId) {
html += timer.ChannelName;
}
html += '</p>';
html += '</a>';
html += '<a data-seriestimerid="' + timer.Id + '" href="#" title="Cancel Series" class="btnCancelSeries">Cancel Series</a>';
2013-12-15 07:19:24 -07:00
2013-12-27 19:46:32 -07:00
html += '</li>';
2013-12-14 18:17:57 -07:00
}
2013-12-28 14:37:01 -07:00
html += '</ul>';
2013-12-14 18:17:57 -07:00
var elem = $('#items', page).html(html).trigger('create');
$('.btnCancelSeries', elem).on('click', function() {
deleteSeriesTimer(page, this.getAttribute('data-seriestimerid'));
});
2013-12-14 18:17:57 -07:00
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);