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

55 lines
1.3 KiB
JavaScript
Raw Normal View History

2014-10-15 20:26:39 -07:00
(function ($, document) {
2013-11-27 12:04:19 -07:00
function deleteTimer(page, id) {
2014-05-30 12:23:56 -07:00
Dashboard.confirm(Globalize.translate('MessageConfirmRecordingCancellation'), Globalize.translate('HeaderConfirmRecordingCancellation'), function (result) {
if (result) {
Dashboard.showLoadingMsg();
2015-12-14 08:43:03 -07:00
ApiClient.cancelLiveTvTimer(id).then(function () {
2014-05-30 12:23:56 -07:00
Dashboard.alert(Globalize.translate('MessageRecordingCancelled'));
reload(page);
});
}
});
}
2013-11-27 12:04:19 -07:00
function renderTimers(page, timers) {
2015-12-14 08:43:03 -07:00
LiveTvHelpers.getTimersHtml(timers).then(function (html) {
var elem = $('#items', page).html(html);
2013-11-27 12:04:19 -07:00
2015-12-14 08:43:03 -07:00
$('.btnDeleteTimer', elem).on('click', function () {
2015-12-14 08:43:03 -07:00
var id = this.getAttribute('data-timerid');
2015-12-14 08:43:03 -07:00
deleteTimer(page, id);
});
2015-12-14 08:43:03 -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-12-14 08:49:11 -07:00
2015-12-14 08:43:03 -07:00
ApiClient.getLiveTvTimers().then(function (result) {
2013-11-27 12:04:19 -07:00
renderTimers(page, result.Items);
});
}
2015-08-18 08:52:48 -07:00
window.LiveTvPage.renderTimersTab = function (page, tabContent) {
2013-11-27 12:04:19 -07:00
2015-08-18 08:52:48 -07:00
if (LibraryBrowser.needsRefresh(tabContent)) {
reload(tabContent);
}
};
2013-11-27 12:04:19 -07:00
2014-10-15 20:26:39 -07:00
})(jQuery, document);