1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
-
+
|
// JavaScript
"use strict";
const Cc = Components.classes;
const Ci = Components.interfaces;
//const Cu = Components.utils;
//const { require } = Cu.import("resource://gre/modules/commonjs/toolkit/require.js", {});
const { BasePromiseWorker } = ChromeUtils.import('resource://gre/modules/PromiseWorker.jsm', {});
const prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).getBranch("extensions.grammarchecker.");
const xGrammalectePrefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).getBranch("extensions.grammarchecker.");
//const text = require("resource://grammalecte/text.js");
//const tf = require("resource://grammalecte/fr/textformatter.js");
const oConverterToExponent = {
dNumbers: new Map ([
|
︙ | | |
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
|
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
|
-
+
-
+
-
-
+
+
-
+
|
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"]);
let xPromise = this.xGCEWorker.post('loadGrammarChecker', [xGrammalectePrefs.getCharPref("sGCOptions"), "Thunderbird"]);
xPromise.then(
function (aVal) {
console.log(aVal);
prefs.setCharPref("sGCOptions", aVal);
xGrammalectePrefs.setCharPref("sGCOptions", aVal);
// spelling dictionary
if (prefs.getCharPref("sMainDicName")) {
let sMainDicName = prefs.getCharPref("sMainDicName");
if (xGrammalectePrefs.getCharPref("sMainDicName")) {
let sMainDicName = xGrammalectePrefs.getCharPref("sMainDicName");
if (sMainDicName == "fr-classic.json" || sMainDicName == "fr-reform.json") {
that.xGCEWorker.post("setDictionary", ["main", sMainDicName]);
}
}
// personal dictionary
if (prefs.getBoolPref("bPersonalDictionary")) {
if (xGrammalectePrefs.getBoolPref("bPersonalDictionary")) {
let sDicJSON = oFileHandler.loadFile("fr.personal.json");
if (sDicJSON) {
that.xGCEWorker.post('setDictionary', ["personal", sDicJSON]);
}
}
},
function (aReason) { console.log('Promise rejected - ', aReason); }
|
︙ | | |
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
120
121
122
123
124
125
|
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
120
121
122
123
124
125
|
-
+
-
+
-
+
|
function (aReason) { console.log('Promise rejected', aReason); }
).catch(
function (aCaught) { console.log('Promise Error', aCaught); }
);
},
setOptions: function () {
console.log('Set options');
let xPromise = this.xGCEWorker.post('setOptions', [prefs.getCharPref("sGCOptions")]);
let xPromise = this.xGCEWorker.post('setOptions', [xGrammalectePrefs.getCharPref("sGCOptions")]);
xPromise.then(
function (aVal) {
console.log(aVal);
prefs.setCharPref("sGCOptions", aVal);
xGrammalectePrefs.setCharPref("sGCOptions", aVal);
},
function (aReason) { console.log('Promise rejected', aReason); }
).catch(
function (aCaught) { console.log('Promise Error', aCaught); }
);
},
resetOptions: function () {
let xPromise = this.xGCEWorker.post('resetOptions');
xPromise.then(
function (aVal) {
console.log(aVal);
prefs.setCharPref("sGCOptions", aVal);
xGrammalectePrefs.setCharPref("sGCOptions", aVal);
},
function (aReason) { console.log('Promise rejected', aReason); }
).catch(
function (aCaught) { console.log('Promise Error', aCaught); }
);
},
parse: async function () {
|
︙ | | |
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
|
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
|
-
+
|
},
onOpenGCOptions: function (e) {
let that = this;
let xPromise = this.xGCEWorker.post('getDefaultOptions');
xPromise.then(
function (aVal) {
console.log(aVal);
prefs.setCharPref("sGCDefaultOptions", aVal);
xGrammalectePrefs.setCharPref("sGCDefaultOptions", aVal);
},
function (aReason) { console.log('Promise rejected', aReason); }
).catch(
function (aCaught) { console.log('Promise Error', aCaught); }
).then(
function () {
that.openDialog("chrome://grammarchecker/content/gc_options.xul", "", "chrome, dialog, modal, resizable=no");
|
︙ | | |
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
|
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
|
-
+
|
var oTextFormatter = {
init: function () {
try {
this.closePanel();
this.listen();
let sTFOptions = prefs.getCharPref("sTFOptions");
let sTFOptions = xGrammalectePrefs.getCharPref("sTFOptions");
if (sTFOptions !== "") {
this.setOptionsInPanel(JSON.parse(sTFOptions));
this.resetProgressBar();
} else {
this.reset();
}
}
|
︙ | | |
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
|
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
|
-
+
|
},
saveOptions: function () {
let oOptions = {};
for (let xNode of document.getElementsByClassName("option")) {
oOptions[xNode.id] = xNode.checked;
}
//console.log("save options: " + JSON.stringify(oOptions));
prefs.setCharPref("sTFOptions", JSON.stringify(oOptions));
xGrammalectePrefs.setCharPref("sTFOptions", JSON.stringify(oOptions));
},
setOptionsInPanel: function (oOptions) {
for (let sOptName in oOptions) {
//console.log(sOptName + ":" + oOptions[sOptName]);
if (document.getElementById(sOptName) !== null) {
document.getElementById(sOptName).checked = oOptions[sOptName];
if (sOptName.startsWith("o_group_")) {
|
︙ | | |