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
|
}
};
var oGrammarChecker = {
// you must use var to be able to call this object from elsewhere
xGCEWorker: null,
bDictActive: null,
loadGC: function () {
if (this.xGCEWorker === null) {
// Grammar checker
console.log('Loading Grammalecte');
this.xGCEWorker = new BasePromiseWorker('chrome://promiseworker/content/gce_worker.js');
let xPromise = this.xGCEWorker.post('loadGrammarChecker', [prefs.getCharPref("sGCOptions"), "Thunderbird"]);
xPromise.then(
function (aVal) {
console.log(aVal);
prefs.setCharPref("sGCOptions", aVal);
},
function (aReason) { console.log('Promise rejected - ', aReason); }
).catch(
function (aCaught) { console.log('Promise Error - ', aCaught); }
);
}
},
fullTests: function () {
console.log('Performing tests... Wait...');
let xPromise = this.xGCEWorker.post('fullTests', ['{"nbsp":true, "esp":true, "unit":true, "num":true}']);
xPromise.then(
function (aVal) {
|
<
>
>
>
>
>
>
>
>
|
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
|
}
};
var oGrammarChecker = {
// you must use var to be able to call this object from elsewhere
xGCEWorker: null,
loadGC: function () {
if (this.xGCEWorker === null) {
// Grammar checker
console.log('Loading Grammalecte');
this.xGCEWorker = new BasePromiseWorker('chrome://promiseworker/content/gce_worker.js');
let that = this;
let xPromise = this.xGCEWorker.post('loadGrammarChecker', [prefs.getCharPref("sGCOptions"), "Thunderbird"]);
xPromise.then(
function (aVal) {
console.log(aVal);
prefs.setCharPref("sGCOptions", aVal);
if (prefs.getBoolPref("bPersonalDictionary")) {
let sDicJSON = oFileHandler.loadFile("fr.personal.json");
if (sDicJSON) {
that.xGCEWorker.post('setDictionary', ["personal", sDicJSON]);
}
}
},
function (aReason) { console.log('Promise rejected - ', aReason); }
).catch(
function (aCaught) { console.log('Promise Error - ', aCaught); }
);
}
},
fullTests: function () {
console.log('Performing tests... Wait...');
let xPromise = this.xGCEWorker.post('fullTests', ['{"nbsp":true, "esp":true, "unit":true, "num":true}']);
xPromise.then(
function (aVal) {
|
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
|
xNodeDiv.appendChild(xNodeMessage);
// suggestions
let xNodeSuggLine = document.createElement("p");
xNodeSuggLine.setAttribute("class", "suggestions");
let xNodeSuggButton = document.createElement("span");
xNodeSuggButton.setAttribute("class", "suggestions_button");
xNodeSuggButton.textContent = "Suggestions : ";
xNodeSuggButton.addEventListener("click", function (e) {
if (this.bDictActive === null) {
this.bDictActive = oSpellControl.setDictionary("fr");
}
try {
let aSugg = oSpellControl.suggest(dErr['sValue']);
if (aSugg) {
let n = 0;
for (let sSugg of aSugg) {
if (true || n > 0) {
xNodeSuggLine.appendChild(document.createTextNode(" "));
}
let xNodeSugg = document.createElement("span");
xNodeSugg.setAttribute("class", "sugg");
xNodeSugg.textContent = sSugg;
xNodeSugg.addEventListener("click", function (e) {
xEditor.changeParagraph(iParagraph, xNodeSugg.textContent, dErr["nStart"], dErr["nEnd"]);
xNodeDiv.textContent = "";
that.reparseParagraph(xEditor, iParagraph);
});
xNodeSuggLine.appendChild(xNodeSugg);
n += 1;
}
} else {
xNodeSuggLine.appendChild(document.createTextNode("Aucune suggestion."));
}
}
catch (e) {
xNodeSuggLine.appendChild(document.createTextNode("# Erreur : dictionnaire orthographique introuvable."));
console.error(e);
// Cu.reportError(e);
}
});
xNodeSuggLine.appendChild(xNodeSuggButton);
xNodeDiv.appendChild(xNodeSuggLine);
return xNodeDiv;
},
loadUI: function() {
console.log("loadUI");
|
|
|
<
<
|
|
|
>
|
|
<
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
|
<
|
|
<
|
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
|
xNodeDiv.appendChild(xNodeMessage);
// suggestions
let xNodeSuggLine = document.createElement("p");
xNodeSuggLine.setAttribute("class", "suggestions");
let xNodeSuggButton = document.createElement("span");
xNodeSuggButton.setAttribute("class", "suggestions_button");
xNodeSuggButton.textContent = "Suggestions : ";
xNodeSuggButton.addEventListener("click", (e) => {
let xPromise = this.xGCEWorker.post('suggest', [dErr['sValue'], 10]);
xPromise.then(
function (sVal) {
if (sVal != "") {
let lSugg = sVal.split("|");
let n = 0;
for (let sSugg of lSugg) {
xNodeSuggLine.appendChild(document.createTextNode(" "));
let xNodeSugg = document.createElement("span");
xNodeSugg.setAttribute("class", "sugg");
xNodeSugg.textContent = sSugg;
xNodeSugg.addEventListener("click", function (e) {
xEditor.changeParagraph(iParagraph, xNodeSugg.textContent, dErr["nStart"], dErr["nEnd"]);
xNodeDiv.textContent = "";
that.reparseParagraph(xEditor, iParagraph);
});
xNodeSuggLine.appendChild(xNodeSugg);
n += 1;
}
} else {
xNodeSuggLine.appendChild(document.createTextNode("Aucune suggestion."));
}
},
function (aReason) { console.error('Promise rejected - ', aReason); }
).catch(
function (aCaught) { console.error('Promise Error - ', aCaught); }
);
});
xNodeSuggLine.appendChild(xNodeSuggButton);
xNodeDiv.appendChild(xNodeSuggLine);
return xNodeDiv;
},
loadUI: function() {
console.log("loadUI");
|
498
499
500
501
502
503
504
505
506
507
508
509
510
511
|
},
onOpenTextFormatter: function (e) {
oTextFormatter.openPanel();
},
onOpenConjugueur: function (e) {
this.openDialog("chrome://grammarchecker/content/conjugueur.xul", "", "chrome, resizable=no");
},
onAbout: function (e) {
this.openDialog("chrome://grammarchecker/content/about.xul", "", "chrome, dialog, modal, resizable=no");
}
};
var oDictIgniter = {
|
>
>
>
|
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
|
},
onOpenTextFormatter: function (e) {
oTextFormatter.openPanel();
},
onOpenConjugueur: function (e) {
this.openDialog("chrome://grammarchecker/content/conjugueur.xul", "", "chrome, resizable=no");
},
onOpenLexiconEditor: function (e) {
this.openDialog("chrome://grammarchecker/content/lex_editor.xul", "", "chrome, resizable=no");
},
onAbout: function (e) {
this.openDialog("chrome://grammarchecker/content/about.xul", "", "chrome, dialog, modal, resizable=no");
}
};
var oDictIgniter = {
|