mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
convert four more files to es6
This commit is contained in:
parent
d41163d4b9
commit
dbf63c723c
9 changed files with 91 additions and 90 deletions
|
@ -1,5 +1,5 @@
|
|||
define(['appStorage', 'events'], function (appStorage, events) {
|
||||
'use strict';
|
||||
import appStorage from 'appStorage';
|
||||
import events from 'events';
|
||||
|
||||
function getKey(name, userId) {
|
||||
if (userId) {
|
||||
|
@ -9,26 +9,23 @@ define(['appStorage', 'events'], function (appStorage, events) {
|
|||
return name;
|
||||
}
|
||||
|
||||
function AppSettings() {
|
||||
}
|
||||
|
||||
AppSettings.prototype.enableAutoLogin = function (val) {
|
||||
export function enableAutoLogin(val) {
|
||||
if (val != null) {
|
||||
this.set('enableAutoLogin', val.toString());
|
||||
}
|
||||
|
||||
return this.get('enableAutoLogin') !== 'false';
|
||||
};
|
||||
}
|
||||
|
||||
AppSettings.prototype.enableSystemExternalPlayers = function (val) {
|
||||
export function enableSystemExternalPlayers(val) {
|
||||
if (val !== null) {
|
||||
this.set('enableSystemExternalPlayers', val.toString());
|
||||
}
|
||||
|
||||
return this.get('enableSystemExternalPlayers') === 'true';
|
||||
};
|
||||
}
|
||||
|
||||
AppSettings.prototype.enableAutomaticBitrateDetection = function (isInNetwork, mediaType, val) {
|
||||
export function enableAutomaticBitrateDetection(isInNetwork, mediaType, val) {
|
||||
var key = 'enableautobitratebitrate-' + mediaType + '-' + isInNetwork;
|
||||
if (val != null) {
|
||||
if (isInNetwork && mediaType === 'Audio') {
|
||||
|
@ -43,9 +40,9 @@ define(['appStorage', 'events'], function (appStorage, events) {
|
|||
} else {
|
||||
return this.get(key) !== 'false';
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
AppSettings.prototype.maxStreamingBitrate = function (isInNetwork, mediaType, val) {
|
||||
export function maxStreamingBitrate(isInNetwork, mediaType, val) {
|
||||
var key = 'maxbitrate-' + mediaType + '-' + isInNetwork;
|
||||
if (val != null) {
|
||||
if (isInNetwork && mediaType === 'Audio') {
|
||||
|
@ -61,43 +58,43 @@ define(['appStorage', 'events'], function (appStorage, events) {
|
|||
} else {
|
||||
return parseInt(this.get(key) || '0') || 1500000;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
AppSettings.prototype.maxStaticMusicBitrate = function (val) {
|
||||
export function maxStaticMusicBitrate(val) {
|
||||
if (val !== undefined) {
|
||||
this.set('maxStaticMusicBitrate', val);
|
||||
}
|
||||
|
||||
var defaultValue = 320000;
|
||||
return parseInt(this.get('maxStaticMusicBitrate') || defaultValue.toString()) || defaultValue;
|
||||
};
|
||||
}
|
||||
|
||||
AppSettings.prototype.maxChromecastBitrate = function (val) {
|
||||
export function maxChromecastBitrate(val) {
|
||||
if (val != null) {
|
||||
this.set('chromecastBitrate1', val);
|
||||
}
|
||||
|
||||
val = this.get('chromecastBitrate1');
|
||||
return val ? parseInt(val) : null;
|
||||
};
|
||||
}
|
||||
|
||||
AppSettings.prototype.syncOnlyOnWifi = function (val) {
|
||||
export function syncOnlyOnWifi(val) {
|
||||
if (val != null) {
|
||||
this.set('syncOnlyOnWifi', val.toString());
|
||||
}
|
||||
|
||||
return this.get('syncOnlyOnWifi') !== 'false';
|
||||
};
|
||||
}
|
||||
|
||||
AppSettings.prototype.syncPath = function (val) {
|
||||
export function syncPath(val) {
|
||||
if (val != null) {
|
||||
this.set('syncPath', val);
|
||||
}
|
||||
|
||||
return this.get('syncPath');
|
||||
};
|
||||
}
|
||||
|
||||
AppSettings.prototype.cameraUploadServers = function (val) {
|
||||
export function cameraUploadServers(val) {
|
||||
if (val != null) {
|
||||
this.set('cameraUploadServers', val.join(','));
|
||||
}
|
||||
|
@ -108,28 +105,40 @@ define(['appStorage', 'events'], function (appStorage, events) {
|
|||
}
|
||||
|
||||
return [];
|
||||
};
|
||||
}
|
||||
|
||||
AppSettings.prototype.runAtStartup = function (val) {
|
||||
export function runAtStartup(val) {
|
||||
if (val != null) {
|
||||
this.set('runatstartup', val.toString());
|
||||
}
|
||||
|
||||
return this.get('runatstartup') === 'true';
|
||||
};
|
||||
}
|
||||
|
||||
AppSettings.prototype.set = function (name, value, userId) {
|
||||
export function set(name, value, userId) {
|
||||
var currentValue = this.get(name, userId);
|
||||
appStorage.setItem(getKey(name, userId), value);
|
||||
|
||||
if (currentValue !== value) {
|
||||
events.trigger(this, 'change', [name]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
AppSettings.prototype.get = function (name, userId) {
|
||||
export function get(name, userId) {
|
||||
return appStorage.getItem(getKey(name, userId));
|
||||
};
|
||||
}
|
||||
|
||||
return new AppSettings();
|
||||
});
|
||||
export default {
|
||||
enableAutoLogin: enableAutoLogin,
|
||||
enableSystemExternalPlayers: enableSystemExternalPlayers,
|
||||
enableAutomaticBitrateDetection: enableAutomaticBitrateDetection,
|
||||
maxStreamingBitrate: maxStreamingBitrate,
|
||||
maxStaticMusicBitrate: maxStaticMusicBitrate,
|
||||
maxChromecastBitrate: maxChromecastBitrate,
|
||||
syncOnlyOnWifi: syncOnlyOnWifi,
|
||||
syncPath: syncPath,
|
||||
cameraUploadServers: cameraUploadServers,
|
||||
runAtStartup: runAtStartup,
|
||||
set: set,
|
||||
get: get
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
define(['appSettings', 'events'], function (appSettings, events) {
|
||||
'use strict';
|
||||
import appSettings from 'appSettings';
|
||||
import events from 'events';
|
||||
|
||||
function onSaveTimeout() {
|
||||
var self = this;
|
||||
|
@ -15,10 +15,7 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
instance.saveTimeout = setTimeout(onSaveTimeout.bind(instance), 50);
|
||||
}
|
||||
|
||||
function UserSettings() {
|
||||
}
|
||||
|
||||
UserSettings.prototype.setUserInfo = function (userId, apiClient) {
|
||||
export function setUserInfo(userId, apiClient) {
|
||||
if (this.saveTimeout) {
|
||||
clearTimeout(this.saveTimeout);
|
||||
}
|
||||
|
@ -39,15 +36,15 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
});
|
||||
};
|
||||
|
||||
UserSettings.prototype.getData = function () {
|
||||
export function getData() {
|
||||
return this.displayPrefs;
|
||||
};
|
||||
|
||||
UserSettings.prototype.importFrom = function (instance) {
|
||||
export function importFrom(instance) {
|
||||
this.displayPrefs = instance.getData();
|
||||
};
|
||||
|
||||
UserSettings.prototype.set = function (name, value, enableOnServer) {
|
||||
export function set(name, value, enableOnServer) {
|
||||
var userId = this.currentUserId;
|
||||
var currentValue = this.get(name, enableOnServer);
|
||||
var result = appSettings.set(name, value, userId);
|
||||
|
@ -64,7 +61,7 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
return result;
|
||||
};
|
||||
|
||||
UserSettings.prototype.get = function (name, enableOnServer) {
|
||||
export function get(name, enableOnServer) {
|
||||
var userId = this.currentUserId;
|
||||
if (enableOnServer !== false && this.displayPrefs) {
|
||||
return this.displayPrefs.CustomPrefs[name];
|
||||
|
@ -73,7 +70,7 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
return appSettings.get(name, userId);
|
||||
};
|
||||
|
||||
UserSettings.prototype.serverConfig = function (config) {
|
||||
export function serverConfig(config) {
|
||||
var apiClient = this.currentApiClient;
|
||||
if (config) {
|
||||
return apiClient.updateUserConfiguration(this.currentUserId, config);
|
||||
|
@ -84,7 +81,7 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
});
|
||||
};
|
||||
|
||||
UserSettings.prototype.enableCinemaMode = function (val) {
|
||||
export function enableCinemaMode(val) {
|
||||
if (val != null) {
|
||||
return this.set('enableCinemaMode', val.toString(), false);
|
||||
}
|
||||
|
@ -93,7 +90,7 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
return val !== 'false';
|
||||
};
|
||||
|
||||
UserSettings.prototype.enableNextVideoInfoOverlay = function (val) {
|
||||
export function enableNextVideoInfoOverlay(val) {
|
||||
if (val != null) {
|
||||
return this.set('enableNextVideoInfoOverlay', val.toString());
|
||||
}
|
||||
|
@ -102,7 +99,7 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
return val !== 'false';
|
||||
};
|
||||
|
||||
UserSettings.prototype.enableThemeSongs = function (val) {
|
||||
export function enableThemeSongs(val) {
|
||||
if (val != null) {
|
||||
return this.set('enableThemeSongs', val.toString(), false);
|
||||
}
|
||||
|
@ -111,7 +108,7 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
return val !== 'false';
|
||||
};
|
||||
|
||||
UserSettings.prototype.enableThemeVideos = function (val) {
|
||||
export function enableThemeVideos(val) {
|
||||
if (val != null) {
|
||||
return this.set('enableThemeVideos', val.toString(), false);
|
||||
}
|
||||
|
@ -120,7 +117,7 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
return val !== 'false';
|
||||
};
|
||||
|
||||
UserSettings.prototype.enableFastFadein = function (val) {
|
||||
export function enableFastFadein(val) {
|
||||
if (val != null) {
|
||||
return this.set('fastFadein', val.toString(), false);
|
||||
}
|
||||
|
@ -129,7 +126,7 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
return val !== 'false';
|
||||
};
|
||||
|
||||
UserSettings.prototype.enableBackdrops = function (val) {
|
||||
export function enableBackdrops(val) {
|
||||
if (val != null) {
|
||||
return this.set('enableBackdrops', val.toString(), false);
|
||||
}
|
||||
|
@ -138,7 +135,7 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
return val !== 'false';
|
||||
};
|
||||
|
||||
UserSettings.prototype.language = function (val) {
|
||||
export function language(val) {
|
||||
if (val != null) {
|
||||
return this.set('language', val.toString(), false);
|
||||
}
|
||||
|
@ -146,7 +143,7 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
return this.get('language', false);
|
||||
};
|
||||
|
||||
UserSettings.prototype.dateTimeLocale = function (val) {
|
||||
export function dateTimeLocale(val) {
|
||||
if (val != null) {
|
||||
return this.set('datetimelocale', val.toString(), false);
|
||||
}
|
||||
|
@ -154,7 +151,7 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
return this.get('datetimelocale', false);
|
||||
};
|
||||
|
||||
UserSettings.prototype.skipBackLength = function (val) {
|
||||
export function skipBackLength(val) {
|
||||
if (val != null) {
|
||||
return this.set('skipBackLength', val.toString());
|
||||
}
|
||||
|
@ -162,7 +159,7 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
return parseInt(this.get('skipBackLength') || '10000');
|
||||
};
|
||||
|
||||
UserSettings.prototype.skipForwardLength = function (val) {
|
||||
export function skipForwardLength(val) {
|
||||
if (val != null) {
|
||||
return this.set('skipForwardLength', val.toString());
|
||||
}
|
||||
|
@ -170,7 +167,7 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
return parseInt(this.get('skipForwardLength') || '30000');
|
||||
};
|
||||
|
||||
UserSettings.prototype.dashboardTheme = function (val) {
|
||||
export function dashboardTheme(val) {
|
||||
if (val != null) {
|
||||
return this.set('dashboardTheme', val);
|
||||
}
|
||||
|
@ -178,7 +175,7 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
return this.get('dashboardTheme');
|
||||
};
|
||||
|
||||
UserSettings.prototype.skin = function (val) {
|
||||
export function skin(val) {
|
||||
if (val != null) {
|
||||
return this.set('skin', val, false);
|
||||
}
|
||||
|
@ -186,7 +183,7 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
return this.get('skin', false);
|
||||
};
|
||||
|
||||
UserSettings.prototype.theme = function (val) {
|
||||
export function theme(val) {
|
||||
if (val != null) {
|
||||
return this.set('appTheme', val, false);
|
||||
}
|
||||
|
@ -194,7 +191,7 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
return this.get('appTheme', false);
|
||||
};
|
||||
|
||||
UserSettings.prototype.screensaver = function (val) {
|
||||
export function screensaver(val) {
|
||||
if (val != null) {
|
||||
return this.set('screensaver', val, false);
|
||||
}
|
||||
|
@ -202,7 +199,7 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
return this.get('screensaver', false);
|
||||
};
|
||||
|
||||
UserSettings.prototype.soundEffects = function (val) {
|
||||
export function soundEffects(val) {
|
||||
if (val != null) {
|
||||
return this.set('soundeffects', val, false);
|
||||
}
|
||||
|
@ -210,7 +207,7 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
return this.get('soundeffects', false);
|
||||
};
|
||||
|
||||
UserSettings.prototype.loadQuerySettings = function (key, query) {
|
||||
export function loadQuerySettings(key, query) {
|
||||
var values = this.get(key);
|
||||
if (values) {
|
||||
values = JSON.parse(values);
|
||||
|
@ -220,7 +217,7 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
return query;
|
||||
};
|
||||
|
||||
UserSettings.prototype.saveQuerySettings = function (key, query) {
|
||||
export function saveQuerySettings(key, query) {
|
||||
var values = {};
|
||||
if (query.SortBy) {
|
||||
values.SortBy = query.SortBy;
|
||||
|
@ -233,23 +230,20 @@ define(['appSettings', 'events'], function (appSettings, events) {
|
|||
return this.set(key, JSON.stringify(values));
|
||||
};
|
||||
|
||||
UserSettings.prototype.getSubtitleAppearanceSettings = function (key) {
|
||||
export function getSubtitleAppearanceSettings(key) {
|
||||
key = key || 'localplayersubtitleappearance3';
|
||||
return JSON.parse(this.get(key, false) || '{}');
|
||||
};
|
||||
|
||||
UserSettings.prototype.setSubtitleAppearanceSettings = function (value, key) {
|
||||
export function setSubtitleAppearanceSettings(value, key) {
|
||||
key = key || 'localplayersubtitleappearance3';
|
||||
return this.set(key, JSON.stringify(value), false);
|
||||
};
|
||||
|
||||
UserSettings.prototype.setFilter = function (key, value) {
|
||||
export function setFilter(key, value) {
|
||||
return this.set(key, value, true);
|
||||
};
|
||||
|
||||
UserSettings.prototype.getFilter = function (key) {
|
||||
export function getFilter(key) {
|
||||
return this.get(key, true);
|
||||
};
|
||||
|
||||
return UserSettings;
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue