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.
47 lines
1.3 KiB
47 lines
1.3 KiB
'use strict';
|
|
define(
|
|
[
|
|
'vent'
|
|
], function (vent) {
|
|
return {
|
|
Events: {
|
|
ConfigUpdatedEvent: 'ConfigUpdatedEvent'
|
|
},
|
|
Keys : {
|
|
DefaultQualityProfileId: 'DefaultQualityProfileId',
|
|
DefaultRootFolderId : 'DefaultRootFolderId',
|
|
UseSeasonFolder : 'UseSeasonFolder',
|
|
AdvancedSettings : 'advancedSettings'
|
|
},
|
|
|
|
getValueBoolean: function (key, defaultValue) {
|
|
defaultValue = defaultValue || false;
|
|
|
|
return this.getValue(key, defaultValue.toString()) === 'true';
|
|
},
|
|
|
|
getValue: function (key, defaultValue) {
|
|
var storeValue = window.localStorage.getItem(key);
|
|
|
|
if (!storeValue) {
|
|
return defaultValue;
|
|
}
|
|
|
|
return storeValue.toString();
|
|
},
|
|
|
|
setValue: function (key, value) {
|
|
|
|
console.log('Config: [{0}] => [{1}] '.format(key, value));
|
|
|
|
if (this.getValue(key) === value.toString()) {
|
|
return;
|
|
}
|
|
|
|
window.localStorage.setItem(key, value);
|
|
vent.trigger(this.Events.ConfigUpdatedEvent, {key: key, value: value});
|
|
|
|
}
|
|
};
|
|
});
|