sonarr-repo-only/UI/Config.js

44 lines
1.1 KiB
JavaScript
Raw Normal View History

2013-06-22 06:24:24 +00:00
'use strict';
2013-06-21 01:43:58 +00:00
define(
[
'app'
], function (App) {
return {
2013-06-21 01:43:58 +00:00
Events: {
ConfigUpdatedEvent: 'ConfigUpdatedEvent'
},
Keys : {
DefaultQualityProfileId: 'DefaultQualityProfileId',
DefaultRootFolderId: 'DefaultRootFolderId'
},
2013-09-25 04:51:44 +00:00
getValueBoolean: function (key, defaultValue) {
return this.getValue(key, defaultValue) === 'true';
},
2013-08-04 01:27:12 +00:00
getValue: function (key, defaultValue) {
var storeValue = localStorage.getItem(key);
if (!storeValue) {
return defaultValue;
}
return storeValue.toString();
},
2013-08-04 01:27:12 +00:00
setValue: function (key, value) {
console.log('Config: [{0}] => [{1}] '.format(key, value));
2013-08-04 01:27:12 +00:00
if (this.getValue(key) === value.toString()) {
return;
}
localStorage.setItem(key, value);
App.vent.trigger(this.Events.ConfigUpdatedEvent, {key: key, value: value});
}
};
2013-06-21 01:43:58 +00:00
});