2013-06-22 06:24:24 +00:00
|
|
|
'use strict';
|
2013-06-21 01:43:58 +00:00
|
|
|
define(
|
|
|
|
[
|
2013-10-09 01:43:41 +00:00
|
|
|
'vent'
|
|
|
|
], function (vent) {
|
2013-06-24 23:41:59 +00:00
|
|
|
return {
|
2013-06-21 01:43:58 +00:00
|
|
|
Events: {
|
|
|
|
ConfigUpdatedEvent: 'ConfigUpdatedEvent'
|
|
|
|
},
|
|
|
|
Keys : {
|
2014-06-08 08:22:55 +00:00
|
|
|
DefaultProfileId : 'DefaultProfileId',
|
2014-07-10 05:59:23 +00:00
|
|
|
DefaultRootFolderId : 'DefaultRootFolderId',
|
|
|
|
UseSeasonFolder : 'UseSeasonFolder',
|
|
|
|
DefaultSeriesType : 'DefaultSeriesType',
|
|
|
|
AdvancedSettings : 'advancedSettings'
|
2013-06-24 23:41:59 +00:00
|
|
|
},
|
2013-04-10 03:17:41 +00:00
|
|
|
|
2013-09-25 04:51:44 +00:00
|
|
|
getValueBoolean: function (key, defaultValue) {
|
2013-11-30 21:23:03 +00:00
|
|
|
defaultValue = defaultValue || false;
|
|
|
|
|
2013-11-30 20:17:01 +00:00
|
|
|
return this.getValue(key, defaultValue.toString()) === 'true';
|
2013-09-25 04:51:44 +00:00
|
|
|
},
|
|
|
|
|
2013-08-04 01:27:12 +00:00
|
|
|
getValue: function (key, defaultValue) {
|
2013-11-11 04:09:11 +00:00
|
|
|
var storeValue = window.localStorage.getItem(key);
|
2013-04-07 23:15:04 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
if (!storeValue) {
|
|
|
|
return defaultValue;
|
|
|
|
}
|
2013-04-07 23:15:04 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
return storeValue.toString();
|
|
|
|
},
|
2013-05-28 05:40:58 +00:00
|
|
|
|
2013-08-04 01:27:12 +00:00
|
|
|
setValue: function (key, value) {
|
2013-05-28 05:40:58 +00:00
|
|
|
|
2014-07-07 04:56:57 +00:00
|
|
|
console.log('Config: [{0}] => [{1}]'.format(key, value));
|
2013-05-28 05:40:58 +00:00
|
|
|
|
2013-08-04 01:27:12 +00:00
|
|
|
if (this.getValue(key) === value.toString()) {
|
2013-06-24 23:41:59 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-05-28 05:40:58 +00:00
|
|
|
|
2014-07-07 04:56:57 +00:00
|
|
|
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));
|
|
|
|
}
|
2013-06-24 23:41:59 +00:00
|
|
|
}
|
|
|
|
};
|
2013-06-21 01:43:58 +00:00
|
|
|
});
|