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