You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/src/UI/Config.js

52 lines
1.6 KiB

'use strict';
12 years ago
define(
[
'vent'
], function (vent) {
return {
12 years ago
Events: {
ConfigUpdatedEvent: 'ConfigUpdatedEvent'
},
Keys : {
DefaultProfileId : 'DefaultProfileId',
DefaultRootFolderId : 'DefaultRootFolderId',
UseSeasonFolder : 'UseSeasonFolder',
DefaultSeriesType : 'DefaultSeriesType',
AdvancedSettings : 'advancedSettings'
},
getValueBoolean: function (key, defaultValue) {
defaultValue = defaultValue || false;
return this.getValue(key, defaultValue.toString()) === 'true';
},
11 years ago
getValue: function (key, defaultValue) {
11 years ago
var storeValue = window.localStorage.getItem(key);
if (!storeValue) {
return defaultValue;
}
return storeValue.toString();
},
11 years ago
setValue: function (key, value) {
console.log('Config: [{0}] => [{1}]'.format(key, value));
11 years ago
if (this.getValue(key) === value.toString()) {
return;
}
try {
window.localStorage.setItem(key, value);
vent.trigger(this.Events.ConfigUpdatedEvent, {key: key, value: value});
}
catch (error) {
console.error('Unable to save config: [{0}] => [{1}]'.format(key, value));
}
}
};
12 years ago
});