js-options: storing namespaces info

This commit is contained in:
Eric van der Vlist 2021-04-29 10:12:58 +02:00
parent 51ecfd78cd
commit 13be075795
1 changed files with 26 additions and 1 deletions

View File

@ -1,10 +1,21 @@
/*
* Main features
*/
Options = function (authorAccess, namespace) {
this.namespace = namespace;
this.authorAccess = authorAccess;
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.NAMESPACES = '__namespaces__';
Options.prototype.getOption = function (key, defaultValue) {
this.optionsStorage.setOptionsDoctypePrefix(this.namespace);
@ -20,7 +31,7 @@ Options.prototype.setOption = function (key, value) {
this.optionsStorage.setOption(key, value);
}
Options.prototype.getOptions = function (key) {
Options.prototype.getOptions = function () {
var results = {
};
this.optionsStorage.setOptionsDoctypePrefix(Options.SYSTEM);
@ -30,3 +41,17 @@ Options.prototype.getOptions = function (key) {
}
return results;
}
/*
* Per file extensions
*
*/
Options.prototype.setSystemId = function(systemID) {
if (systemID === undefined) {
this.systemID = this.authorAccess.getDocumentController().getAuthorDocumentNode().getSystemID();
} else {
this.systemID = systemID;
}
}