-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomponent_loader.js
More file actions
52 lines (41 loc) · 1.33 KB
/
Copy pathcomponent_loader.js
File metadata and controls
52 lines (41 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
window.ToolsLoaderComponent = {
props: {
tool: { type: String, default: "TOOL0" },
},
template: ``
};
window.ModuleLoaderComponent = {
props: {
modfilter: { type: String, default: "" },
},
template: ``
};
async function ucnc_component_loader() {
for (let tool of window.app_vars.app_options.TOOL_OPTIONS) {
try {
const response = await fetch(`./tools/${tool.id}.js`);
if (!response.ok) throw new Error(`Failed to fetch ${tool.id}.js`);
const scriptContent = await response.text();
new Function(scriptContent)();
} catch (error) {
console.error(`Error loading ${tool.id}.js:`, error.message);
}
}
for (let module of window.app_vars.app_options.MODULES_OPTIONS) {
try {
const response = await fetch(`./modules/${module.id}.js`);
if (!response.ok) throw new Error(`Failed to fetch ${module.id}.js`);
const scriptContent = await response.text();
new Function(scriptContent)();
} catch (error) {
console.error(`Error loading ${module.id}.js:`, error.message);
}
}
window.addEventListener("ucnc_load_components", (e) => {
window.ucnc_app.component('toolsloader', window.ToolsLoaderComponent);
});
window.addEventListener("ucnc_load_components", (e) => {
window.ucnc_app.component('modulesloader', window.ModuleLoaderComponent);
});
window.dispatchEvent(new Event("ucnc_components_loaded"));
}