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

56 lines
1.4 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) {
2016-02-22 12:31:28 -07:00
require(['confirm'], function (confirm) {
2016-02-22 12:31:28 -07:00
confirm(Globalize.translate('MessageConfirmRecordingCancellation'), Globalize.translate('HeaderConfirmRecordingCancellation')).then(function () {
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);
});
2016-02-22 12:31:28 -07:00
});
});
}
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) {
2016-02-18 11:19:18 -07:00
var elem = $('#items', page).html(html)[0];
ImageLoader.lazyChildren(elem);
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);