DataTools3/controllers/module-controller.js

25 lines
606 B
JavaScript

class ModuleController {
static STATUS_UNLOADED = 0;
static STATUS_LOADING = 1;
static STATUS_LOADED = 2;
static MODULES = {
"md5": { file: "md5.js", status: this.STATUS_UNLOADED },
"sha256": { file: "sha256.js", status: this.STATUS_UNLOADED },
};
static loadModule(module) {
if (module.status == this.STATUS_UNLOADED) {
module.status = this.STATUS_LOADING;
let script = document.createElement("script");
script.src = "modules/" + module.file;
document.body.appendChild(script);
script.addEventListener("load", () => {
module.status = this.STATUS_LOADED;
});
}
}
}