jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/appsettings.js

112 lines
2.6 KiB
JavaScript
Raw Normal View History

2016-04-03 10:34:52 -07:00
define(['appStorage', 'events'], function (appStorage, events) {
2016-02-29 21:23:40 -07:00
function getKey(name, userId) {
if (userId) {
name = userId + '-' + name;
}
return name;
}
2016-04-03 10:34:52 -07:00
return new function () {
2016-02-29 21:23:40 -07:00
2016-04-03 10:34:52 -07:00
var self = this;
2016-02-29 21:23:40 -07:00
2016-05-25 09:10:57 -07:00
self.enableAutoLogin = function (val) {
if (val != null) {
self.set('enableAutoLogin', val.toString());
}
return self.get('enableAutoLogin') != 'false';
};
2016-04-03 10:34:52 -07:00
self.enableAutomaticBitrateDetection = function (val) {
2016-02-29 21:23:40 -07:00
if (val != null) {
2016-04-03 10:34:52 -07:00
self.set('enableAutomaticBitrateDetection', val.toString());
2016-02-29 21:23:40 -07:00
}
2016-04-03 10:34:52 -07:00
return self.get('enableAutomaticBitrateDetection') != 'false';
};
self.maxStreamingBitrate = function (val) {
2016-02-29 21:23:40 -07:00
if (val != null) {
2016-04-03 10:34:52 -07:00
self.set('preferredVideoBitrate', val);
2016-02-29 21:23:40 -07:00
}
2016-08-22 22:08:07 -07:00
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;
2016-04-03 10:34:52 -07:00
};
self.maxChromecastBitrate = function (val) {
2016-02-29 23:02:03 -07:00
if (val != null) {
2016-04-03 10:34:52 -07:00
self.set('chromecastBitrate1', val);
2016-02-29 23:02:03 -07:00
}
2016-04-03 10:34:52 -07:00
val = self.get('chromecastBitrate1');
2016-02-29 23:02:03 -07:00
return val ? parseInt(val) : null;
2016-04-03 10:34:52 -07:00
};
self.syncOnlyOnWifi = function (val) {
2016-02-29 23:02:03 -07:00
if (val != null) {
2016-04-03 10:34:52 -07:00
self.set('syncOnlyOnWifi', val.toString());
2016-02-29 23:02:03 -07:00
}
2016-04-03 10:34:52 -07:00
return self.get('syncOnlyOnWifi') != 'false';
};
self.syncPath = function (val) {
2016-02-29 23:02:03 -07:00
if (val != null) {
2016-04-03 10:34:52 -07:00
self.set('syncPath', val);
2016-02-29 23:02:03 -07:00
}
2016-04-03 10:34:52 -07:00
return self.get('syncPath');
};
2016-02-29 23:02:03 -07:00
2016-04-03 10:34:52 -07:00
self.cameraUploadServers = function (val) {
2016-02-29 23:02:03 -07:00
if (val != null) {
2016-04-03 10:34:52 -07:00
self.set('cameraUploadServers', val.join(','));
2016-02-29 23:02:03 -07:00
}
2016-04-03 10:34:52 -07:00
val = self.get('cameraUploadServers');
2016-02-29 23:02:03 -07:00
if (val) {
return val.split(',');
}
return [];
2016-04-03 10:34:52 -07:00
};
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));
};
}();
2016-02-29 21:23:40 -07:00
});