Fix multiplication of event listeners

This commit is contained in:
Dmitry Lyzo 2020-12-10 11:27:51 +03:00
parent 3992265189
commit 6a6eae96e6
2 changed files with 96 additions and 100 deletions

View file

@ -56,75 +56,73 @@ function showSaveMessage(recordingPathChanged) {
} }
} }
export default function () { $(document).on('pageinit', '#liveTvSettingsPage', function () {
$(document).on('pageinit', '#liveTvSettingsPage', function () { const page = this;
const page = this; $('.liveTvSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
$('.liveTvSettingsForm').off('submit', onSubmit).on('submit', onSubmit); $('#btnSelectRecordingPath', page).on('click.selectDirectory', function () {
$('#btnSelectRecordingPath', page).on('click.selectDirectory', function () { import('../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => {
import('../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => { const picker = new directoryBrowser();
const picker = new directoryBrowser(); picker.show({
picker.show({ callback: function (path) {
callback: function (path) { if (path) {
if (path) { $('#txtRecordingPath', page).val(path);
$('#txtRecordingPath', page).val(path);
}
picker.close();
},
validateWriteable: true
});
});
});
$('#btnSelectMovieRecordingPath', page).on('click.selectDirectory', function () {
import('../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => {
const picker = new directoryBrowser();
picker.show({
callback: function (path) {
if (path) {
$('#txtMovieRecordingPath', page).val(path);
}
picker.close();
},
validateWriteable: true
});
});
});
$('#btnSelectSeriesRecordingPath', page).on('click.selectDirectory', function () {
import('../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => {
const picker = new directoryBrowser();
picker.show({
callback: function (path) {
if (path) {
$('#txtSeriesRecordingPath', page).val(path);
}
picker.close();
},
validateWriteable: true
});
});
});
$('#btnSelectPostProcessorPath', page).on('click.selectDirectory', function () {
import('../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => {
const picker = new directoryBrowser();
picker.show({
includeFiles: true,
callback: function (path) {
if (path) {
$('#txtPostProcessor', page).val(path);
}
picker.close();
} }
});
picker.close();
},
validateWriteable: true
}); });
}); });
}).on('pageshow', '#liveTvSettingsPage', function () {
loading.show();
const page = this;
ApiClient.getNamedConfiguration('livetv').then(function (config) {
loadPage(page, config);
});
}); });
} $('#btnSelectMovieRecordingPath', page).on('click.selectDirectory', function () {
import('../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => {
const picker = new directoryBrowser();
picker.show({
callback: function (path) {
if (path) {
$('#txtMovieRecordingPath', page).val(path);
}
picker.close();
},
validateWriteable: true
});
});
});
$('#btnSelectSeriesRecordingPath', page).on('click.selectDirectory', function () {
import('../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => {
const picker = new directoryBrowser();
picker.show({
callback: function (path) {
if (path) {
$('#txtSeriesRecordingPath', page).val(path);
}
picker.close();
},
validateWriteable: true
});
});
});
$('#btnSelectPostProcessorPath', page).on('click.selectDirectory', function () {
import('../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => {
const picker = new directoryBrowser();
picker.show({
includeFiles: true,
callback: function (path) {
if (path) {
$('#txtPostProcessor', page).val(path);
}
picker.close();
}
});
});
});
}).on('pageshow', '#liveTvSettingsPage', function () {
loading.show();
const page = this;
ApiClient.getNamedConfiguration('livetv').then(function (config) {
loadPage(page, config);
});
});

View file

@ -293,36 +293,34 @@ function onDevicesListClick(e) {
} }
} }
export default function () { $(document).on('pageinit', '#liveTvStatusPage', function () {
$(document).on('pageinit', '#liveTvStatusPage', function () { const page = this;
const page = this; $('.btnAddDevice', page).on('click', function () {
$('.btnAddDevice', page).on('click', function () { addDevice(this);
addDevice(this);
});
$('.formAddDevice', page).on('submit', function () {
submitAddDeviceForm(page);
return false;
});
$('.btnAddProvider', page).on('click', function () {
addProvider(this);
});
page.querySelector('.devicesList').addEventListener('click', onDevicesListClick);
}).on('pageshow', '#liveTvStatusPage', function () {
const page = this;
reload(page);
taskButton({
mode: 'on',
progressElem: page.querySelector('.refreshGuideProgress'),
taskKey: 'RefreshGuide',
button: page.querySelector('.btnRefresh')
});
}).on('pagehide', '#liveTvStatusPage', function () {
const page = this;
taskButton({
mode: 'off',
progressElem: page.querySelector('.refreshGuideProgress'),
taskKey: 'RefreshGuide',
button: page.querySelector('.btnRefresh')
});
}); });
} $('.formAddDevice', page).on('submit', function () {
submitAddDeviceForm(page);
return false;
});
$('.btnAddProvider', page).on('click', function () {
addProvider(this);
});
page.querySelector('.devicesList').addEventListener('click', onDevicesListClick);
}).on('pageshow', '#liveTvStatusPage', function () {
const page = this;
reload(page);
taskButton({
mode: 'on',
progressElem: page.querySelector('.refreshGuideProgress'),
taskKey: 'RefreshGuide',
button: page.querySelector('.btnRefresh')
});
}).on('pagehide', '#liveTvStatusPage', function () {
const page = this;
taskButton({
mode: 'off',
progressElem: page.querySelector('.refreshGuideProgress'),
taskKey: 'RefreshGuide',
button: page.querySelector('.btnRefresh')
});
});