Overview
Context
Changes
Modified gc_lang/fr/webext/background.js
from [e31347c2da]
to [c04d704430].
︙ | | |
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
|
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
|
-
-
-
-
|
xGCEWorker.onmessage = function (e) {
// https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent
try {
let {sActionDone, result, dInfo} = e.data;
switch (sActionDone) {
case "init":
console.log("INIT DONE");
break;
case "parse":
case "parseAndSpellcheck":
case "parseAndSpellcheck1":
case "getListOfTokens":
console.log("Action done: " + sActionDone);
if (typeof(dInfo.iReturnPort) === "number") {
let xPort = dConnx.get(dInfo.iReturnPort);
xPort.postMessage(e.data);
} else {
console.log("[background] don’t know where to send results");
console.log(e.data);
}
break;
case "textToTest":
console.log("TEXT TO TEXT RESULTS");
browser.runtime.sendMessage({sCommand: "text_to_test_result", sResult: result});
break;
case "fullTests":
console.log("FULL TESTS RESULTS");
browser.runtime.sendMessage({sCommand: "fulltests_result", sResult: result});
break;
case "getOptions":
case "getDefaultOptions":
case "setOptions":
case "setOption":
console.log("OPTIONS");
|
︙ | | |
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
-
-
|
/*
Messages from the extension (not the Worker)
*/
function handleMessage (oRequest, xSender, sendResponse) {
//console.log(xSender);
console.log("[background] received:");
console.log(oRequest);
switch (oRequest.sCommand) {
case "parse":
case "parseAndSpellcheck":
case "parseAndSpellcheck1":
case "getListOfTokens":
case "textToTest":
case "getOptions":
|
︙ | | |
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
-
-
-
-
|
}
browser.runtime.onMessage.addListener(handleMessage);
function handleConnexion (xPort) {
let iPortId = xPort.sender.tab.id; // identifier for the port: each port can be found at dConnx[iPortId]
console.log("tab_id: " + iPortId);
dConnx.set(iPortId, xPort);
xPort.onMessage.addListener(function (oRequest) {
console.log("[background] message via connexion:");
console.log(oRequest);
switch (oRequest.sCommand) {
case "parse":
case "parseAndSpellcheck":
case "parseAndSpellcheck1":
case "getListOfTokens":
oRequest.dInfo.iReturnPort = iPortId; // we pass the id of the return port to receive answer
console.log(oRequest);
xGCEWorker.postMessage(oRequest);
break;
default:
console.log("[background] Unknown command: " + oRequest.sCommand);
console.log(oRequest);
}
});
|
︙ | | |
Modified gc_lang/fr/webext/content_scripts/content_modifier.js
from [00d02be92c]
to [08d6a77f2d].
︙ | | |
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
-
+
|
let xConjButton = createNode("div", {className: "grammalecte_wrapper_button", textContent: "Conjuguer"});
xConjButton.onclick = function () {
this.createConjPanel();
//this.oConjPanel.show();
}.bind(this);
let xTFButton = createNode("div", {className: "grammalecte_wrapper_button", textContent: "Formater"});
xTFButton.onclick = function () {
this.createTFPanel(xTextArea);
this.createTFPanel();
this.oTFPanel.start(xTextArea);
this.oTFPanel.show();
}.bind(this);
let xLxgButton = createNode("div", {className: "grammalecte_wrapper_button", textContent: "Analyser"});
xLxgButton.onclick = function () {
this.createLxgPanel();
this.oLxgPanel.clear();
|
︙ | | |
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
-
-
+
|
}
catch (e) {
showError(e);
}
},
createConjPanel: function () {
console.log("Conjugueur");
if (this.oConjPanel === null) {
this.oConjPanel = new GrammalectePanel("grammalecte_conj_panel", "Conjugueur", 600, 600);
this.oConjPanel.insertIntoPage();
}
},
createTFPanel: function (xTextArea) {
createTFPanel: function () {
if (this.oTFPanel === null) {
this.oTFPanel = new GrammalecteTextFormatter("grammalecte_tf_panel", "Formateur de texte", 800, 620, false);
//this.oTFPanel.logInnerHTML();
this.oTFPanel.insertIntoPage();
}
},
|
︙ | | |
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
-
-
-
-
|
/*
Connexion to the background
*/
let xPort = browser.runtime.connect({name: "content-script port"});
xPort.onMessage.addListener(function (oMessage) {
console.log("[Content script] received…");
let {sActionDone, result, dInfo, bEnd, bError} = oMessage;
switch (sActionDone) {
case "parseAndSpellcheck":
console.log("[content script] received: parseAndSpellcheck");
if (!bEnd) {
oGrammalecte.oGCPanel.addParagraphResult(result);
} else {
oGrammalecte.oGCPanel.stopWaitIcon();
}
break;
case "parseAndSpellcheck1":
console.log("[content script] received: parseAndSpellcheck1");
oGrammalecte.oGCPanel.refreshParagraph(dInfo.sParagraphId, result);
break;
case "getListOfTokens":
console.log("[content script] received: getListOfTokens");
if (!bEnd) {
oGrammalecte.oLxgPanel.addListOfTokens(result);
} else {
oGrammalecte.oLxgPanel.stopWaitIcon();
}
break;
// Design WTF: context menus are made in background, not in content-script.
|
︙ | | |
Modified gc_lang/fr/webext/gce_worker.js
from [94cf928cb8]
to [1a2b4f786b].
︙ | | |
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
-
+
|
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
*/
"use strict";
console.log("[Worker] GC Engine Worker [start]");
//console.log("[Worker] GC Engine Worker [start]");
//console.log(self);
importScripts("grammalecte/helpers.js");
importScripts("grammalecte/str_transform.js");
importScripts("grammalecte/ibdawg.js");
importScripts("grammalecte/text.js");
importScripts("grammalecte/tokenizer.js");
|
︙ | | |
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
-
|
/*
Message Event Object
https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent
*/
onmessage = function (e) {
console.log("[Worker] message received");
let {sCommand, dParam, dInfo} = e.data;
switch (sCommand) {
case "init":
init(dParam.sExtensionPath, dParam.sOptions, dParam.sContext, dInfo);
break;
case "parse":
parse(dParam.sText, dParam.sCountry, dParam.bDebug, dParam.bContext, dInfo);
|
︙ | | |
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
-
+
-
+
|
That’s why the full text to analyze is send in one block, but analyse is returned paragraph
by paragraph.
*/
function init (sExtensionPath, sGCOptions="", sContext="JavaScript", dInfo={}) {
try {
if (!bInitDone) {
console.log("[Worker] Loading… Extension path: " + sExtensionPath);
//console.log("[Worker] Loading… Extension path: " + sExtensionPath);
conj.init(helpers.loadFile(sExtensionPath + "/grammalecte/fr/conj_data.json"));
phonet.init(helpers.loadFile(sExtensionPath + "/grammalecte/fr/phonet_data.json"));
mfsp.init(helpers.loadFile(sExtensionPath + "/grammalecte/fr/mfsp_data.json"));
console.log("[Worker] Modules have been initialized…");
//console.log("[Worker] Modules have been initialized…");
gc_engine.load(sContext, sExtensionPath+"grammalecte/_dictionaries");
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)));
}
|
︙ | | |