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

154 lines
4.3 KiB
JavaScript
Raw Normal View History

2014-10-15 20:26:39 -07:00
(function ($, document) {
2013-12-14 18:17:57 -07:00
2014-01-11 16:07:56 -07:00
var query = {
SortBy: "SortName",
SortOrder: "Ascending"
};
function deleteSeriesTimer(page, id) {
2013-12-14 18:17:57 -07:00
2014-05-30 12:23:56 -07:00
Dashboard.confirm(Globalize.translate('MessageConfirmSeriesCancellation'), Globalize.translate('HeaderConfirmSeriesCancellation'), function (result) {
2013-12-14 18:17:57 -07:00
if (result) {
Dashboard.showLoadingMsg();
ApiClient.cancelLiveTvSeriesTimer(id).done(function () {
2014-05-30 12:23:56 -07:00
Dashboard.alert(Globalize.translate('MessageSeriesCancelled'));
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
2014-05-30 12:23:56 -07:00
html += '<li data-role="list-divider">' + Globalize.translate('HeaderSeriesRecordings') + '</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
2014-05-30 12:23:56 -07:00
html += ' - ' + Globalize.translate('LabelAnytime');
2013-12-27 19:46:32 -07:00
} else {
2015-05-22 12:16:14 -07:00
html += ' - ' + LibraryBrowser.getDisplayTime(timer.StartDate);
2013-12-27 19:46:32 -07:00
}
html += '</p>';
2013-12-14 18:17:57 -07:00
2013-12-27 19:46:32 -07:00
html += '<p>';
if (timer.RecordAnyChannel) {
2014-05-30 12:23:56 -07:00
html += Globalize.translate('LabelAllChannels');
2013-12-27 19:46:32 -07:00
}
else if (timer.ChannelId) {
html += timer.ChannelName;
}
html += '</p>';
html += '</a>';
2014-05-30 12:23:56 -07:00
html += '<a data-seriestimerid="' + timer.Id + '" href="#" title="' + Globalize.translate('ButtonCancelSeries') + '" class="btnCancelSeries">' + Globalize.translate('ButtonCancelSeries') + '</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');
2014-05-30 12:23:56 -07:00
$('.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();
2014-10-15 20:26:39 -07:00
ApiClient.getLiveTvSeriesTimers(query).done(function (result) {
2013-12-14 18:17:57 -07:00
renderTimers(page, result.Items);
2015-06-30 10:21:20 -07:00
LibraryBrowser.setLastRefreshed(page);
2013-12-14 18:17:57 -07:00
});
}
2014-01-11 16:07:56 -07:00
function updateFilterControls(page) {
// Reset form values using the last used query
$('.radioSortBy', page).each(function () {
this.checked = (query.SortBy || '').toLowerCase() == this.getAttribute('data-sortby').toLowerCase();
}).checkboxradio('refresh');
$('.radioSortOrder', page).each(function () {
this.checked = (query.SortOrder || '').toLowerCase() == this.getAttribute('data-sortorder').toLowerCase();
}).checkboxradio('refresh');
}
2015-08-02 16:47:31 -07:00
$(document).on('pagebeforeshowready', "#liveTvSuggestedPage", function () {
2013-12-14 18:17:57 -07:00
var page = this;
2015-08-02 16:47:31 -07:00
$(page.querySelector('neon-animated-pages')).on('tabchange', function () {
2014-05-30 12:23:56 -07:00
2015-08-02 16:47:31 -07:00
if (parseInt(this.selected) == 5) {
var tabContent = page.querySelector('.seriesTimersTabContent');
2014-01-11 16:07:56 -07:00
2015-08-02 16:47:31 -07:00
if (LibraryBrowser.needsRefresh(tabContent)) {
reload(tabContent);
}
}
});
}).on('pageinitdepends', "#liveTvSuggestedPage", function () {
var page = this.querySelector('.seriesTimersTabContent');
2014-01-11 16:07:56 -07:00
2015-08-02 16:47:31 -07:00
$('.radioSortBy', page).on('click', function () {
2014-01-11 16:07:56 -07:00
query.StartIndex = 0;
query.SortBy = this.getAttribute('data-sortby');
reload(page);
});
2015-08-02 16:47:31 -07:00
$('.radioSortOrder', page).on('click', function () {
2014-01-11 16:07:56 -07:00
query.StartIndex = 0;
query.SortOrder = this.getAttribute('data-sortorder');
reload(page);
});
updateFilterControls(this);
2013-12-14 18:17:57 -07:00
});
2014-10-15 20:26:39 -07:00
})(jQuery, document);