js-options: storing namespaces info
This commit is contained in:
parent
51ecfd78cd
commit
13be075795
|
@ -1,10 +1,21 @@
|
||||||
|
/*
|
||||||
|
* Main features
|
||||||
|
*/
|
||||||
|
|
||||||
Options = function (authorAccess, namespace) {
|
Options = function (authorAccess, namespace) {
|
||||||
this.namespace = namespace;
|
this.namespace = namespace;
|
||||||
this.authorAccess = authorAccess;
|
this.authorAccess = authorAccess;
|
||||||
this.optionsStorage = this.authorAccess.getOptionsStorage();
|
this.optionsStorage = this.authorAccess.getOptionsStorage();
|
||||||
|
if (namespace != Options.SYSTEM) {
|
||||||
|
var systemOptions = new Options(authorAccess, Options.SYSTEM);
|
||||||
|
var namespaces = JSON.parse(systemOptions.getOption(Options.NAMESPACES, '{}'));
|
||||||
|
namespaces[this.namespace] = (new Date()).toISOString();
|
||||||
|
systemOptions.setOption(Options.NAMESPACES, JSON.stringify(namespaces))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Options.SYSTEM = '__system__';
|
Options.SYSTEM = '__system__';
|
||||||
|
Options.NAMESPACES = '__namespaces__';
|
||||||
|
|
||||||
Options.prototype.getOption = function (key, defaultValue) {
|
Options.prototype.getOption = function (key, defaultValue) {
|
||||||
this.optionsStorage.setOptionsDoctypePrefix(this.namespace);
|
this.optionsStorage.setOptionsDoctypePrefix(this.namespace);
|
||||||
|
@ -20,7 +31,7 @@ Options.prototype.setOption = function (key, value) {
|
||||||
this.optionsStorage.setOption(key, value);
|
this.optionsStorage.setOption(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Options.prototype.getOptions = function (key) {
|
Options.prototype.getOptions = function () {
|
||||||
var results = {
|
var results = {
|
||||||
};
|
};
|
||||||
this.optionsStorage.setOptionsDoctypePrefix(Options.SYSTEM);
|
this.optionsStorage.setOptionsDoctypePrefix(Options.SYSTEM);
|
||||||
|
@ -30,3 +41,17 @@ Options.prototype.getOptions = function (key) {
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Per file extensions
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
Options.prototype.setSystemId = function(systemID) {
|
||||||
|
if (systemID === undefined) {
|
||||||
|
this.systemID = this.authorAccess.getDocumentController().getAuthorDocumentNode().getSystemID();
|
||||||
|
} else {
|
||||||
|
this.systemID = systemID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue