Overview
Context
Changes
Modified gc_lang/fr/webext/gce_worker.js
from [0e6bb7b841]
to [0220235f9e] .
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
-
-
-
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…");
gc_engine.load(sContext, sExtensionPath+"grammalecte/graphspell/_dictionaries");
oSpellChecker = gc_engine.getSpellChecker();
oTest = new TestGrammarChecking(gc_engine, sExtensionPath+"/grammalecte/fr/tests_data.json");
oTokenizer = new Tokenizer("fr");
oLocution = helpers.loadFile(sExtensionPath + "/grammalecte/fr/locutions_data.json");
oLxg = new Lexicographe(oSpellChecker, oTokenizer, oLocution);
if (dOptions !== null) {
console.log(dOptions);
gc_engine.setOptions(dOptions);
}
//tests();
bInitDone = true;
} else {
console.log("[Worker] Already initialized…")
}
Modified gc_lang/fr/webext/panel/main.js
from [82866d8fd8]
to [3a6b7ee35a] .
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
-
+
let {sActionDone, result, dInfo, bEnd, bError} = oMessage;
switch(sActionDone) {
case "textToTest":
case "fullTests":
showTestResult(result);
break;
case "resetOptions":
setGCOptions(result);
display GCOptions(result);
break;
default:
console.log("GRAMMALECTE. Unknown command: " + sActionDone);
}
//sendResponse({sCommand: "none", result: "done"});
}
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
-
+
-
+
// hide them all
for (let xNodePage of document.getElementsByClassName("page")) {
xNodePage.style.display = "none";
}
// show the selected one
document.getElementById(sPageName).style.display = "block";
if (sPageName == "gc_options_page") {
setGCOptionsFromStorage();
display GCOptionsLoaded FromStorage();
}
else if (sPageName == "ui_options_page") {
setUIOptionsFromStorage();
display UIOptionsLoaded FromStorage();
}
}
catch (e) {
showError(e);
}
}
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
-
+
-
+
-
+
-
+
}
/*
UI options
*/
function setUIOptionsFromStorage () {
function display UIOptionsLoaded FromStorage () {
if (bChrome) {
browser.storage.local.get("ui_options", setUIOptions);
browser.storage.local.get("ui_options", display UIOptions);
return;
}
let xPromise = browser.storage.local.get("ui_options");
xPromise.then(setUIOptions, showError);
xPromise.then(display UIOptions, showError);
}
function setUIOptions (dOptions) {
function display UIOptions (dOptions) {
if (!dOptions.hasOwnProperty("ui_options")) {
console.log("no ui options found");
return;
}
dOptions = dOptions.ui_options;
for (let sOpt in dOptions) {
if (document.getElementById("ui_option_"+sOpt)) {
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
-
+
-
+
-
+
-
+
-
+
-
+
-
+
}});
}
/*
GC options
*/
function setGCOptionsFromStorage () {
function display GCOptionsLoaded FromStorage () {
if (bChrome) {
browser.storage.local.get("gc_options", _setGCOptions);
browser.storage.local.get("gc_options", _display GCOptions);
return;
}
let xPromise = browser.storage.local.get("gc_options");
xPromise.then(_setGCOptions, showError);
xPromise.then(_display GCOptions, showError);
}
function _setGCOptions (dSavedOptions) {
function _display GCOptions (dSavedOptions) {
if (dSavedOptions.hasOwnProperty("gc_options")) {
setGCOptions(dSavedOptions.gc_options);
display GCOptions(dSavedOptions.gc_options);
}
}
function setGCOptions (dOptions) {
function display GCOptions (dOptions) {
try {
// dOptions is supposed to be a Map
if (bChrome) {
// JS crap again. Chrome can’t store/send Map object.
dOptions = helpers.objectToMap(dOptions);
}
for (let [sOpt, bVal] of dOptions) {
if (document.getElementById("option_"+sOpt)) {
document.getElementById("option_"+sOpt).checked = bVal;
}
}
}
catch (e) {
console.log(dOptions);
showError(e);
console.log(dOptions);
}
}