33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
Options = function (authorAccess, namespace) {
|
|
this.namespace = namespace;
|
|
this.authorAccess = authorAccess;
|
|
this.optionsStorage = this.authorAccess.getOptionsStorage();
|
|
}
|
|
|
|
Options.SYSTEM = '__system__';
|
|
|
|
Options.prototype.getOption = function (key, defaultValue) {
|
|
this.optionsStorage.setOptionsDoctypePrefix(this.namespace);
|
|
return this.optionsStorage.getOption(key, defaultValue);
|
|
}
|
|
|
|
Options.prototype.setOption = function (key, value) {
|
|
this.optionsStorage.setOptionsDoctypePrefix(Options.SYSTEM);
|
|
var options = JSON.parse(this.optionsStorage.getOption(this.namespace, '{}'));
|
|
options[key] = (new Date()).toISOString();
|
|
this.optionsStorage.setOption(this.namespace, JSON.stringify(options));
|
|
this.optionsStorage.setOptionsDoctypePrefix(this.namespace);
|
|
this.optionsStorage.setOption(key, value);
|
|
}
|
|
|
|
Options.prototype.getOptions = function (key) {
|
|
var results = {
|
|
};
|
|
this.optionsStorage.setOptionsDoctypePrefix(Options.SYSTEM);
|
|
var options = JSON.parse(this.optionsStorage.getOption(this.namespace, '{}'));
|
|
for (var key in options) {
|
|
results[key] = this.getOption(key, '');
|
|
}
|
|
return results;
|
|
}
|