Merge pull request #1713 from matjaz321/migrated-livetvsettings-to-es6-module

Migrated `/controllers/livetvsettings.js` to es6 module
This commit is contained in:
dkanada 2020-08-02 16:55:43 +09:00 committed by GitHub
commit 33700cb337
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 65 additions and 61 deletions

View file

@ -209,6 +209,7 @@
"src/controllers/searchpage.js",
"src/controllers/livetvtuner.js",
"src/controllers/livetvstatus.js",
"src/controllers/livetvsettings.js",
"src/controllers/shows/episodes.js",
"src/controllers/shows/tvgenres.js",
"src/controllers/shows/tvlatest.js",

View file

@ -1,5 +1,7 @@
define(['jQuery', 'loading', 'globalize', 'emby-button'], function ($, loading, globalize) {
'use strict';
import $ from 'jQuery';
import loading from 'loading';
import globalize from 'globalize';
import 'emby-button';
loading = loading.default || loading;
@ -19,13 +21,13 @@ define(['jQuery', 'loading', 'globalize', 'emby-button'], function ($, loading,
function onSubmit() {
loading.show();
var form = this;
const form = this;
ApiClient.getNamedConfiguration('livetv').then(function (config) {
config.GuideDays = $('#selectGuideDays', form).val() || null;
var recordingPath = form.querySelector('#txtRecordingPath').value || null;
var movieRecordingPath = form.querySelector('#txtMovieRecordingPath').value || null;
var seriesRecordingPath = form.querySelector('#txtSeriesRecordingPath').value || null;
var recordingPathChanged = recordingPath != config.RecordingPath || movieRecordingPath != config.MovieRecordingPath || seriesRecordingPath != config.SeriesRecordingPath;
const recordingPath = form.querySelector('#txtRecordingPath').value || null;
const movieRecordingPath = form.querySelector('#txtMovieRecordingPath').value || null;
const seriesRecordingPath = form.querySelector('#txtSeriesRecordingPath').value || null;
const recordingPathChanged = recordingPath != config.RecordingPath || movieRecordingPath != config.MovieRecordingPath || seriesRecordingPath != config.SeriesRecordingPath;
config.RecordingPath = recordingPath;
config.MovieRecordingPath = movieRecordingPath;
config.SeriesRecordingPath = seriesRecordingPath;
@ -43,25 +45,26 @@ define(['jQuery', 'loading', 'globalize', 'emby-button'], function ($, loading,
}
function showSaveMessage(recordingPathChanged) {
var msg = '';
let msg = '';
if (recordingPathChanged) {
msg += globalize.translate('RecordingPathChangeMessage');
}
if (msg) {
require(['alert'], function (alert) {
import('alert').then(({default: alert}) => {
alert(msg);
});
}
}
export default function () {
$(document).on('pageinit', '#liveTvSettingsPage', function () {
var page = this;
const page = this;
$('.liveTvSettingsForm').off('submit', onSubmit).on('submit', onSubmit);
$('#btnSelectRecordingPath', page).on('click.selectDirectory', function () {
require(['directorybrowser'], function (directoryBrowser) {
var picker = new directoryBrowser.default();
import('directorybrowser').then(({default: directoryBrowser}) => {
const picker = new directoryBrowser();
picker.show({
callback: function (path) {
if (path) {
@ -75,8 +78,8 @@ define(['jQuery', 'loading', 'globalize', 'emby-button'], function ($, loading,
});
});
$('#btnSelectMovieRecordingPath', page).on('click.selectDirectory', function () {
require(['directorybrowser'], function (directoryBrowser) {
var picker = new directoryBrowser.default();
import('directorybrowser').then(({default: directoryBrowser}) => {
const picker = new directoryBrowser();
picker.show({
callback: function (path) {
if (path) {
@ -90,8 +93,8 @@ define(['jQuery', 'loading', 'globalize', 'emby-button'], function ($, loading,
});
});
$('#btnSelectSeriesRecordingPath', page).on('click.selectDirectory', function () {
require(['directorybrowser'], function (directoryBrowser) {
var picker = new directoryBrowser.default();
import('directorybrowser').then(({default: directoryBrowser}) => {
const picker = new directoryBrowser();
picker.show({
callback: function (path) {
if (path) {
@ -105,8 +108,8 @@ define(['jQuery', 'loading', 'globalize', 'emby-button'], function ($, loading,
});
});
$('#btnSelectPostProcessorPath', page).on('click.selectDirectory', function () {
require(['directorybrowser'], function (directoryBrowser) {
var picker = new directoryBrowser.default();
import('directorybrowser').then(({default: directoryBrowser}) => {
const picker = new directoryBrowser();
picker.show({
includeFiles: true,
callback: function (path) {
@ -121,9 +124,9 @@ define(['jQuery', 'loading', 'globalize', 'emby-button'], function ($, loading,
});
}).on('pageshow', '#liveTvSettingsPage', function () {
loading.show();
var page = this;
const page = this;
ApiClient.getNamedConfiguration('livetv').then(function (config) {
loadPage(page, config);
});
});
});
}