56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
+
+
+
+
+
+
+
+
|
/*
Message Event Object
https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent
*/
let xPort = null;
function showError (e) {
for (let sParam in e) {
console.log(sParam);
console.log(e[sParam]);
}
}
onconnect = function(e) {
console.log("START CONNECTION");
xPort = e.ports[0];
xPort.onmessage = function (e) {
console.log("[Sharedworker] ONMESSAGE");
console.log(e);
console.log(e.data[0]);
let oParam = e.data[1];
switch (e.data[0]) {
case "init":
loadGrammarChecker(oParam.sExtensionPath, oParam.sOptions, oParam.sContext);
break;
|
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
-
+
|
case "fullTests":
fullTests();
break;
case "getListOfTokens":
getListOfTokens(oParam.sText);
break;
default:
console.log("Unknown command: " + e.data[0]);
console.log("Unknown command: " + showError(e.data[0]));
}
}
//xPort.start();
}
let oDict = null;
|
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
-
+
|
oDict = gc_engine.getDictionary();
oTest = new TestGrammarChecking(gc_engine, sExtensionPath+"/grammalecte/fr/tests_data.json");
oLxg = new Lexicographe(oDict);
if (sGCOptions !== "") {
gc_engine.setOptions(helpers.objectToMap(JSON.parse(sGCOptions)));
}
oTokenizer = new Tokenizer("fr");
tests();
//tests();
// we always retrieve options from the gc_engine, for setOptions filters obsolete options
xPort.postMessage(["options", gc_engine.getOptions().gl_toString()]);
}
catch (e) {
console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
xPort.postMessage(["error", e.message]);
}
|