1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/scripts/livetvtimers.js

58 lines
1.4 KiB
JavaScript
Raw Normal View History

define(['jQuery'], function ($) {
2013-11-27 14:04:19 -05:00
function deleteTimer(page, id) {
2016-02-22 14:31:28 -05:00
require(['confirm'], function (confirm) {
2016-02-22 14:31:28 -05:00
confirm(Globalize.translate('MessageConfirmRecordingCancellation'), Globalize.translate('HeaderConfirmRecordingCancellation')).then(function () {
Dashboard.showLoadingMsg();
2015-12-14 10:43:03 -05:00
ApiClient.cancelLiveTvTimer(id).then(function () {
2016-02-25 01:38:12 -05:00
require(['toast'], function (toast) {
toast(Globalize.translate('MessageRecordingCancelled'));
});
reload(page);
});
2016-02-22 14:31:28 -05:00
});
});
}
2013-11-27 14:04:19 -05:00
function renderTimers(page, timers) {
2015-12-14 10:43:03 -05:00
LiveTvHelpers.getTimersHtml(timers).then(function (html) {
2016-02-18 13:19:18 -05:00
var elem = $('#items', page).html(html)[0];
ImageLoader.lazyChildren(elem);
2013-11-27 14:04:19 -05:00
2015-12-14 10:43:03 -05:00
$('.btnDeleteTimer', elem).on('click', function () {
2015-12-14 10:43:03 -05:00
var id = this.getAttribute('data-timerid');
2015-12-14 10:43:03 -05:00
deleteTimer(page, id);
});
2015-12-14 10:43:03 -05:00
Dashboard.hideLoadingMsg();
});
2013-11-27 14:04:19 -05:00
}
function reload(page) {
2013-11-29 13:44:51 -05:00
Dashboard.showLoadingMsg();
2013-12-14 10:49:11 -05:00
2015-12-14 10:43:03 -05:00
ApiClient.getLiveTvTimers().then(function (result) {
2013-11-27 14:04:19 -05:00
renderTimers(page, result.Items);
});
}
2015-08-18 11:52:48 -04:00
window.LiveTvPage.renderTimersTab = function (page, tabContent) {
2013-11-27 14:04:19 -05:00
2015-08-18 11:52:48 -04:00
if (LibraryBrowser.needsRefresh(tabContent)) {
reload(tabContent);
}
};
2013-11-27 14:04:19 -05:00
});