mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-18 11:28:23 -07:00
115 lines
2.7 KiB
JavaScript
115 lines
2.7 KiB
JavaScript
define(['appStorage', 'events'], function (appStorage, events) {
|
|
'use strict';
|
|
|
|
function getKey(name, userId) {
|
|
|
|
if (userId) {
|
|
name = userId + '-' + name;
|
|
}
|
|
|
|
return name;
|
|
}
|
|
|
|
function AppSettings() {
|
|
|
|
var self = this;
|
|
|
|
self.enableAutoLogin = function (val) {
|
|
|
|
if (val != null) {
|
|
self.set('enableAutoLogin', val.toString());
|
|
}
|
|
|
|
return self.get('enableAutoLogin') !== 'false';
|
|
};
|
|
|
|
self.enableAutomaticBitrateDetection = function (val) {
|
|
|
|
if (val != null) {
|
|
self.set('enableAutomaticBitrateDetection', val.toString());
|
|
}
|
|
|
|
return self.get('enableAutomaticBitrateDetection') !== 'false';
|
|
};
|
|
|
|
self.maxStreamingBitrate = function (val) {
|
|
|
|
if (val != null) {
|
|
self.set('preferredVideoBitrate', val);
|
|
}
|
|
|
|
return parseInt(self.get('preferredVideoBitrate') || '0') || 1500000;
|
|
};
|
|
|
|
self.maxStaticMusicBitrate = function (val) {
|
|
|
|
if (val !== undefined) {
|
|
self.set('maxStaticMusicBitrate', val);
|
|
}
|
|
|
|
return parseInt(self.get('maxStaticMusicBitrate') || '0') || null;
|
|
};
|
|
|
|
self.maxChromecastBitrate = function (val) {
|
|
|
|
if (val != null) {
|
|
self.set('chromecastBitrate1', val);
|
|
}
|
|
|
|
val = self.get('chromecastBitrate1');
|
|
|
|
return val ? parseInt(val) : null;
|
|
};
|
|
|
|
self.syncOnlyOnWifi = function (val) {
|
|
|
|
if (val != null) {
|
|
self.set('syncOnlyOnWifi', val.toString());
|
|
}
|
|
|
|
return self.get('syncOnlyOnWifi') !== 'false';
|
|
};
|
|
|
|
self.syncPath = function (val) {
|
|
|
|
if (val != null) {
|
|
self.set('syncPath', val);
|
|
}
|
|
|
|
return self.get('syncPath');
|
|
};
|
|
|
|
self.cameraUploadServers = function (val) {
|
|
|
|
if (val != null) {
|
|
self.set('cameraUploadServers', val.join(','));
|
|
}
|
|
|
|
val = self.get('cameraUploadServers');
|
|
|
|
if (val) {
|
|
return val.split(',');
|
|
}
|
|
|
|
return [];
|
|
};
|
|
|
|
self.set = function (name, value, userId) {
|
|
|
|
var currentValue = self.get(name, userId);
|
|
|
|
appStorage.setItem(getKey(name, userId), value);
|
|
|
|
if (currentValue !== value) {
|
|
events.trigger(self, 'change', [name]);
|
|
}
|
|
};
|
|
|
|
self.get = function (name, userId) {
|
|
|
|
return appStorage.getItem(getKey(name, userId));
|
|
};
|
|
}
|
|
|
|
return new AppSettings();
|
|
}); |