-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmain.js
More file actions
77 lines (67 loc) · 1.99 KB
/
main.js
File metadata and controls
77 lines (67 loc) · 1.99 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// main.js
let permanentModule2Load=[
"externalLoad",
"OEEMenu", // add the OEE Menu in the top right corner
"surveyMessage"
];
let moules2Load = [
"aiCodeGeneration",
"copyAsJson",
"darkMode",
"editorSettings",
"openInNewTab",
"plotly",
"sharedCodeSession",
"uploadWithManifest"
];
// Load all permanent modules
for (let i = 0; i < permanentModule2Load.length; i++) {
const moduleName = permanentModule2Load[i];
import('./modules/' + moduleName + '.js')
.then(module => {
if (module.initialize) {
module.initialize();
//console.log(moduleName)
}
})
.catch(err => {
console.error('Error loading ' + moduleName + ':', err);
});
}
// Load all relevant settings from storage
chrome.storage.local.get(moules2Load, function(items) {
for (let i = 0; i < moules2Load.length; i++) {
const moduleName = moules2Load[i];
// Check if the module is enabled (i.e., true) before loading
if (items[moduleName]) { // temporarly force all
import('./modules/' + moduleName + '.js')
.then(module => {
if (module.initialize) {
module.initialize();
//console.log(moduleName)
}
})
.catch(err => {
console.error('Error loading ' + moduleName + ':', err);
});
}
}
});
/*************** MT part **************************/
let moulesMT2Load = [
"aiCodeGeneration",
"consoleError",
"darkMode",
"docLink",
"editorSettings",
"insertFucntionSignature",
"plotly",
"pythonCE",
"runAll",
"sharedCodeSession",
"terminal",
"uploadWithManifest"
];
chrome.storage.local.get(moulesMT2Load, function(items) {
window.dispatchEvent(new CustomEvent("moduleMT2Load",{detail:{modules:items, extensionId:chrome.runtime.id}}))
});