2013-06-22 06:24:24 +00:00
|
|
|
'use strict';
|
2013-06-21 01:43:58 +00:00
|
|
|
define(
|
|
|
|
[
|
|
|
|
'app'
|
2013-06-24 23:41:59 +00:00
|
|
|
], function (App) {
|
|
|
|
return {
|
2013-06-21 01:43:58 +00:00
|
|
|
Events: {
|
|
|
|
ConfigUpdatedEvent: 'ConfigUpdatedEvent'
|
|
|
|
},
|
|
|
|
Keys : {
|
2013-07-11 21:28:57 +00:00
|
|
|
DefaultQualityProfileId: 'DefaultQualityProfileId',
|
|
|
|
DefaultRootFolderId: 'DefaultRootFolderId'
|
2013-06-24 23:41:59 +00:00
|
|
|
},
|
2013-04-10 03:17:41 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
GetValue: function (key, defaultValue) {
|
2013-04-10 03:17:41 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
var storeValue = 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-06-24 23:41:59 +00:00
|
|
|
SetValue: function (key, value) {
|
2013-05-28 05:40:58 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
console.log('Config: [{0}] => [{1}] '.format(key, value));
|
2013-05-28 05:40:58 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
if (this.GetValue(key) === value.toString()) {
|
|
|
|
return;
|
|
|
|
}
|
2013-05-28 05:40:58 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
localStorage.setItem(key, value);
|
|
|
|
App.vent.trigger(this.Events.ConfigUpdatedEvent, {key: key, value: value});
|
2013-04-07 23:15:04 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
}
|
2013-06-21 01:43:58 +00:00
|
|
|
|
2013-06-24 23:41:59 +00:00
|
|
|
};
|
2013-06-21 01:43:58 +00:00
|
|
|
});
|