Выгрузить модули
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* NOTE Only ASCII is allowed in this loading module
|
||||
* NOTE because it's deciphered with btoa() call,
|
||||
* NOTE which can't handle Unicode.
|
||||
* NOTE However, murom.atob/btoa functions (defined here)
|
||||
* NOTE work fine with Unicode, so you are free
|
||||
* NOTE to use Unicode in other modules
|
||||
*/
|
||||
|
||||
murom.installLocalForage = function()
|
||||
{
|
||||
/*
|
||||
@@ -36,10 +45,27 @@ function TextEncoderLite(){}function TextDecoderLite(){}(function(){"use strict"
|
||||
};
|
||||
};
|
||||
|
||||
murom.moduleProperties = function(id)
|
||||
{
|
||||
var m = murom.modules[id];
|
||||
return (typeof m[2] != "undefined") ? m[2] : {};
|
||||
};
|
||||
|
||||
murom.moduleStatus = function(id)
|
||||
{
|
||||
var prop = murom.moduleProperties(id);
|
||||
if ("status" in prop)
|
||||
{
|
||||
return prop["status"];
|
||||
}
|
||||
// Status == true if explicit record is absent.
|
||||
return true;
|
||||
};
|
||||
|
||||
murom.start = function()
|
||||
{
|
||||
console.log("Override 'murom.start()' in any of the modules to be notified when all modules are loaded");
|
||||
};
|
||||
console.debug("Override murom.start() function to be notified when all modules were loaded");
|
||||
}
|
||||
|
||||
murom.loadModules = function()
|
||||
{
|
||||
@@ -49,10 +75,9 @@ murom.loadModules = function()
|
||||
var module = murom.modules[i];
|
||||
var name = module[0];
|
||||
var code = murom.atob(module[1]);
|
||||
var state = module[2];
|
||||
if (state == false)
|
||||
if (murom.moduleStatus(i) == false)
|
||||
{
|
||||
console.log("WARNING Skip loading '" + name + "' module because it's turned off");
|
||||
console.warn("Skip loading '" + name + "' module because it's turned off");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -62,7 +87,7 @@ murom.loadModules = function()
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
console.log("ERROR Could not load '" + name + "' module: '" + e + "'");
|
||||
console.error("Could not load '" + name + "' module: '" + e + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -79,11 +104,11 @@ murom.loadIndexedDBModules = function(completionHandler)
|
||||
if (modules)
|
||||
{
|
||||
murom.modules = modules;
|
||||
console.log("Modules have been loaded from IndexedDB");
|
||||
console.debug("Modules have been loaded from IndexedDB");
|
||||
}
|
||||
if (error)
|
||||
{
|
||||
console.log("ERROR Getting modules from IndexedDB: '" + error + "'");
|
||||
console.error("Could not get modules from IndexedDB: '" + error + "'");
|
||||
}
|
||||
// Continue.
|
||||
completionHandler();
|
||||
|
||||
Reference in New Issue
Block a user