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