Grammalecte  Changes On Branch 53f7b50983e4a12b

Changes In Branch mailext Through [53f7b50983] Excluding Merge-Ins

This is equivalent to a diff from 3d30d02ecf to 53f7b50983

2020-07-09
14:56
[tb][fx] editor & text formatter: update for MailExtension check-in: 4553dac0b4 user: olr tags: tb, fx, mailext
13:07
[tb][fx] adapt conjugueur to MailExtension -> no input allowed in compose scripts check-in: 53f7b50983 user: olr tags: tb, fx, mailext
2020-07-08
17:26
[tb][fx] adjustement for Mail Extension: no event for input -> no autorefresh check-in: 081fa7f8ca user: olr tags: tb, fx, mailext
2020-07-04
10:23
[fr] conf: tandis que, + phonet_simil: tandis / tendis / tendit check-in: ee8c478284 user: olr tags: trunk, fr
2020-07-02
12:23
[tb] MailExtension for Thunderbird 78 check-in: 4c21586958 user: olr tags: tb, mailext
09:04
[fr] faux positif et ajustements check-in: 3d30d02ecf user: olr tags: trunk, fr
2020-07-01
06:17
[fr] ajustements check-in: f4c70b8022 user: olr tags: trunk, fr

Modified gc_lang/fr/build.py from [43a9cad18e] to [78914808d1].

9
10
11
12
13
14
15

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from distutils import dir_util, file_util

import helpers


def build (sLang, dVars):
    "complementary build launched from make.py"

    createWebExtension(sLang, dVars)
    convertWebExtensionForChrome(sLang, dVars)
    createMailExtension(sLang, dVars)
    createNodeJSPackage(sLang)


def createWebExtension (sLang, dVars):
    "create Web-extension"
    print("> Building WebExtension for Firefox")
    helpers.createCleanFolder("_build/webext/"+sLang)
    dir_util.copy_tree("gc_lang/"+sLang+"/webext/", "_build/webext/"+sLang)
    dir_util.copy_tree("grammalecte-js", "_build/webext/"+sLang+"/grammalecte")
    dVars['webextOptionsHTML'] = _createOptionsForWebExtension(dVars)
    helpers.copyAndFileTemplate("_build/webext/"+sLang+"/manifest.json", "_build/webext/"+sLang+"/manifest.json", dVars)
    helpers.copyAndFileTemplate("_build/webext/"+sLang+"/panel/main.html", "_build/webext/"+sLang+"/panel/main.html", dVars)
    with helpers.CD("_build/webext/"+sLang):
        os.system("web-ext build")
    # Copy Firefox zip extension to _build
    helpers.moveFolderContent("_build/webext/"+sLang+"/web-ext-artifacts", "_build", "firefox-", True)








>












<







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

29
30
31
32
33
34
35
from distutils import dir_util, file_util

import helpers


def build (sLang, dVars):
    "complementary build launched from make.py"
    dVars['webextOptionsHTML'] = _createOptionsForWebExtension(dVars)
    createWebExtension(sLang, dVars)
    convertWebExtensionForChrome(sLang, dVars)
    createMailExtension(sLang, dVars)
    createNodeJSPackage(sLang)


def createWebExtension (sLang, dVars):
    "create Web-extension"
    print("> Building WebExtension for Firefox")
    helpers.createCleanFolder("_build/webext/"+sLang)
    dir_util.copy_tree("gc_lang/"+sLang+"/webext/", "_build/webext/"+sLang)
    dir_util.copy_tree("grammalecte-js", "_build/webext/"+sLang+"/grammalecte")

    helpers.copyAndFileTemplate("_build/webext/"+sLang+"/manifest.json", "_build/webext/"+sLang+"/manifest.json", dVars)
    helpers.copyAndFileTemplate("_build/webext/"+sLang+"/panel/main.html", "_build/webext/"+sLang+"/panel/main.html", dVars)
    with helpers.CD("_build/webext/"+sLang):
        os.system("web-ext build")
    # Copy Firefox zip extension to _build
    helpers.moveFolderContent("_build/webext/"+sLang+"/web-ext-artifacts", "_build", "firefox-", True)

68
69
70
71
72
73
74
75


76





77



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
    "create extension for Thunderbird (as MailExtension)"
    print("> Building extension for Thunderbird (MailExtension)")
    spfZip = "_build/" + dVars['tb_identifier'] + "-v" + dVars['version'] + '.mailext.xpi'
    hZip = zipfile.ZipFile(spfZip, mode='w', compression=zipfile.ZIP_DEFLATED)
    _copyGrammalecteJSPackageInZipFile(hZip, sLang)
    for spf in ["LICENSE.txt", "LICENSE.fr.txt"]:
        hZip.write(spf)
    dVars = _createOptionsForThunderbird(dVars)


    helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/mailext", "", dVars, True)





    hZip.close()



    #spExtension = dVars['win_tb_debug_extension_path']  if platform.system() == "Windows"  else dVars['linux_tb_debug_extension_path']
    #if os.path.isdir(spExtension):
    #    file_util.copy_file(spfZip, spExtension + "/" + dVars['tb_identifier']+ ".xpi")  # Filename for TB is just <identifier.xpi>
    #    print(f"TB extension copied in <{spExtension}>")
    #spExtension = dVars['win_tb_beta_extension_path']  if platform.system() == "Windows"  else dVars['linux_tb_beta_extension_path']
    #if os.path.isdir(spExtension):
    #    print(f"TB extension copied in <{spExtension}>")
    #    file_util.copy_file(spfZip, spExtension + "/" + dVars['tb_identifier']+ ".xpi")  # Filename for TB is just <identifier.xpi>


def _createOptionsForThunderbird (dVars):
    dVars['sXULTabs'] = ""
    dVars['sXULTabPanels'] = ""
    # dialog options
    for sSection, lOpt in dVars['lStructOpt']:
        dVars['sXULTabs'] += '    <tab label="&option.label.'+sSection+';"/>\n'
        dVars['sXULTabPanels'] += '    <tabpanel orient="vertical">\n      <label class="section" value="&option.label.'+sSection+';" />\n'
        for lLineOpt in lOpt:
            for sOpt in lLineOpt:
                dVars['sXULTabPanels'] += '      <checkbox id="option_'+sOpt+'" class="option" label="&option.label.'+sOpt+';" />\n'
        dVars['sXULTabPanels'] += '    </tabpanel>\n'
    # translation data
    for sLang in dVars['dOptLabel'].keys():
        dVars['gc_options_labels_'+sLang] = "\n".join( [ "<!ENTITY option.label." + sOpt + ' "' + dVars['dOptLabel'][sLang][sOpt][0] + '">'  for sOpt in dVars['dOptLabel'][sLang] ] )
    return dVars


def _copyGrammalecteJSPackageInZipFile (hZip, sLang, sAddPath=""):
    for sf in os.listdir("grammalecte-js"):
        if not os.path.isdir("grammalecte-js/"+sf):
            hZip.write("grammalecte-js/"+sf, sAddPath+"grammalecte/"+sf)
    for sf in os.listdir("grammalecte-js/graphspell"):







|
>
>
|
>
>
>
>
>

>
>
>
|
|
|
|
|
|
<
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

94
95
















96
97
98
99
100
101
102
    "create extension for Thunderbird (as MailExtension)"
    print("> Building extension for Thunderbird (MailExtension)")
    spfZip = "_build/" + dVars['tb_identifier'] + "-v" + dVars['version'] + '.mailext.xpi'
    hZip = zipfile.ZipFile(spfZip, mode='w', compression=zipfile.ZIP_DEFLATED)
    _copyGrammalecteJSPackageInZipFile(hZip, sLang)
    for spf in ["LICENSE.txt", "LICENSE.fr.txt"]:
        hZip.write(spf)
    helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/mailext", "", dVars, True)
    helpers.addFileToZipAndFileFile(hZip, "gc_lang/"+sLang+"/webext/gce_worker.js", "gce_worker.js", dVars)
    helpers.addFileToZipAndFileFile(hZip, "gc_lang/"+sLang+"/webext/README.md", "README.md", dVars)
    helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/webext/3rd", "3rd", dVars, True)
    helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/webext/_locales", "_locales", dVars, True)
    helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/webext/content_scripts", "content_scripts", dVars, True)
    helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/webext/fonts", "fonts", dVars, True)
    helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/webext/img", "img", dVars, True)
    helpers.addFolderToZipAndFileFile(hZip, "gc_lang/"+sLang+"/webext/panel", "panel", dVars, True)
    hZip.close()
    # Note about copying Thunderbird extension directly into the profile:
    # In Options > Configuration editor (about:config), deactivate option <xpinstall.whitelist.required>
    # If <manifest.json> is changed, you must reinstall the extension manually
    spExtension = dVars['win_tb_debug_extension_path']  if platform.system() == "Windows"  else dVars['linux_tb_debug_extension_path']
    if os.path.isdir(spExtension):
        file_util.copy_file(spfZip, f"{spExtension}/{dVars['tb_identifier']}.xpi")  # Filename for TB is just <identifier.xpi>
        print(f"Thunderbird extension copied in <{spExtension}>")
    spExtension = dVars['win_tb_beta_extension_path']  if platform.system() == "Windows"  else dVars['linux_tb_beta_extension_path']
    if os.path.isdir(spExtension):

        file_util.copy_file(spfZip, f"{spExtension}/{dVars['tb_identifier']}.xpi")  # Filename for TB is just <identifier.xpi>
        print(f"Thunderbird extension copied in <{spExtension}>")


















def _copyGrammalecteJSPackageInZipFile (hZip, sLang, sAddPath=""):
    for sf in os.listdir("grammalecte-js"):
        if not os.path.isdir("grammalecte-js/"+sf):
            hZip.write("grammalecte-js/"+sf, sAddPath+"grammalecte/"+sf)
    for sf in os.listdir("grammalecte-js/graphspell"):

Modified gc_lang/fr/config.ini from [8f917f78e2] to [c9564324d8].

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Thunderbird
tb_identifier = French-GC-TB@grammalecte.net
tb_name = Grammalecte [fr]
win_tb_path = C:\Program Files\Mozilla Thunderbird\thunderbird.exe
win_tb_beta_path = C:\Program Files\Thunderbird Daily\thunderbird.exe
linux_tb_path = /usr/bin/thunderbird
linux_tb_beta_path = /usr/bin/thunderbird
# useless now
win_tb_debug_extension_path = D:\_temp\tb-debug.profile\extensions
linux_tb_debug_extension_path = ~/tb-debug.profile/extensions
win_tb_beta_extension_path = D:\_temp\tb-beta.profile\extensions
linux_tb_beta_extension_path = ~/tb-beta.profile/extensions
# Set Thunderbird folder in your PATH variable
# Create a local profile:
#     	thunderbird -CreateProfile "debug _build\tb-debug.profile"







<







55
56
57
58
59
60
61

62
63
64
65
66
67
68
# Thunderbird
tb_identifier = French-GC-TB@grammalecte.net
tb_name = Grammalecte [fr]
win_tb_path = C:\Program Files\Mozilla Thunderbird\thunderbird.exe
win_tb_beta_path = C:\Program Files\Thunderbird Daily\thunderbird.exe
linux_tb_path = /usr/bin/thunderbird
linux_tb_beta_path = /usr/bin/thunderbird

win_tb_debug_extension_path = D:\_temp\tb-debug.profile\extensions
linux_tb_debug_extension_path = ~/tb-debug.profile/extensions
win_tb_beta_extension_path = D:\_temp\tb-beta.profile\extensions
linux_tb_beta_extension_path = ~/tb-beta.profile/extensions
# Set Thunderbird folder in your PATH variable
# Create a local profile:
#     	thunderbird -CreateProfile "debug _build\tb-debug.profile"

Deleted gc_lang/fr/mailext/README.txt version [e831050871].

1
2
3
4
5
6
7
8
9
10
11
12
13
14

= GRAMMALECTE =

French grammar checker
By Olivier R. (olivier /at/ grammalecte /dot/ net)

Website: https://grammalecte.net/

License: GPL 3 -- http://www.gnu.org/copyleft/gpl.html

Grammalecte for Firefox is a derivative tool born from the version
for LibreOffice written in Python.

Written in JavaScript ES6/ES7.
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























Modified gc_lang/fr/mailext/background.js from [84cc5ca0a0] to [2a80afd42c].

1
2




3
4
5















6
7
8
9
10
11
12
// Background





"use strict";

// Draft for later
















const oWorkerHandler = {
    xGCEWorker: null,

    nLastTimeWorkerResponse: 0,  // milliseconds since 1970-01-01

    oTask: {},


>
>
>
>


|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Background

/* jshint esversion:6, -W097 */
/* jslint esversion:6 */
/* global helpers, showError, Worker, chrome, console */

"use strict";


console.log("[Grammalecte] background");


// Chrome don’t follow the W3C specification:
// https://browserext.github.io/browserext/
let bChrome = false;
let bThunderbird = false;
if (typeof(browser) !== "object") {
    var browser = chrome;
    bChrome = true;
}
if (typeof(messenger) === "object") {
    bThunderbird = true;
}


const oWorkerHandler = {
    xGCEWorker: null,

    nLastTimeWorkerResponse: 0,  // milliseconds since 1970-01-01

    oTask: {},
105
106
107
108
109
110
111





112
113
114
115
116









117

118
119

120
121




























122
123
124
125
126
127
128
    }
}


const oInitHandler = {

    initUIOptions: function () {





        browser.storage.local.get("ui_options").then(this._initUIOptions, showError);
        browser.storage.local.get("autorefresh_option").then(this._initUIOptions, showError);
    },

    initGrammarChecker: function () {









        browser.storage.local.get("gc_options").then(this._initGrammarChecker, showError);

        browser.storage.local.get("personal_dictionary").then(this._setSpellingDictionaries, showError);
        browser.storage.local.get("community_dictionary").then(this._setSpellingDictionaries, showError);

        browser.storage.local.get("sc_options").then(this._initSCOptions, showError);
    },





























    _initUIOptions: function (oSavedOptions) {
        if (!oSavedOptions.hasOwnProperty("ui_options")) {
            browser.storage.local.set({"ui_options": {
                textarea: true,
                editablenode: true
            }});







>
>
>
>
>





>
>
>
>
>
>
>
>
>

>


>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







124
125
126
127
128
129
130
131
132
133
134
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
    }
}


const oInitHandler = {

    initUIOptions: function () {
        if (bChrome) {
            browser.storage.local.get("ui_options", this._initUIOptions);
            browser.storage.local.get("autorefresh_option", this._initUIOptions);
            return;
        }
        browser.storage.local.get("ui_options").then(this._initUIOptions, showError);
        browser.storage.local.get("autorefresh_option").then(this._initUIOptions, showError);
    },

    initGrammarChecker: function () {
        if (bChrome) {
            browser.storage.local.get("gc_options", this._initGrammarChecker);
            browser.storage.local.get("main_dic_name", this._setSpellingDictionaries);
            browser.storage.local.get("personal_dictionary", this._setSpellingDictionaries);
            browser.storage.local.get("community_dictionary", this._setSpellingDictionaries);
            browser.storage.local.get("oPersonalDictionary", this._setSpellingDictionaries); // deprecated
            browser.storage.local.get("sc_options", this._initSCOptions);
            return;
        }
        browser.storage.local.get("gc_options").then(this._initGrammarChecker, showError);
        browser.storage.local.get("main_dic_name", this._setSpellingDictionaries);
        browser.storage.local.get("personal_dictionary").then(this._setSpellingDictionaries, showError);
        browser.storage.local.get("community_dictionary").then(this._setSpellingDictionaries, showError);
        browser.storage.local.get("oPersonalDictionary").then(this._setSpellingDictionaries, showError); // deprecated
        browser.storage.local.get("sc_options").then(this._initSCOptions, showError);
    },

    registerComposeScripts: async function () {
        // For Thunderbird only
        if (bThunderbird) {
            let xRegisteredScripts = await browser.composeScripts.register({
                /*css: [
                    // Any number of code or file objects could be listed here.
                    { code: "body { background-color: red; }" },
                    { file: "compose.css" },
                ],*/
                js: [
                    // Any number of code or file objects could be listed here.
                    //{ code: `document.body.textContent = "Hey look, the script ran!";` },
                    { file: "content_scripts/editor.js" },
                    { file: "content_scripts/html_src.js" },
                    { file: "content_scripts/panel.js" },
                    { file: "grammalecte/fr/textformatter.js" },
                    { file: "content_scripts/panel_tf.js" },
                    { file: "content_scripts/panel_gc.js" },
                    { file: "content_scripts/message_box.js" },
                    { file: "content_scripts/menu.js" },
                    { file: "content_scripts/init.js" }
                ]
            });
            // To unregister scripts:
            // await xRegisteredScripts.unregister();
        }
    },

    _initUIOptions: function (oSavedOptions) {
        if (!oSavedOptions.hasOwnProperty("ui_options")) {
            browser.storage.local.set({"ui_options": {
                textarea: true,
                editablenode: true
            }});
148
149
150
151
152
153
154










155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183

184





















































































































































































































185
186
187
188
189
190
191
192
193
194
195
196
197



198














































































































199
200
201
202
        catch (e) {
            console.log("initGrammarChecker failed");
            showError(e);
        }
    },

    _setSpellingDictionaries: function (oData) {










        if (oData.hasOwnProperty("community_dictionary")) {
            oWorkerHandler.xGCEWorker.postMessage({ sCommand: "setDictionary", oParam: { sDictionary: "community", oDict: oData["community_dictionary"] }, oInfo: {} });
        }
        if (oData.hasOwnProperty("personal_dictionary")) {
            oWorkerHandler.xGCEWorker.postMessage({ sCommand: "setDictionary", oParam: { sDictionary: "personal", oDict: oData["personal_dictionary"] }, oInfo: {} });
        }
    },

    _initSCOptions: function (oData) {
        if (!oData.hasOwnProperty("sc_options")) {
            browser.storage.local.set({"sc_options": {
                community: true,
                personal: true
            }});
            oWorkerHandler.xGCEWorker.postMessage({ sCommand: "setDictionaryOnOff", oParam: { sDictionary: "community", bActivate: true }, oInfo: {} });
            oWorkerHandler.xGCEWorker.postMessage({ sCommand: "setDictionaryOnOff", oParam: { sDictionary: "personal", bActivate: true }, oInfo: {} });
        } else {
            oWorkerHandler.xGCEWorker.postMessage({ sCommand: "setDictionaryOnOff", oParam: { sDictionary: "community", bActivate: oData.sc_options["community"] }, oInfo: {} });
            oWorkerHandler.xGCEWorker.postMessage({ sCommand: "setDictionaryOnOff", oParam: { sDictionary: "personal", bActivate: oData.sc_options["personal"] }, oInfo: {} });
        }
    }
}

// start the Worker for the GC
oWorkerHandler.start();

// init the options stuff and start the GC
oInitHandler.initUIOptions();
oInitHandler.initGrammarChecker();

























































































































































































































/*
    Actions
*/

function storeGCOptions (dOptions) {
    if (dOptions instanceof Map) {
        dOptions = helpers.mapToObject(dOptions);
    }
    browser.storage.local.set({"gc_options": dOptions});
}



















































































































function showError (e) {
    console.error(e);
    //console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}







>
>
>
>
>
>
>
>
>
>




















|








>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>













>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
        catch (e) {
            console.log("initGrammarChecker failed");
            showError(e);
        }
    },

    _setSpellingDictionaries: function (oData) {
        if (oData.hasOwnProperty("oPersonalDictionary")) {
            // deprecated (to be removed in 2020)
            console.log("personal dictionary migration");
            browser.storage.local.set({ "personal_dictionary": oData["oPersonalDictionary"] });
            oWorkerHandler.xGCEWorker.postMessage({ sCommand: "setDictionary", oParam: { sDictionary: "personal", oDict: oData["oPersonalDictionary"] }, oInfo: {} });
            browser.storage.local.remove("oPersonalDictionary");
        }
        if (oData.hasOwnProperty("main_dic_name")) {
            oWorkerHandler.xGCEWorker.postMessage({ sCommand: "setDictionary", oParam: { sDictionary: "main", oDict: oData["main_dic_name"] }, oInfo: {sExtPath: browser.extension.getURL("")} });
        }
        if (oData.hasOwnProperty("community_dictionary")) {
            oWorkerHandler.xGCEWorker.postMessage({ sCommand: "setDictionary", oParam: { sDictionary: "community", oDict: oData["community_dictionary"] }, oInfo: {} });
        }
        if (oData.hasOwnProperty("personal_dictionary")) {
            oWorkerHandler.xGCEWorker.postMessage({ sCommand: "setDictionary", oParam: { sDictionary: "personal", oDict: oData["personal_dictionary"] }, oInfo: {} });
        }
    },

    _initSCOptions: function (oData) {
        if (!oData.hasOwnProperty("sc_options")) {
            browser.storage.local.set({"sc_options": {
                community: true,
                personal: true
            }});
            oWorkerHandler.xGCEWorker.postMessage({ sCommand: "setDictionaryOnOff", oParam: { sDictionary: "community", bActivate: true }, oInfo: {} });
            oWorkerHandler.xGCEWorker.postMessage({ sCommand: "setDictionaryOnOff", oParam: { sDictionary: "personal", bActivate: true }, oInfo: {} });
        } else {
            oWorkerHandler.xGCEWorker.postMessage({ sCommand: "setDictionaryOnOff", oParam: { sDictionary: "community", bActivate: oData.sc_options["community"] }, oInfo: {} });
            oWorkerHandler.xGCEWorker.postMessage({ sCommand: "setDictionaryOnOff", oParam: { sDictionary: "personal", bActivate: oData.sc_options["personal"] }, oInfo: {} });
        }
    },
}

// start the Worker for the GC
oWorkerHandler.start();

// init the options stuff and start the GC
oInitHandler.initUIOptions();
oInitHandler.initGrammarChecker();
oInitHandler.registerComposeScripts(); // Thunderbird only


// When the extension is installed or updated
browser.runtime.onInstalled.addListener(function (oDetails) {
    // launched at installation or update
    // https://developer.mozilla.org/fr/Add-ons/WebExtensions/API/runtime/onInstalled
    if (oDetails.reason == "update"  ||  oDetails.reason == "installed") {
        // todo
        //browser.tabs.create({url: "http://grammalecte.net"});
    }
});


/*
    Messages from the extension (not the Worker)
*/
function handleMessage (oRequest, xSender, sendResponse) {
    // message from panels
    //console.log(xSender);
    let {sCommand, oParam, oInfo} = oRequest;
    switch (sCommand) {
        case "getOptions":
        case "getDefaultOptions":
        case "setOptions":
        case "setOption":
        case "resetOptions":
        case "textToTest":
        case "fullTests":
        case "setDictionary":
        case "setDictionaryOnOff":
            oWorkerHandler.xGCEWorker.postMessage(oRequest);
            break;
        case "restartWorker":
            oWorkerHandler.restart(oParam["nDelayLimit"]);
            break;
        case "openURL":
            browser.tabs.create({url: oParam.sURL});
            break;
        case "openConjugueurTab":
            openConjugueurTab();
            break;
        case "openLexiconEditor":
            openLexiconEditor(oParam["dictionary"]);
            break;
        case "openDictionaries":
            openDictionaries();
            break;
        default:
            console.log("[background] Unknown command: " + sCommand);
            console.log(oRequest);
    }
    //sendResponse({response: "response from background script"});
}

browser.runtime.onMessage.addListener(handleMessage);


/*
    Ports from content-scripts
*/
let dConnx = new Map();

function handleConnexion (xPort) {
    // Messages from tabs
    let iPortId = xPort.sender.tab.id; // identifier for the port: each port can be found at dConnx[iPortId]
    dConnx.set(iPortId, xPort);
    xPort.onMessage.addListener(function (oRequest) {
        let {sCommand, oParam, oInfo} = oRequest;
        switch (sCommand) {
            case "ping":
                //console.log("[background] ping");
                xPort.postMessage({sActionDone: "ping", result: null, bInfo: null, bEnd: true, bError: false});
                break;
            case "parse":
            case "parseAndSpellcheck":
            case "parseAndSpellcheck1":
            case "parseFull":
            case "getListOfTokens":
            case "getSpellSuggestions":
            case "getVerb":
                oRequest.oInfo.iReturnPort = iPortId; // we pass the id of the return port to receive answer
                oWorkerHandler.xGCEWorker.postMessage(oRequest);
                break;
            case "restartWorker":
                oWorkerHandler.restart(oParam["nDelayLimit"]);
                break;
            case "openURL":
                browser.tabs.create({url: oParam.sURL});
                break;
            case "openConjugueurTab":
                openConjugueurTab();
                break;
            case "openConjugueurWindow":
                openConjugueurWindow();
                break;
            case "openLexiconEditor":
                openLexiconEditor();
                break;
            default:
                console.log("[background] Unknown command: " + sCommand);
                console.log(oRequest);
        }
    });
    //xPort.postMessage({sActionDone: "newId", result: iPortId});
    //console.log("[Grammalecte] init connection to content-script");
    xPort.postMessage({sActionDone: "init", sUrl: browser.extension.getURL("")});
}

browser.runtime.onConnect.addListener(handleConnexion);



/*
    ComposeAction
    (Thunderbird only)
*/
if (bThunderbird) {
    browser.composeAction.onClicked.addListener(function (xTab, xData) {
        sendCommandToTab(xTab.id, "grammar_checker_compose_window");
    });
}


/*
    Context Menu
    (not for MailExtension)
*/
if (!bThunderbird) {
    // Analyze
    browser.contextMenus.create({ id: "grammar_checker_editable",   title: "Analyser cette zone de texte",              contexts: ["editable"] });
    browser.contextMenus.create({ id: "grammar_checker_selection",  title: "Analyser la sélection",                     contexts: ["selection"] });
    browser.contextMenus.create({ id: "grammar_checker_iframe",     title: "Analyser le contenu de ce cadre",           contexts: ["frame"] });
    browser.contextMenus.create({ id: "grammar_checker_page",       title: "Analyser la page",                          contexts: ["all"] });
    browser.contextMenus.create({ id: "separator_tools",            type: "separator",                                  contexts: ["all"] });
    // Tools
    browser.contextMenus.create({ id: "conjugueur_tab",             title: "Conjugueur [onglet]",                       contexts: ["all"] });
    browser.contextMenus.create({ id: "conjugueur_window",          title: "Conjugueur [fenêtre]",                      contexts: ["all"] });
    //browser.contextMenus.create({ id: "dictionaries",               title: "Dictionnaires",                             contexts: ["all"] });
    browser.contextMenus.create({ id: "lexicon_editor",             title: "Éditeur lexical",                           contexts: ["all"] });

    browser.contextMenus.onClicked.addListener(function (xInfo, xTab) {
        // xInfo = https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/contextMenus/OnClickData
        // xTab = https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/tabs/Tab
        // confusing: no way to get the node where we click?!
        switch (xInfo.menuItemId) {
            // analyze
            case "grammar_checker_editable":
            case "grammar_checker_page":
                sendCommandToTab(xTab.id, xInfo.menuItemId);
                break;
            case "grammar_checker_iframe":
                sendCommandToTab(xTab.id, xInfo.menuItemId, xInfo.frameId);
                break;
            case "grammar_checker_selection":
                sendCommandToTab(xTab.id, xInfo.menuItemId, xInfo.selectionText);
                break;
            // tools
            case "conjugueur_window":
                openConjugueurWindow();
                break;
            case "conjugueur_tab":
                openConjugueurTab();
                break;
            case "lexicon_editor":
                openLexiconEditor();
                break;
            case "dictionaries":
                openDictionaries();
                break;
            default:
                console.log("[Background] Unknown menu id: " + xInfo.menuItemId);
                console.log(xInfo);
                console.log(xTab);
        }
    });
}



/*
    Keyboard shortcuts
*/
browser.commands.onCommand.addListener(function (sCommand) {
    switch (sCommand) {
        case "grammar_checker":
            sendCommandToCurrentTab("shortcutGrammarChecker");
            break;
        case "conjugueur_tab":
            openConjugueurTab();
            break;
        case "lexicon_editor":
            openLexiconEditor();
            break;
        case "dictionaries":
            openDictionaries();
            break;
    }
});


/*
    Tabs
*/
let nTabLexiconEditor = null;
let nTabDictionaries = null;
let nTabConjugueur = null;

browser.tabs.onRemoved.addListener(function (nTabId, xRemoveInfo) {
    switch (nTabId) {
        case nTabLexiconEditor: nTabLexiconEditor = null; break;
        case nTabDictionaries:  nTabDictionaries = null; break;
        case nTabConjugueur:    nTabConjugueur = null; break;
    }
});


/*
    Actions
*/

function storeGCOptions (dOptions) {
    if (dOptions instanceof Map) {
        dOptions = helpers.mapToObject(dOptions);
    }
    browser.storage.local.set({"gc_options": dOptions});
}

function sendCommandToTab (iTab, sCommand, result=null) {
    let xTabPort = dConnx.get(iTab);
    xTabPort.postMessage({sActionDone: sCommand, result: result, oInfo: null, bEnd: false, bError: false});
}

function sendCommandToCurrentTab (sCommand) {
    if (bChrome) {
        browser.tabs.query({ currentWindow: true, active: true }, (lTabs) => {
            for (let xTab of lTabs) {
                //console.log(xTab);
                browser.tabs.sendMessage(xTab.id, {sActionRequest: sCommand});
            }
        });
        return;
    }
    browser.tabs.query({ currentWindow: true, active: true }).then((lTabs) => {
        for (let xTab of lTabs) {
            //console.log(xTab);
            browser.tabs.sendMessage(xTab.id, {sActionRequest: sCommand});
        }
    }, showError);
}

function sendCommandToAllTabs (sCommand) {
    for (let [iTab, xTabPort] of dConnx.entries()) {
        xTabPort.postMessage({sActionDone: sCommand, result: null, oInfo: null, bEnd: false, bError: false});
    }
}

function openLexiconEditor (sName="__personal__") {
    if (nTabLexiconEditor === null) {
        if (bChrome) {
            browser.tabs.create({
                url: browser.extension.getURL("panel/lex_editor.html")
            }, onLexiconEditorOpened);
            return;
        }
        let xLexEditor = browser.tabs.create({
            url: browser.extension.getURL("panel/lex_editor.html")
        });
        xLexEditor.then(onLexiconEditorOpened, showError);
    }
    else {
        browser.tabs.update(nTabLexiconEditor, {active: true});
    }
}

function onLexiconEditorOpened (xTab) {
    nTabLexiconEditor = xTab.id;
}

function openDictionaries () {
    if (nTabDictionaries === null) {
        if (bChrome) {
            browser.tabs.create({
                url: browser.extension.getURL("panel/dictionaries.html")
            }, onDictionariesOpened);
            return;
        }
        let xLexEditor = browser.tabs.create({
            url: browser.extension.getURL("panel/dictionaries.html")
        });
        xLexEditor.then(onDictionariesOpened, showError);
    }
    else {
        browser.tabs.update(nTabDictionaries, {active: true});
    }
}

function onDictionariesOpened (xTab) {
    nTabDictionaries = xTab.id;
}

function openConjugueurTab () {
    if (nTabConjugueur === null) {
        if (bChrome) {
            browser.tabs.create({
                url: browser.extension.getURL("panel/conjugueur.html")
            }, onConjugueurOpened);
            return;
        }
        let xConjTab = browser.tabs.create({
            url: browser.extension.getURL("panel/conjugueur.html")
        });
        xConjTab.then(onConjugueurOpened, showError);
    }
    else {
        browser.tabs.update(nTabConjugueur, {active: true});
    }
}

function onConjugueurOpened (xTab) {
    nTabConjugueur = xTab.id;
}

function openConjugueurWindow () {
    if (bChrome) {
        browser.windows.create({
            url: browser.extension.getURL("panel/conjugueur.html"),
            type: "popup",
            width: 710,
            height: 980
        });
        return;
    }
    let xConjWindow = browser.windows.create({
        url: browser.extension.getURL("panel/conjugueur.html"),
        type: "popup",
        width: 710,
        height: 980
    });
}


function showError (e) {
    console.error(e);
    //console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}

Deleted gc_lang/fr/mailext/chrome.manifest version [8b108fd6a7].

1
2
3
4
5
6
7
8
9
# https://developer.mozilla.org/en-US/docs/Chrome_Registration
content	grammarchecker	content/
content promiseworker ./worker/
resource grammalecte ./grammalecte/
locale	grammarchecker	fr	locale/fr/
locale	grammarchecker	en	locale/en/
skin	grammarchecker	classic/1.0	skin/
overlay	chrome://messenger/content/messengercompose/messengercompose.xul	chrome://grammarchecker/content/overlay.xul
style	chrome://messenger/content/customizeToolbar.xul	chrome://grammarchecker/content/overlay.css
<
<
<
<
<
<
<
<
<


















Deleted gc_lang/fr/mailext/content/about.css version [0c03b7bf9e].

1
2
3
4
5
6
7
8
9
10
11
12
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
/* CSS */

.descr {
	font-size: 18px;
	font-weight: bold;
	text-align: center;
}

.stdlabel {
	font-size: 16px;
	text-align: center;
}

#website {
	font-size: 16px;
	font-weight: bold;
	color: hsl(210, 50%, 50%);
	text-align: center;
	cursor: pointer;
}

#contrib {
	font-size: 16px;
	text-align: center;
	color: hsl(210, 50%, 50%);
	cursor: pointer;
}


/*
    TB Next: fix dialogheaders
*/
dialogheader {
  -moz-binding: url("chrome://messenger/content/generalBindings.xml#dialogheader");
  margin: 0 5px 5px;
  border: 1px solid ThreeDDarkShadow;
  padding: 5px 8px;
  background-color: Highlight;
  color: HighlightText;
}

.dialogheader-title {
  margin: 0 !important;
  font-size: larger;
  font-weight: bold;
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































Deleted gc_lang/fr/mailext/content/about.js version [94f44e1159].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// JavaScript

const Cc = Components.classes;
const Ci = Components.interfaces;
//const Cu = Components.utils;


function openInBrowserURL (sURL) {
    // method found in S3.Google.Translator
    try {
        openURL(sURL);
        // Works in overlay.js, but not here… Seems there is no documentation available about this feature on Mozilla.org
    }
    catch (e) {
        console.error(e);
        //Cu.reportError(e);
    }
}

function openInTabURL (sURL) {
    // method found in S3.Google.Translator
    try {
        let xWM = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
        let xWin = xWM.getMostRecentWindow("mail:3pane");
        let xTabmail = xWin.document.getElementById('tabmail');
        xWin.focus();
        if (xTabmail) {
            xTabmail.openTab('contentTab', { contentPage: sURL });
        }
    }
    catch (e) {
        console.error(e);
        //Cu.reportError(e);
    }
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































Deleted gc_lang/fr/mailext/content/about.xul version [6f2fa2e063].

1
2
3
4
5
6
7
8
9
10
11
12
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
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://grammarchecker/content/about.css" type="text/css"?>

<!DOCTYPE dialog SYSTEM "chrome://grammarchecker/locale/about.dtd">

<dialog
  id="grammalecte-about-window"
  title="&windowtitle;"
  orient="vertical"
  buttons="accept"
  width="300"
  onload="document.getElementById('grammalecte-about-window').centerWindowOnScreen();"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <!-- Other elements go here -->
  <description  style="text-align: center;">
    <image src="chrome://grammarchecker/skin/logo120_text.png" />
  </description>
  <label class="descr">&description1;</label>
  <label class="descr">&description2;</label>
  <label class="stdlabel" value="&version; ${version}" />
  <label class="stdlabel" value="&license; GPL 3" />
  <label id="website" value="Site web" onclick="openInTabURL('https://grammalecte.net/?from=grammalecte-tb');" />

  <separator class="groove" orient="horizontal" style="margin: 10px;"/>

  <label class="stdlabel" value="&thanks;" />
  <image src="chrome://grammarchecker/skin/LaMouette_small.png" style="cursor: pointer;"
    onclick="openInTabURL('http://lamouette.org/?from=grammalecte-tb');" />
  <label class="stdlabel" value="&amp;" />
  <image src="chrome://grammarchecker/skin/Algoo_logo.png" style="cursor: pointer;"
    onclick="openInTabURL('https://www.algoo.fr/?from=grammalecte-tb');" />
  <label id="contrib" value="&contrib;"
    onclick="openInTabURL('https://grammalecte.net/#thanks');" />

  <script type="application/javascript" src="about.js"/>
</dialog>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































Deleted gc_lang/fr/mailext/content/conjugueur.css version [c5ad386744].

1
2
3
4
5
6
7
8
9
10
11
12
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
48
/* CSS */

#verb {
    width: 200px;
}

#verb_title {
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    color: hsl(210, 50%, 50%);
}

#info {
    font-size: 16px;
    text-align: center;
    vertical-align: bottom;
}


.groupbox {
    margin-left: 5px;
    margin-bottom: 5px;
    width: 275px;
    border: 1px solid hsl(0, 0%, 90%);
    border-radius: 5px;
}

#smallnote {
    font-size: 10px;
    width: 250px;
}

.sub_header {
    color: hsl(0, 50%, 50%);
    font-size: 16px;
    font-weight: bold;
    border-bottom: 1px solid hsl(0, 0%, 80%);
}

label.temps {
    color: hsl(210, 50%, 50%);
    font-size: 13px;
    font-weight: bold;
}
label.cj {
    font-size: 11px;
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































Deleted gc_lang/fr/mailext/content/conjugueur.js version [de46feffb0].

1
2
3
4
5
6
7
8
9
10
11
12
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
48
49
50
51
52
53
54
55
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
84
85
86
87
88
89
90
91
92
93
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
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
// JavaScript

//const Cu = Components.utils;
//const { require } = Cu.import("resource://gre/modules/commonjs/toolkit/require.js", {});
//const conj = require("resource://grammalecte/fr/conj.js");


let oConj = {
    init: function () {
        console.log("Init conjugueur");
        try {
            // button
            document.getElementById('conjugate').addEventListener("click", (xEvent) => {
                this.getVerbAndConjugate();
            });
            // text field
            document.getElementById('verb').addEventListener("change", (xEvent) => {
                this.getVerbAndConjugate();
            });
            // options
            document.getElementById('oneg').addEventListener("click", (xEvent) => {
                this._displayResults();
            });
            document.getElementById('opro').addEventListener("click", (xEvent) => {
                this._displayResults();
            });
            document.getElementById('oint').addEventListener("click", (xEvent) => {
                this._displayResults();
            });
            document.getElementById('ofem').addEventListener("click", (xEvent) => {
                this._displayResults();
            });
            document.getElementById('otco').addEventListener("click", (xEvent) => {
                this._displayResults();
            });
        }
        catch (e) {
            console.error(e);
        }
        this.conjugate("être");
    },

    oVerb: null,

    getVerbAndConjugate: function () {
        this.conjugate(document.getElementById('verb').value);
    },

    conjugate: function (sVerb) {
        try {
            document.getElementById('oneg').checked = false;
            document.getElementById('opro').checked = false;
            document.getElementById('oint').checked = false;
            document.getElementById('otco').checked = false;
            document.getElementById('ofem').checked = false;
            document.getElementById('smallnote').hidden = true;

            // request analyzing
            sVerb = sVerb.trim().toLowerCase().replace(/’/g, "'").replace(/  +/g, " ");
            if (sVerb) {
                if (sVerb.startsWith("ne pas ")) {
                    document.getElementById('oneg').checked = true;
                    sVerb = sVerb.slice(7);
                }
                if (sVerb.startsWith("se ")) {
                    document.getElementById('opro').checked = true;
                    sVerb = sVerb.slice(3);
                } else if (sVerb.startsWith("s'")) {
                    document.getElementById('opro').checked = true;
                    sVerb = sVerb.slice(2);
                }
                if (sVerb.endsWith("?")) {
                    document.getElementById('oint').checked = true;
                    sVerb = sVerb.slice(0,-1).trim();
                }

                if (!conj.isVerb(sVerb)) {
                    document.getElementById('verb').style = "color: #BB4411;";
                } else {
                    document.getElementById('verb_title').textContent = sVerb;
                    document.getElementById('verb').style = "color: #999999;";
                    document.getElementById('verb').value = "";
                    this.oVerb = new Verb(sVerb);
                    document.getElementById('info').textContent = this.oVerb.sInfo;
                    document.getElementById('opro').label = this.oVerb.sProLabel;
                    if (this.oVerb.bUncomplete) {
                        document.getElementById('opro').checked = false;
                        document.getElementById('opro').disabled = true;
                        document.getElementById('opro').style = "color: #CCC;";
                        document.getElementById('otco').checked = false;
                        document.getElementById('otco').disabled = true;
                        document.getElementById('otco').style = "color: #CCC;";
                        document.getElementById('smallnote').hidden = false;
                    } else {
                        document.getElementById('otco').disabled = false;
                        document.getElementById('otco').style = "color: #000;";
                        if (this.oVerb.nPronominable == 0) {
                            document.getElementById('opro').checked = false;
                            document.getElementById('opro').disabled = false;
                            document.getElementById('opro').style = "color: #000;";
                        } else if (this.oVerb.nPronominable == 1) {
                            document.getElementById('opro').checked = true;
                            document.getElementById('opro').disabled = true;
                            document.getElementById('opro').style = "color: #CCC;";
                        } else { // -1 or 1 or error
                            document.getElementById('opro').checked = false;
                            document.getElementById('opro').disabled = true;
                            document.getElementById('opro').style = "color: #CCC;";
                        }
                        document.getElementById('smallnote').hidden = true;
                    }
                    this._displayResults();
                }
            }
        }
        catch (e) {
            console.error(e);
        }
    },

    _displayResults: function () {
        if (this.oVerb === null) {
            return;
        }
        try {
            let bPro = document.getElementById('opro').checked;
            let bNeg = document.getElementById('oneg').checked;
            let bTCo = document.getElementById('otco').checked;
            let bInt = document.getElementById('oint').checked;
            let bFem = document.getElementById('ofem').checked;
            let oConjTable = this.oVerb.createConjTable(bPro, bNeg, bTCo, bInt, bFem);
            document.getElementById('verb').Text = "";
            // infinitif
            document.getElementById('infi').textContent = oConjTable["infi"] || " "; // something or nbsp
            // participe présent
            document.getElementById('ppre').textContent = oConjTable["ppre"] || " ";
            // participes passés
            document.getElementById('ppas1').textContent = oConjTable["ppas1"] || " ";
            document.getElementById('ppas2').textContent = oConjTable["ppas2"] || " ";
            document.getElementById('ppas3').textContent = oConjTable["ppas3"] || " ";
            document.getElementById('ppas4').textContent = oConjTable["ppas4"] || " ";
            // impératif
            document.getElementById('impe_temps').textContent = oConjTable["t_impe"] || " ";
            document.getElementById('impe1').textContent = oConjTable["impe1"] || " ";
            document.getElementById('impe2').textContent = oConjTable["impe2"] || " ";
            document.getElementById('impe3').textContent = oConjTable["impe3"] || " ";
            // présent
            document.getElementById('ipre_temps').textContent = oConjTable["t_ipre"] || " ";
            document.getElementById('ipre1').textContent = oConjTable["ipre1"] || " ";
            document.getElementById('ipre2').textContent = oConjTable["ipre2"] || " ";
            document.getElementById('ipre3').textContent = oConjTable["ipre3"] || " ";
            document.getElementById('ipre4').textContent = oConjTable["ipre4"] || " ";
            document.getElementById('ipre5').textContent = oConjTable["ipre5"] || " ";
            document.getElementById('ipre6').textContent = oConjTable["ipre6"] || " ";
            // imparfait
            document.getElementById('iimp_temps').textContent = oConjTable["t_iimp"] || " ";
            document.getElementById('iimp1').textContent = oConjTable["iimp1"] || " ";
            document.getElementById('iimp2').textContent = oConjTable["iimp2"] || " ";
            document.getElementById('iimp3').textContent = oConjTable["iimp3"] || " ";
            document.getElementById('iimp4').textContent = oConjTable["iimp4"] || " ";
            document.getElementById('iimp5').textContent = oConjTable["iimp5"] || " ";
            document.getElementById('iimp6').textContent = oConjTable["iimp6"] || " ";
            // passé simple
            document.getElementById('ipsi_temps').textContent = oConjTable["t_ipsi"] || " ";
            document.getElementById('ipsi1').textContent = oConjTable["ipsi1"] || " ";
            document.getElementById('ipsi2').textContent = oConjTable["ipsi2"] || " ";
            document.getElementById('ipsi3').textContent = oConjTable["ipsi3"] || " ";
            document.getElementById('ipsi4').textContent = oConjTable["ipsi4"] || " ";
            document.getElementById('ipsi5').textContent = oConjTable["ipsi5"] || " ";
            document.getElementById('ipsi6').textContent = oConjTable["ipsi6"] || " ";
            // futur
            document.getElementById('ifut_temps').textContent = oConjTable["t_ifut"] || " ";
            document.getElementById('ifut1').textContent = oConjTable["ifut1"] || " ";
            document.getElementById('ifut2').textContent = oConjTable["ifut2"] || " ";
            document.getElementById('ifut3').textContent = oConjTable["ifut3"] || " ";
            document.getElementById('ifut4').textContent = oConjTable["ifut4"] || " ";
            document.getElementById('ifut5').textContent = oConjTable["ifut5"] || " ";
            document.getElementById('ifut6').textContent = oConjTable["ifut6"] || " ";
            // Conditionnel
            document.getElementById('conda_temps').textContent = oConjTable["t_conda"] || " ";
            document.getElementById('conda1').textContent = oConjTable["conda1"] || " ";
            document.getElementById('conda2').textContent = oConjTable["conda2"] || " ";
            document.getElementById('conda3').textContent = oConjTable["conda3"] || " ";
            document.getElementById('conda4').textContent = oConjTable["conda4"] || " ";
            document.getElementById('conda5').textContent = oConjTable["conda5"] || " ";
            document.getElementById('conda6').textContent = oConjTable["conda6"] || " ";
            document.getElementById('condb_temps').textContent = oConjTable["t_condb"] || " ";
            document.getElementById('condb1').textContent = oConjTable["condb1"] || " ";
            document.getElementById('condb2').textContent = oConjTable["condb2"] || " ";
            document.getElementById('condb3').textContent = oConjTable["condb3"] || " ";
            document.getElementById('condb4').textContent = oConjTable["condb4"] || " ";
            document.getElementById('condb5').textContent = oConjTable["condb5"] || " ";
            document.getElementById('condb6').textContent = oConjTable["condb6"] || " ";
            // subjonctif présent
            document.getElementById('spre_temps').textContent = oConjTable["t_spre"] || " ";
            document.getElementById('spre1').textContent = oConjTable["spre1"] || " ";
            document.getElementById('spre2').textContent = oConjTable["spre2"] || " ";
            document.getElementById('spre3').textContent = oConjTable["spre3"] || " ";
            document.getElementById('spre4').textContent = oConjTable["spre4"] || " ";
            document.getElementById('spre5').textContent = oConjTable["spre5"] || " ";
            document.getElementById('spre6').textContent = oConjTable["spre6"] || " ";
            // subjonctif imparfait
            document.getElementById('simp_temps').textContent = oConjTable["t_simp"] || " ";
            document.getElementById('simp1').textContent = oConjTable["simp1"] || " ";
            document.getElementById('simp2').textContent = oConjTable["simp2"] || " ";
            document.getElementById('simp3').textContent = oConjTable["simp3"] || " ";
            document.getElementById('simp4').textContent = oConjTable["simp4"] || " ";
            document.getElementById('simp5').textContent = oConjTable["simp5"] || " ";
            document.getElementById('simp6').textContent = oConjTable["simp6"] || " ";
        }
        catch (e) {
            console.error(e);
        }
    }
};

conj.init(helpers.loadFile("resource://grammalecte/fr/conj_data.json"));
oConj.init();
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































































































































































































































































































































































































Deleted gc_lang/fr/mailext/content/conjugueur.xul version [7d69e0ed2b].

1
2
3
4
5
6
7
8
9
10
11
12
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
48
49
50
51
52
53
54
55
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
84
85
86
87
88
89
90
91
92
93
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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
162
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://grammarchecker/content/conjugueur.css" type="text/css"?>


<dialog
  id="grammalecte-conjugueur-window"
  title="Grammalecte · Conjugueur…"
  orient="vertical"
  width="580"
  buttons="extra1"
  buttonlabelextra1="Conjuguer"
  ondialogextra1="oConj.getVerbAndConjugate();"
  defaultButton="extra1"
  onload="document.getElementById('grammalecte-conjugueur-window').centerWindowOnScreen();"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">


  <!-- Other elements go here -->
  <box>
    <spacer flex="1"/>
    <image src="chrome://grammarchecker/skin/grammarcheck.png" />
    <textbox id="verb" value="" />
    <button id="conjugate" label="Conjuguer" />
    <spacer flex="1"/>
  </box>

  <box>
    <spacer flex="1"/>
    <checkbox id="oneg" label="Négation" />
    <checkbox id="opro" label="Pronominal" />
    <checkbox id="ofem" label="Féminin" />
    <checkbox id="oint" label="Interrogatif" />
    <checkbox id="otco" label="Temps composés" />
    <spacer flex="1"/>
  </box>

  <box>
    <spacer flex="1"/>
    <box orient="vertical">
      <label id="verb_title">.</label>
      <label id="info">.</label>
    </box>
    <spacer flex="1"/>
  </box>

  <columns>
    <column>
      <groupbox class="groupbox" id="infinitif">
        <label class="sub_header">Infinitif</label>
        <label id="infi" class="cj">.</label>
      </groupbox>

      <groupbox class="groupbox" id="imperatif">
        <label class="sub_header">Impératif</label>
        <label id="impe_temps" class="temps">Présent</label>
        <label id="impe1" class="cj">.</label>
        <label id="impe2" class="cj">.</label>
        <label id="impe3" class="cj">.</label>
      </groupbox>
    </column>

    <column>
      <groupbox class="groupbox" id="partpre">
        <label class="sub_header">Participe présent</label>
        <label id="ppre" class="cj">.</label>
      </groupbox>

      <groupbox class="groupbox" id="partpas">
        <label class="sub_header">Participes passés</label>
        <label id="ppas1" class="cj">.</label>
        <label id="ppas2" class="cj">.</label>
        <label id="ppas3" class="cj">.</label>
        <label id="ppas4" class="cj">.</label>
      </groupbox>
    </column>
  </columns>

  <columns>
    <column>
      <groupbox class="groupbox" id="indicatif">
        <label class="sub_header">Indicatif</label>
        <label id="ipre_temps" class="temps">Présent</label>
        <label id="ipre1" class="cj">.</label>
        <label id="ipre2" class="cj">.</label>
        <label id="ipre3" class="cj">.</label>
        <label id="ipre4" class="cj">.</label>
        <label id="ipre5" class="cj">.</label>
        <label id="ipre6" class="cj">.</label>

        <label id="iimp_temps" class="temps">Imparfait</label>
        <label id="iimp1" class="cj">.</label>
        <label id="iimp2" class="cj">.</label>
        <label id="iimp3" class="cj">.</label>
        <label id="iimp4" class="cj">.</label>
        <label id="iimp5" class="cj">.</label>
        <label id="iimp6" class="cj">.</label>

        <label id="ipsi_temps" class="temps">Passé simple</label>
        <label id="ipsi1" class="cj">.</label>
        <label id="ipsi2" class="cj">.</label>
        <label id="ipsi3" class="cj">.</label>
        <label id="ipsi4" class="cj">.</label>
        <label id="ipsi5" class="cj">.</label>
        <label id="ipsi6" class="cj">.</label>

        <label id="ifut_temps" class="temps">Futur</label>
        <label id="ifut1" class="cj">.</label>
        <label id="ifut2" class="cj">.</label>
        <label id="ifut3" class="cj">.</label>
        <label id="ifut4" class="cj">.</label>
        <label id="ifut5" class="cj">.</label>
        <label id="ifut6" class="cj">.</label>
      </groupbox>
      <description id="smallnote">Ce verbe n’a pas encore été vérifié. C’est pourquoi les options “pronominal” et “temps composés” sont désactivées.</description>
    </column>

    <column>
      <groupbox class="groupbox" id="subjonctif">
        <label class="sub_header">Subjonctif</label>
        <label id="spre_temps" class="temps">Présent</label>
        <label id="spre1" class="cj">.</label>
        <label id="spre2" class="cj">.</label>
        <label id="spre3" class="cj">.</label>
        <label id="spre4" class="cj">.</label>
        <label id="spre5" class="cj">.</label>
        <label id="spre6" class="cj">.</label>

        <label id="simp_temps" class="temps">Imparfait</label>
        <label id="simp1" class="cj">.</label>
        <label id="simp2" class="cj">.</label>
        <label id="simp3" class="cj">.</label>
        <label id="simp4" class="cj">.</label>
        <label id="simp5" class="cj">.</label>
        <label id="simp6" class="cj">.</label>
      </groupbox>

      <groupbox class="groupbox" id="conditionnel">
        <label class="sub_header">Conditionnel</label>
        <label id="conda_temps" class="temps">Présent</label>
        <label id="conda1" class="cj">.</label>
        <label id="conda2" class="cj">.</label>
        <label id="conda3" class="cj">.</label>
        <label id="conda4" class="cj">.</label>
        <label id="conda5" class="cj">.</label>
        <label id="conda6" class="cj">.</label>

        <label id="condb_temps" class="temps">.</label>
        <label id="condb1" class="cj">.</label>
        <label id="condb2" class="cj">.</label>
        <label id="condb3" class="cj">.</label>
        <label id="condb4" class="cj">.</label>
        <label id="condb5" class="cj">.</label>
        <label id="condb6" class="cj">.</label>
      </groupbox>
    </column>
  </columns>

  <script type="application/javascript" src="resource://grammalecte/graphspell/helpers.js"/>
  <script type="application/javascript" src="resource://grammalecte/fr/conj.js"/>
  <script type="application/javascript" src="conjugueur.js"/>
</dialog>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































































































































































































































































































































Deleted gc_lang/fr/mailext/content/gc_options.css version [c585d5d70e].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* CSS */

.section {
	font-size: 16px;
	font-weight: bold;
	color: hsl(210, 50%, 50%);
}

.dialogheader-title {
  margin: 5px;
  padding: 5px 8px;
  border: 1px solid hsl(210, 50%, 80%);
  background-color: hsl(210, 50%, 50%);
  color: hsl(210, 10%, 90%);
  font-size: larger;
  font-weight: bold;
}

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































Deleted gc_lang/fr/mailext/content/gc_options.js version [050fb882b6].

1
2
3
4
5
6
7
8
9
10
11
12
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
48
49
50
51
52
53
// JavaScript

const Cc = Components.classes;
const Ci = Components.interfaces;
// const Cu = Components.utils;
const prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).getBranch("extensions.grammarchecker.");


var oOptControl = {
    oOptions: null,
    load: function () {
        this._setDialogOptions(false);
        this.listen();
    },
    listen: function () {
        document.addEventListener("dialogaccept", (event) => {
            this.save();
        });
        document.addEventListener("dialogextra1", (event) => {
            this.reset();
        });
    },
    _setDialogOptions: function (bDefaultOptions=false) {
        try {
            sOptions = bDefaultOptions ? prefs.getCharPref("sGCDefaultOptions") : prefs.getCharPref("sGCOptions");
            this.oOptions = JSON.parse(sOptions);
            for (let sParam in this.oOptions) {
                if (document.getElementById("option_"+sParam) !== null) {
                    document.getElementById("option_"+sParam).checked = this.oOptions[sParam];
                }
            }
        }
        catch (e) {
            console.error(e);
        }
    },
    save: function () {
        try {
            for (let xNode of document.getElementsByClassName("option")) {
                this.oOptions[xNode.id.slice(7)] = xNode.checked;
            }
            prefs.setCharPref("sGCOptions", JSON.stringify(this.oOptions));
        }
        catch (e) {
            console.error(e);
        }
    },
    reset: function () {
        this._setDialogOptions(true);
    }
}

oOptControl.load();
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<










































































































Deleted gc_lang/fr/mailext/content/gc_options.xul version [2d497a7dd0].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://grammarchecker/content/gc_options.css" type="text/css"?>

<!DOCTYPE dialog SYSTEM "chrome://grammarchecker/locale/gc_options.dtd">

<dialog
  id="grammalecte-gcoptions-window"
  title="&window.title;"
  orient="vertical"
  buttons="accept, cancel, extra1"
  buttonlabelextra1="&defaultbutton.label;"
  defaultButton="accept"
  width="400"
  onload="document.getElementById('grammalecte-gcoptions-window').centerWindowOnScreen();"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <!-- Other elements go here -->

  <div class="dialogheader-title">&dialogheader.label;</div>

  <tabbox id="tabs_options" selectedIndex="0">
    <tabs>
${sXULTabs}
    </tabs>
    <tabpanels>
${sXULTabPanels}
    </tabpanels>
  </tabbox>

  <script type="application/javascript" src="gc_options.js" />

</dialog>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































Deleted gc_lang/fr/mailext/content/options.css version [b5017553f4].

1
2
3
4
5
6
7
8
9
10
11
12
/* CSS */


.dialogheader-title {
  margin: 5px;
  padding: 5px 8px;
  border: 1px solid hsl(210, 50%, 80%);
  background-color: hsl(210, 50%, 50%);
  color: hsl(210, 10%, 90%);
  font-size: larger;
  font-weight: bold;
}
<
<
<
<
<
<
<
<
<
<
<
<
























Deleted gc_lang/fr/mailext/content/options.js version [9da0d898f3].

1
2
3
4
5
6
7
8
9
10
11
12
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
// JavaScript

"use strict";


const Cc = Components.classes;
const Ci = Components.interfaces;
// const Cu = Components.utils;
const prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).getBranch("extensions.grammarchecker.");


var oOptControl = {

    load: function () {
        try {
            document.getElementById('check_signature').checked = prefs.getBoolPref('bCheckSignature');
        }
        catch (e) {
            console.error(e);
        }
        this.listen();
    },

    listen: function () {
        document.addEventListener("dialogaccept", (event) => {
            this.save();
        });
    },

    save: function () {
        try {
            prefs.setBoolPref('bCheckSignature', document.getElementById('check_signature').checked);
        }
        catch (e) {
            console.error(e);
        }
    }
}

oOptControl.load();
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
















































































Deleted gc_lang/fr/mailext/content/options.xul version [3943bf3117].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://grammarchecker/content/options.css" type="text/css"?>

<!DOCTYPE dialog SYSTEM "chrome://grammarchecker/locale/options.dtd">

<dialog
  id="grammalecte-options-window"
  title="&window.title;"
  orient="vertical"
  buttons="accept, cancel"
  defaultButton="accept"
  width="400"
  onload="document.getElementById('grammalecte-options-window').centerWindowOnScreen();"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <!-- Other elements go here -->

  <div class="dialogheader-title">&dialogheader.label;</div>

  <checkbox id="check_signature" label="&check_signature.label;" accesskey="&check_signature.accesskey;" />

  <script type="application/javascript" src="options.js" />

</dialog>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































Deleted gc_lang/fr/mailext/content/overlay.css version [680f0ace85].

1
2
3
4
5
6
7
8
9
10
11
12
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
48
49
50
51
52
53
54
55
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
84
85
86
87
88
89
90
91
92
93
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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
162
163
164
#grammarchecker-toolbar-button {
    list-style-image: url("chrome://grammarchecker/skin/grammarcheck.png");
}
[iconsize="small"] #grammarchecker-toolbar-button {
    list-style-image: url("chrome://grammarchecker/skin/grammarcheck_small.png");
}
#grammarchecker-toolbar-button[disabled="true"] {
    list-style-image: url("chrome://grammarchecker/skin/grammarcheck_disabled.png");
}
[iconsize="small"] #grammarchecker-toolbar-button[disabled="true"] {
    list-style-image: url("chrome://grammarchecker/skin/grammarcheck_small_disabled.png");
}

#grammalecte-menu {
    list-style-image: url("chrome://grammarchecker/skin/grammarcheck.png");
}
menuitem#gl-item-analyze {
    list-style-image: url('chrome://grammarchecker/skin/grammarcheck.png');
}

#textformatter-panel {
    overflow: auto;
    height: 500px;
    max-height: 650px;
    color: hsl(0, 0%, 0%);
}
#textformatter-title {
    margin-top: 10px;
}
#textformatter-commands {
    margin: 10px 0;
}
#textformatter-infomsg {
    padding: 5px;
    font-size: 10px;
}
.optiongroup {
    color: hsl(210, 50%, 40%);
    font-size: 14px;
    font-weight: bold;
}
#textformatter-progressbar {
    width: 470px;
}
#textformatter-timer {
    padding: 5px;
}


#grammarchecker-panel {
    overflow: auto;
    margin-left: 0.5em;
    height: 400px;
    max-height: 600px;
}

#grammalecte-title {
    margin-top: 10px;
}

#grammalecte-infobox {
    display: block;
    margin: 20px 10px 5px 10px;
    padding: 10px;
    background-color: hsl(210, 20%, 40%);
    border-radius: 3px;
    color: hsl(210, 50%, 96%);
    font-weight: bold;
}
#grammalecte-info {
    padding: 1px 5px;
}
#closebutton {
    padding: 1px 5px;
    background-color: hsl(0, 50%, 50%);
    color: hsl(0, 10%, 96%);
    border-radius: 2px;
    cursor: pointer;
}

#grammalecte-errors div {
    display: block;
    /*display: list-item;
    list-style-position: inside;*/
    margin-top: 10px;
}
#grammalecte-errors p {
    display: block;
    margin-left: 10px;
    color: hsl(0, 0%, 0%);
}
#grammalecte-errors p.paragraph {
    margin-top: 20px;
    font-size: 16px;
    font-family: "Courier New", Courier, "Lucida Sans Typewriter", "Lucida Typewriter", monospace;
}
#grammalecte-errors p.message {
    margin-left: 20px;
}
#grammalecte-errors p.moreinfo {
    margin-left: 40px;
}
#grammalecte-errors p.suggestions {
    margin-left: 40px;
    color: hsl(120, 5%, 33%);
}
#grammalecte-errors span.suggestions_button {
    padding: 1px 6px;
    background-color: hsl(120, 40%, 60%);
    color: hsl(120, 10%, 96%);
    border-radius: 2px;
    cursor: pointer;
}
#grammalecte-errors {
    display: block;
}

a {
    font-weight: bold;
    color: hsl(30, 50%, 50%);
    text-decoration: underline;
    cursor: pointer;
}
.error {
    /* default color */
    background-color: hsl(210, 50%, 50%);
    color: hsl(210, 10%, 96%);
    font-weight: bold;
    border-radius: 3px;
    /*border-bottom: 2px solid hsl(210, 50%, 50%);*/
}
.errornum {
    color: hsl(210, 10%, 30%);
    font-weight: bold;
}
.sugg {
    padding: 1px 6px;
    background-color: hsl(120, 50%, 30%);
    color: hsl(210, 10%, 90%);
    border-radius: 2px;
    font-weight: bold;
    cursor: pointer;
}
.debug_info {
    color: hsl(0, 50%, 50%);
    font-style: italic;
}

.spell {
    background-color: hsl(0, 50%, 50%);
    color: hsl(0, 0%, 96%);
    border-radius: 3px;
}


.dialogheader-title {
    margin: 5px;
    padding: 5px 8px;
    border: 1px solid hsl(210, 50%, 80%);
    background-color: hsl(210, 50%, 50%);
    color: hsl(210, 10%, 90%);
    font-size: larger;
    font-weight: bold;
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<








































































































































































































































































































































Deleted gc_lang/fr/mailext/content/overlay.js version [2bffe86e4e].

1
2
3
4
5
6
7
8
9
10
11
12
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
48
49
50
51
52
53
54
55
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
84
85
86
87
88
89
90
91
92
93
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
// 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 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 ([
        ["1", "¹"], ["2", "²"], ["3", "³"], ["4", "⁴"], ["5", "⁵"],
        ["6", "⁶"], ["7", "⁷"], ["8", "⁸"], ["9", "⁹"], ["0", "⁰"]
    ]),
    convert: function (sText) {
        let sRes = "";
        for (let c of sText) {
            sRes += (this.dNumbers.has(c)) ? this.dNumbers.get(c) : "⁻";
        }
        return sRes;
    }
};


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', [xGrammalectePrefs.getCharPref("sGCOptions"), "Thunderbird"]);
            xPromise.then(
                function (aVal) {
                    console.log(aVal);
                    xGrammalectePrefs.setCharPref("sGCOptions", aVal);
                    // spelling dictionary
                    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 (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); }
            ).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) {
                console.log('Done.');
                console.log(aVal);
            },
            function (aReason) { console.log('Promise rejected', aReason); }
        ).catch(
            function (aCaught) { console.log('Promise Error', aCaught); }
        );
    },
    test: function (sText) {
        console.log("Test...");
        let xPromise = this.xGCEWorker.post('parse', [sText, "FR", true]);
        xPromise.then(
            function (aVal) {
                let lErr = JSON.parse(aVal);
                if (lErr.length > 0) {
                    for (let dErr of lErr) {
                        console.log(text.getReadableError(dErr));
                    }
                } else {
                    console.log("no error found");
                }
            },
            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', [xGrammalectePrefs.getCharPref("sGCOptions")]);
        xPromise.then(
            function (aVal) {
                console.log(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);
                xGrammalectePrefs.setCharPref("sGCOptions", aVal);
            },
            function (aReason) { console.log('Promise rejected', aReason); }
        ).catch(
            function (aCaught) { console.log('Promise Error', aCaught); }
        );
    },
    parse: async function () {
        this.clearPreview();
        this.openPanel();
        this.setInfo("Analyse en cours…");
        try {
            let xEditor = new Editor();
            let nParagraph = 0;
            let bIsError = false;
            for (let [iParagraph, sParagraph] of xEditor.getParagraphs()) {
                if (sParagraph.trim() !== "") {
                    let sRes = await this.xGCEWorker.post('parseAndSpellcheck', [sParagraph, "FR", false, false]);
                    let oRes = JSON.parse(sRes);
                    if (oRes.aGrammErr.length > 0 || oRes.aSpellErr.length > 0) {
                        document.getElementById("grammalecte-errors").appendChild(this.createResultNode(xEditor, sParagraph, iParagraph, oRes.aGrammErr, oRes.aSpellErr));
                        bIsError = true;
                    }
                    nParagraph += 1;
                }
            }
            if (bIsError === false) {
                let xNodeP = document.createElement("p");
                xNodeP.setAttribute("class", "message");
                xNodeP.textContent = "Aucune erreur détectée…";
                document.getElementById("grammalecte-errors").appendChild(xNodeP);
            }
            this.setInfo("Nombre de paragraphes analysés : " + nParagraph);
        }
        catch (e) {
            this.setInfo("Erreur : " + e.message);
            console.error(e);
        }
    },
    createResultNode: function (xEditor, sParagraph, iParagraph, aGrammErr, aSpellErr) {
        let xResultNode = document.createElement("div");
        xResultNode.setAttribute("id", "resnode" + iParagraph);
        this.fillResultNode(xResultNode, xEditor, sParagraph, iParagraph, aGrammErr, aSpellErr);
        return xResultNode;
    },
    reparseParagraph: function (xEditor, iParagraph) {
        try {
            let that = this;
            let xResultNode = document.getElementById("resnode"+iParagraph);
            xResultNode.textContent = "…………… réanalyse en cours ……………";
            let sParagraph = xEditor.getParagraph(iParagraph);
            let xPromise = this.xGCEWorker.post('parseAndSpellcheck', [sParagraph, "FR", false, false]);
            xPromise.then(function (res) {
                xResultNode.textContent = "";
                let oRes = JSON.parse(res);
                if (oRes.aGrammErr.length > 0 || oRes.aSpellErr.length > 0) {
                    that.fillResultNode(xResultNode, xEditor, sParagraph, iParagraph, oRes.aGrammErr, oRes.aSpellErr);
                }
            }, function (res) {
                xResultNode.textContent = "Erreur: " + res;
            });
        }
        catch (e) {
            console.error(e);
        }
    },
    fillResultNode: function (xResultNode, xEditor, sParagraph, iParagraph, aGrammErr, aSpellErr) {
        try {
            if (aGrammErr.length === 0  &&  aSpellErr.length === 0) {
                return null;
            }
            aGrammErr.push(...aSpellErr);
            aGrammErr.sort(function (a, b) {
                if (a["nStart"] < b["nStart"])
                    return -1;
                if (a["nStart"] > b["nStart"])
                    return 1;
                return 0;
            });
            let xParagraphNode = document.createElement("p");
            let lNodeError = [];
            let nEndLastErr = 0;
            let nError = 1;
            xParagraphNode.setAttribute("class", "paragraph");
            for (let dErr of aGrammErr) {
                let nStart = dErr["nStart"];
                let nEnd = dErr["nEnd"];
                if (nStart >= nEndLastErr) {
                    xParagraphNode.appendChild(document.createTextNode(this._purgeTags(sParagraph.slice(nEndLastErr, nStart))));
                    let xNodeError = document.createElement("b");
                    if (dErr['sType'] !== 'WORD') {
                        xNodeError.setAttribute("class", "error");
                        xNodeError.textContent = oConverterToExponent.convert(nError.toString()) + sParagraph.slice(nStart, nEnd);
                        xNodeError.style.backgroundColor = dErr["aColor"];
                        xParagraphNode.appendChild(xNodeError);
                        lNodeError.push(this._createNodeGCErrorDescription(xEditor, nError, dErr, iParagraph));
                    }
                    else {
                        xNodeError.setAttribute("class", "error spell");
                        xNodeError.textContent = oConverterToExponent.convert(nError.toString()) + sParagraph.slice(nStart, nEnd);
                        xParagraphNode.appendChild(xNodeError);
                        lNodeError.push(this._createNodeSpellErrorDescription(xEditor, nError, dErr, iParagraph));
                    }
                    nEndLastErr = nEnd;
                    nError += 1;
                }
            }
            xParagraphNode.appendChild(document.createTextNode(this._purgeTags(sParagraph.slice(nEndLastErr))));
            xResultNode.appendChild(xParagraphNode);
            for (let xNode of lNodeError) {
                xResultNode.appendChild(xNode);
            }
        }
        catch (e) {
            console.error(e);
            xResultNode.textContent = "# Error: " + e.message;
        }
    },
    _createNodeGCErrorDescription: function (xEditor, nError, dErr, iParagraph) {
        let xNodeDiv = document.createElement("div");
        let that = this;
        // message
        let xNodeMessage = document.createElement("p");
        xNodeMessage.setAttribute("class", "message");
        let xNodeErrorNumber = document.createElement("b");
        xNodeErrorNumber.setAttribute("class", "errornum");
        xNodeErrorNumber.textContent = "[" + nError + "] ";
        xNodeMessage.appendChild(xNodeErrorNumber);
        xNodeMessage.appendChild(document.createTextNode(" " + dErr["sMessage"].replace(/&nbsp;/g, " ") + " "));
        if (false) {
            // debug info
            let xNodeDebug = document.createElement("span");
            xNodeDebug.setAttribute("class", "debug_info");
            xNodeDebug.textContent = " #" + dErr["sRuleId"] + " #" + dErr["sLineId"];
            xNodeMessage.appendChild(xNodeDebug);
        }
        xNodeDiv.appendChild(xNodeMessage);
        // URL
        if (dErr["URL"]) {
            let xNodeP = document.createElement("p");
            xNodeP.setAttribute("class", "moreinfo");
            xNodeP.appendChild(document.createTextNode("→ "));
            let xNodeURL = document.createElement("a");
            xNodeURL.setAttribute("href", dErr["URL"]);
            xNodeURL.textContent = "Plus d’informations…";
            xNodeURL.addEventListener("click", function (e) {
                that.openInTabURL(dErr["URL"]);
            });
            xNodeP.appendChild(xNodeURL);
            xNodeDiv.appendChild(xNodeP);
        }
        // suggestions
        if (dErr["aSuggestions"].length > 0) {
            let xNodeSuggLine = document.createElement("p");
            xNodeSuggLine.setAttribute("class", "suggestions");
            xNodeSuggLine.textContent = "Suggestions : ";
            let n = 0;
            for (let sSugg of dErr["aSuggestions"]) {
                if (n > 0) {
                    xNodeSuggLine.appendChild(document.createTextNode(" "));
                }
                let xNodeSugg = document.createElement("span");
                xNodeSugg.setAttribute("class", "sugg");
                xNodeSugg.textContent = sSugg.replace(" ", " "); // use nnbsp
                xNodeSugg.addEventListener("click", function (e) {
                    xEditor.changeParagraph(iParagraph, sSugg, dErr["nStart"], dErr["nEnd"]);
                    xNodeDiv.textContent = "";
                    that.reparseParagraph(xEditor, iParagraph);
                });
                xNodeSuggLine.appendChild(xNodeSugg);
                n += 1;
            }
            xNodeDiv.appendChild(xNodeSuggLine);
        }
        return xNodeDiv;
    },
    _purgeTags: function (sText) {
        sText = sText.replace(/<br ?\/?>/ig, " ");
        sText = sText.replace(/<font size="[+-]\d+">/g, "");
        return sText.replace(/<\/? ?[a-zA-Z]+ ?>/g, "");
    },
    _createNodeSpellErrorDescription: function (xEditor, nError, dErr, iParagraph) {
        let xNodeDiv = document.createElement("div");
        let that = this;
        // message
        let xNodeMessage = document.createElement("p");
        xNodeMessage.setAttribute("class", "message");
        let xNodeErrorNumber = document.createElement("b");
        xNodeErrorNumber.setAttribute("class", "errornum");
        xNodeErrorNumber.textContent = "[" + nError + "] ";
        xNodeMessage.appendChild(xNodeErrorNumber);
        xNodeMessage.appendChild(document.createTextNode(" Mot inconnu du dictionnaire. "));
        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 () {
        this._strings = document.getElementById("grammarchecker-strings");
        let that = this;
        let nsGrammarCommand = {
            isCommandEnabled: function (aCommand, dummy) {
                return (IsDocumentEditable() && !IsInHTMLSourceMode());
            },
            getCommandStateParams: function (aCommand, aParams, aRefCon) {},
            doCommandParams: function (aCommand, aParams, aRefCon) {},
            doCommand: function (aCommand) {
                that.onParseText(aCommand);
            }
        };
        let xCommandTable = GetComposerCommandTable();
        xCommandTable.registerCommand("cmd_grammar", nsGrammarCommand);
        let sButtonId = "grammarchecker-toolbar-button";
        let sButtonId2 = "grammalecte-menu";
        let xNavBar  = document.getElementById("composeToolbar2");
        let lCurSet  = xNavBar.currentSet.split(",");
        if (lCurSet.indexOf(sButtonId) == -1) {
            let iPos = lCurSet.indexOf("spellingButton") + 1 || lCurSet.length;
            let aSet = lCurSet.slice(0, iPos).concat(sButtonId).concat(sButtonId2).concat(lCurSet.slice(iPos));
            xNavBar.setAttribute("currentset", aSet.join(","));
            //xNavBar.currentSet = aSet.join(",");
            Services.xulStore.persist(xNavBar, "currentset");
            //Ci.BrowserToolboxCustomizeDone(true);
        }
    },
    clearPreview: function () {
        let xPreview = document.getElementById("grammalecte-errors");
        while (xPreview.firstChild) {
            xPreview.removeChild(xPreview.firstChild);
        };
        let xEditor = GetCurrentEditor();
        if (xEditor != null) {
            try {
                xEditor.QueryInterface(Ci.nsIEditorStyleSheets);
                xEditor.addOverrideStyleSheet("chrome://grammarchecker/content/overlay.css");
            }
            catch (e) {
                console.error(e);
            }
        }
        this.setInfo("[vide]");
    },
    setInfo: function (sText) {
        document.getElementById("grammalecte-info").textContent = sText;
    },
    openPanel: function () {
        document.getElementById("textformatter-splitter").setAttribute("state", "collapsed");
        document.getElementById("grammarchecker-splitter").setAttribute("state", "open");
    },
    closePanel: function () {
        document.getElementById("grammarchecker-splitter").setAttribute("state", "collapsed");
    },
    openDialog: function (sWhat, sName="", sOptions="") {
        try {
            window.openDialog(sWhat, sName, sOptions);
        }
        catch (e) {
            console.error(e);
        }
    },
    openInTabURL: function (sURL) {
        // method found in S3.Google.Translator
        try {
            let xWM = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
            let xWin = xWM.getMostRecentWindow("mail:3pane");
            let xTabmail = xWin.document.getElementById('tabmail');
            xWin.focus();
            if (xTabmail) {
                xTabmail.openTab('contentTab', { contentPage: sURL });
            }
        }
        catch (e) {
            console.error(e);
        }
    },
    openInBrowserURL: function (sURL) {
        // method found in S3.Google.Translator
        try {
            openURL(sURL);
        }
        catch (e) {
            console.error(e);
        }
    },
    onParseText: function (e) {
        this.parse();
    },
    onClosePanel: function (e) {
        this.closePanel();
    },
    onOpenGCOptions: function (e) {
        let that = this;
        let xPromise = this.xGCEWorker.post('getDefaultOptions');
        xPromise.then(
            function (aVal) {
                console.log(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");
                that.setOptions();
            },
            function (aReason) { console.log('Error options dialog', aReason); }
        ).catch(
            function (aCaught) { console.log('Error', aCaught); }
        );
    },
    onOpenSpellOptions: function (e) {
        this.openDialog("chrome://grammarchecker/content/spell_options.xul", "", "chrome, dialog, modal, resizable=no");
    },
    onOpenOptions: function (e) {
        this.openDialog("chrome://grammarchecker/content/options.xul", "", "chrome, dialog, modal, resizable=no");
    },
    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 oTextFormatter = {
    init: function () {
        try {
            this.closePanel();
            this.listen();
            let sTFOptions = xGrammalectePrefs.getCharPref("sTFOptions");
            if (sTFOptions !== "") {
                this.setOptionsInPanel(JSON.parse(sTFOptions));
                this.resetProgressBar();
            } else {
                this.reset();
            }
        }
        catch (e) {
            console.error(e);
        }
    },
    listen: function () {
        window.addEventListener("click", (xEvent) => {
            let xElem = xEvent.target;
            if (xElem.id && xElem.id.startsWith("o_group_")) {
                this.switchGroup(xElem.id);
                this.resetProgressBar();
            }
        }, false);
    },
    apply: function () {
        try {
            this.saveOptions();
            this.resetProgressBar();
            let xEditor = new Editor();
            let sText = xEditor.getContent();
            let iParagraph = 0;
            sText = this.applyOptions(sText);
            for (let sParagraph of text.getParagraph(sText)) {
                xEditor.writeParagraph(iParagraph, sParagraph);
                iParagraph += 1;
            }
        }
        catch (e) {
            console.error(e);
        }
    },
    saveOptions: function () {
        let oOptions = {};
        for (let xNode of document.getElementsByClassName("option")) {
            oOptions[xNode.id] = xNode.checked;
        }
        //console.log("save options: " + 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_")) {
                    this.switchGroup(sOptName);
                }
                if (document.getElementById("res_"+sOptName) !== null) {
                    document.getElementById("res_"+sOptName).textContent = "";
                }
            }
        }
    },
    switchGroup: function (sOptName) {
        if (document.getElementById(sOptName).checked) {
            document.getElementById(sOptName.slice(2)).style.opacity = 1;
        } else {
            document.getElementById(sOptName.slice(2)).style.opacity = 0.3;
        }
    },
    reset: function () {
        try {
            this.resetProgressBar();
            for (let xNode of document.getElementsByClassName('option')) {
                xNode.checked = (xNode.getAttribute('data-default') === "true");
                if (xNode.id.startsWith("o_group_")) {
                    this.switchGroup(xNode.id);
                }
            }
        }
        catch (e) {
            console.error(e);
        }
    },
    resetProgressBar: function () {
        document.getElementById('textformatter-progressbar').value = 0;
        document.getElementById('textformatter-timer').textContent = "";
    },
    getTimeRes: function (n) {
        // returns duration in seconds as string
        if (n < 10) {
            return n.toFixed(3).toString() + " s";
        }
        if (n < 100) {
            return n.toFixed(2).toString() + " s";
        }
        if (n < 1000) {
            return n.toFixed(1).toString() + " s";
        }
        return n.toFixed().toString() + " s";
    },
    openPanel: function () {
        document.getElementById("grammarchecker-splitter").setAttribute("state", "collapsed");
        document.getElementById("textformatter-splitter").setAttribute("state", "open");
    },
    closePanel: function () {
        document.getElementById("textformatter-splitter").setAttribute("state", "collapsed");
    },
    onOpenPanel: function (e) {
        this.openPanel();
    },
    onClosePanel: function (e) {
        this.closePanel();
    },
    onApply: function (e) {
        this.apply();
    },
    onReset: function (e) {
        this.reset();
    },
    //
    applyOptions: function (sText) {
        try {
            const t0 = Date.now();
            //window.setCursor("wait"); // change pointer
            document.getElementById('textformatter-progressbar').value = 0;
            document.getElementById('textformatter-progressbar').max = 6;
            let n1 = 0, n2 = 0, n3 = 0, n4 = 0, n5 = 0, n6 = 0, n7 = 0;

            // espaces surnuméraires
            if (document.getElementById("o_group_ssp").checked) {
                if (document.getElementById("o_end_of_paragraph").checked) {
                    [sText, n1] = this.formatText(sText, "end_of_paragraph");
                    document.getElementById('res_o_end_of_paragraph').textContent = n1;
                }
                if (document.getElementById("o_between_words").checked) {
                    [sText, n1] = this.formatText(sText, "between_words");
                    document.getElementById('res_o_between_words').textContent = n1;
                }
                if (document.getElementById("o_start_of_paragraph").checked) {
                    [sText, n1] = this.formatText(sText, "start_of_paragraph");
                    document.getElementById('res_o_start_of_paragraph').textContent = n1;
                }
                if (document.getElementById("o_before_punctuation").checked) {
                    [sText, n1] = this.formatText(sText, "before_punctuation");
                    document.getElementById('res_o_before_punctuation').textContent = n1;
                }
                if (document.getElementById("o_within_parenthesis").checked) {
                    [sText, n1] = this.formatText(sText, "within_parenthesis");
                    document.getElementById('res_o_within_parenthesis').textContent = n1;
                }
                if (document.getElementById("o_within_square_brackets").checked) {
                    [sText, n1] = this.formatText(sText, "within_square_brackets");
                    document.getElementById('res_o_within_square_brackets').textContent = n1;
                }
                if (document.getElementById("o_within_quotation_marks").checked) {
                    [sText, n1] = this.formatText(sText, "within_quotation_marks");
                    document.getElementById('res_o_within_quotation_marks').textContent = n1;
                }
                document.getElementById("o_group_ssp").checked = false;
                this.switchGroup("o_group_ssp");
            }
            document.getElementById('textformatter-progressbar').value = 1;

            // espaces insécables
            if (document.getElementById("o_group_nbsp").checked) {
                if (document.getElementById("o_nbsp_before_punctuation").checked) {
                    [sText, n1] = this.formatText(sText, "nbsp_before_punctuation");
                    [sText, n2] = this.formatText(sText, "nbsp_repair");
                    document.getElementById('res_o_nbsp_before_punctuation').textContent = n1 - n2;
                }
                if (document.getElementById("o_nbsp_within_quotation_marks").checked) {
                    [sText, n1] = this.formatText(sText, "nbsp_within_quotation_marks");
                    document.getElementById('res_o_nbsp_within_quotation_marks').textContent = n1;
                }
                if (document.getElementById("o_nbsp_before_symbol").checked) {
                    [sText, n1] = this.formatText(sText, "nbsp_before_symbol");
                    document.getElementById('res_o_nbsp_before_symbol').textContent = n1;
                }
                if (document.getElementById("o_nbsp_within_numbers").checked) {
                    [sText, n1] = this.formatText(sText, "nbsp_within_numbers");
                    document.getElementById('res_o_nbsp_within_numbers').textContent = n1;
                }
                if (document.getElementById("o_nbsp_before_units").checked) {
                    [sText, n1] = this.formatText(sText, "nbsp_before_units");
                    document.getElementById('res_o_nbsp_before_units').textContent = n1;
                }
                if (document.getElementById("o_nbsp_titles").checked) {
                    [sText, n1] = this.formatText(sText, "nbsp_titles");
                    document.getElementById('res_o_nbsp_titles').textContent = n1;
                }
                document.getElementById("o_group_nbsp").checked = false;
                this.switchGroup("o_group_nbsp");
            }
            document.getElementById('textformatter-progressbar').value = 2;

            // espaces manquants
            if (document.getElementById("o_group_typo").checked) {
                if (document.getElementById("o_ts_units").checked) {
                    [sText, n1] = this.formatText(sText, "ts_units");
                    document.getElementById('res_o_ts_units').textContent = n1;
                }
            }
            if (document.getElementById("o_group_space").checked) {
                if (document.getElementById("o_add_space_after_punctuation").checked) {
                    [sText, n1] = this.formatText(sText, "add_space_after_punctuation");
                    [sText, n2] = this.formatText(sText, "add_space_repair");
                    document.getElementById('res_o_add_space_after_punctuation').textContent = n1 - n2;
                }
                if (document.getElementById("o_add_space_around_hyphens").checked) {
                    [sText, n1] = this.formatText(sText, "add_space_around_hyphens");
                    document.getElementById('res_o_add_space_around_hyphens').textContent = n1;
                }
                document.getElementById("o_group_space").checked = false;
                this.switchGroup("o_group_space");
            }
            document.getElementById('textformatter-progressbar').value = 3;

            // suppression
            if (document.getElementById("o_group_delete").checked) {
                if (document.getElementById("o_erase_non_breaking_hyphens").checked) {
                    [sText, n1] = this.formatText(sText, "erase_non_breaking_hyphens");
                    document.getElementById('res_o_erase_non_breaking_hyphens').textContent = n1;
                }
                document.getElementById("o_group_delete").checked = false;
                this.switchGroup("o_group_delete");
            }
            document.getElementById('textformatter-progressbar').value = 4;

            // signes typographiques
            if (document.getElementById("o_group_typo").checked) {
                if (document.getElementById("o_ts_apostrophe").checked) {
                    [sText, n1] = this.formatText(sText, "ts_apostrophe");
                    document.getElementById('res_o_ts_apostrophe').textContent = n1;
                }
                if (document.getElementById("o_ts_ellipsis").checked) {
                    [sText, n1] = this.formatText(sText, "ts_ellipsis");
                    document.getElementById('res_o_ts_ellipsis').textContent = n1;
                }
                if (document.getElementById("o_ts_dash_start").checked) {
                    if (document.getElementById("o_ts_m_dash_start").checked) {
                        [sText, n1] = this.formatText(sText, "ts_m_dash_start");
                    } else {
                        [sText, n1] = this.formatText(sText, "ts_n_dash_start");
                    }
                    document.getElementById('res_o_ts_dash_start').textContent = n1;
                }
                if (document.getElementById("o_ts_dash_middle").checked) {
                    if (document.getElementById("o_ts_m_dash_middle").checked) {
                        [sText, n1] = this.formatText(sText, "ts_m_dash_middle");
                    } else {
                        [sText, n1] = this.formatText(sText, "ts_n_dash_middle");
                    }
                    document.getElementById('res_o_ts_dash_middle').textContent = n1;
                }
                if (document.getElementById("o_ts_quotation_marks").checked) {
                    [sText, n1] = this.formatText(sText, "ts_quotation_marks");
                    document.getElementById('res_o_ts_quotation_marks').textContent = n1;
                }
                if (document.getElementById("o_ts_spell").checked) {
                    [sText, n1] = this.formatText(sText, "ts_spell");
                    document.getElementById('res_o_ts_spell').textContent = n1;
                }
                if (document.getElementById("o_ts_ligature").checked) {
                    // ligatures typographiques : fi, fl, ff, ffi, ffl, ft, st
                    if (document.getElementById("o_ts_ligature_do").checked) {
                        if (document.getElementById("o_ts_ligature_ffi").checked) {
                            [sText, n1] = this.formatText(sText, "ts_ligature_ffi_do");
                        }
                        if (document.getElementById("o_ts_ligature_ffl").checked) {
                            [sText, n2] = this.formatText(sText, "ts_ligature_ffl_do");
                        }
                        if (document.getElementById("o_ts_ligature_fi").checked) {
                            [sText, n3] = this.formatText(sText, "ts_ligature_fi_do");
                        }
                        if (document.getElementById("o_ts_ligature_fl").checked) {
                            [sText, n4] = this.formatText(sText, "ts_ligature_fl_do");
                        }
                        if (document.getElementById("o_ts_ligature_ff").checked) {
                            [sText, n5] = this.formatText(sText, "ts_ligature_ff_do");
                        }
                        if (document.getElementById("o_ts_ligature_ft").checked) {
                            [sText, n6] = this.formatText(sText, "ts_ligature_ft_do");
                        }
                        if (document.getElementById("o_ts_ligature_st").checked) {
                            [sText, n7] = this.formatText(sText, "ts_ligature_st_do");
                        }
                    }
                    if (document.getElementById("o_ts_ligature_undo").checked) {
                        if (document.getElementById("o_ts_ligature_ffi").checked) {
                            [sText, n1] = this.formatText(sText, "ts_ligature_ffi_undo");
                        }
                        if (document.getElementById("o_ts_ligature_ffl").checked) {
                            [sText, n2] = this.formatText(sText, "ts_ligature_ffl_undo");
                        }
                        if (document.getElementById("o_ts_ligature_fi").checked) {
                            [sText, n3] = this.formatText(sText, "ts_ligature_fi_undo");
                        }
                        if (document.getElementById("o_ts_ligature_fl").checked) {
                            [sText, n4] = this.formatText(sText, "ts_ligature_fl_undo");
                        }
                        if (document.getElementById("o_ts_ligature_ff").checked) {
                            [sText, n5] = this.formatText(sText, "ts_ligature_ff_undo");
                        }
                        if (document.getElementById("o_ts_ligature_ft").checked) {
                            [sText, n6] = this.formatText(sText, "ts_ligature_ft_undo");
                        }
                        if (document.getElementById("o_ts_ligature_st").checked) {
                            [sText, n7] = this.formatText(sText, "ts_ligature_st_undo");
                        }
                    }
                    document.getElementById('res_o_ts_ligature').textContent = n1 + n2 + n3 + n4 + n5 + n6 + n7;
                }
                document.getElementById("o_group_typo").checked = false;
                this.switchGroup("o_group_typo");
            }
            document.getElementById('textformatter-progressbar').value = 5;

            // divers
            if (document.getElementById("o_group_misc").checked) {
                if (document.getElementById("o_ordinals_no_exponant").checked) {
                    if (document.getElementById("o_ordinals_exponant").checked) {
                        [sText, n1] = this.formatText(sText, "ordinals_exponant");
                    } else {
                        [sText, n1] = this.formatText(sText, "ordinals_no_exponant");
                    }
                    document.getElementById('res_o_ordinals_no_exponant').textContent = n1;
                }
                if (document.getElementById("o_etc").checked) {
                    [sText, n1] = this.formatText(sText, "etc");
                    document.getElementById('res_o_etc').textContent = n1;
                }
                if (document.getElementById("o_missing_hyphens").checked) {
                    [sText, n1] = this.formatText(sText, "missing_hyphens");
                    document.getElementById('res_o_missing_hyphens').textContent = n1;
                }
                if (document.getElementById("o_ma_word").checked) {
                    [sText, n1] = this.formatText(sText, "ma_word");
                    if (document.getElementById("o_ma_1letter_lowercase").checked) {
                        [sText, n1] = this.formatText(sText, "ma_1letter_lowercase");
                        if (document.getElementById("o_ma_1letter_uppercase").checked) {
                            [sText, n1] = this.formatText(sText, "ma_1letter_uppercase");
                        }
                    }
                    document.getElementById('res_o_ma_word').textContent = n1;
                }
                document.getElementById("o_group_misc").checked = false;
                this.switchGroup("o_group_misc");
            }
            document.getElementById('textformatter-progressbar').value = document.getElementById('textformatter-progressbar').max;
            // end of processing

            //window.setCursor("auto"); // restore pointer
            const t1 = Date.now();
            document.getElementById('textformatter-timer').textContent = this.getTimeRes((t1-t0)/1000);
        }
        catch (e) {
            console.error(e);
        }
        return sText;
    },
    formatText: function (sText, sOptName) {
        let nCount = 0;
        try {
            if (!oReplTable.hasOwnProperty(sOptName)) {
                console.log("# Error. TF: there is no option “" + sOptName+ "”.");
                return [sText, nCount];
            }
            for (let [zRgx, sRep] of oReplTable[sOptName]) {
                nCount += (sText.match(zRgx) || []).length;
                sText = sText.replace(zRgx, sRep);
            }
        }
        catch (e) {
            console.error(e);
        }
        return [sText, nCount];
    }
}


/* EVENTS */

window.addEventListener("load", function (xEvent) {
    oGrammarChecker.loadGC();
    //oGrammarChecker.fullTests();
}, false);

window.addEventListener("compose-window-init", function (xEvent) {
    oGrammarChecker.loadUI();
    oGrammarChecker.closePanel();
    oGrammarChecker.clearPreview();
    oTextFormatter.init();
}, true);
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted gc_lang/fr/mailext/content/overlay.xul version [c9ae1732ec].

1
2
3
4
5
6
7
8
9
10
11
12
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
48
49
50
51
52
53
54
55
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
84
85
86
87
88
89
90
91
92
93
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
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
370
371
372
373
374
375
376
377
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="chrome://grammarchecker/content/overlay.css" type="text/css"?>
<!--<?xml-stylesheet type="text/css" href="chrome://messenger/skin/messenger.css"?>-->

<!DOCTYPE overlay SYSTEM "chrome://grammarchecker/locale/overlay.dtd">

<overlay id="grammarchecker-overlay"
         xmlns:html="http://www.w3.org/1999/xhtml"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
  <script type="application/javascript" src="chrome://messenger/content/customElements.js"/>
  <script type="application/javascript" src="resource://grammalecte/text.js"/>
  <script type="application/javascript" src="resource://grammalecte/fr/textformatter.js"/>
  <script type="application/javascript" src="overlay.js"/>
  <script type="application/javascript" src="file_handler.js"/>
  <script type="application/javascript" src="spellchecker.js"/>
  <script type="application/javascript" src="editor.js"/>


  <!--<stringbundleset id="stringbundleset">
    <stringbundle id="grammarchecker-strings" src="chrome://grammarchecker/locale/grammarchecker.properties"/>
  </stringbundleset>-->

  <commandset id="composerEditMenuItems" commandupdater="true"
              events="focus"
              oncommandupdate="goUpdateCommand('cmd_grammar')">
    <command id="cmd_grammar" label="&grammarchecker.button.label;" oncommand="goDoCommand('cmd_grammar')"/>
  </commandset>

  <menupopup id="taskPopup">
    <!-- menu tools -->
    <menuitem id="grammarchecker-hello" command="cmd_grammar"/>
  </menupopup>

  <popup id="msgComposeContext">
    <!-- contextual menu -->
    <menuitem id="context-grammarchecker" command="cmd_grammar"
        accesskey="&grammarchecker.accesskey;"/>
  </popup>

  <toolbarpalette id="MsgComposeToolbarPalette">
    <!-- toolbar palette -->
    <toolbarbutton id="grammarchecker-toolbar-button" command="cmd_grammar"
                   tooltiptext="&grammarchecker.tooltip;"
                   class="toolbarbutton-1 chromeclass-toolbar-additional" />

    <toolbarbutton id="grammalecte-menu" type="menu-button" label="Grammalecte" class="toolbarbutton-1" tooltip="&grammarchecker.tooltip;" oncommand="">
      <menupopup id="gl-toolbar-popup">
        <menuitem id="gl-item-conj" class="menuitem-iconic" label="&grammalectemenu.textformatter;" oncommand="oTextFormatter.onOpenPanel(event);"/>
        <menuitem id="gl-item-conj" class="menuitem-iconic" label="&grammalectemenu.conjugueur;" oncommand="oGrammarChecker.onOpenConjugueur(event);"/>
        <menuseparator/>
        <menuitem id="gl-item-analyze" class="menuitem-iconic" label="&grammalectemenu.start;" oncommand="oGrammarChecker.onParseText(event);"/>
        <menuitem id="gl-item-options" class="menuitem-iconic" label="&grammalectemenu.gc_options;" onclick="oGrammarChecker.onOpenGCOptions(event);"/>
        <menuitem id="gl-item-options" class="menuitem-iconic" label="&grammalectemenu.spell_options;" onclick="oGrammarChecker.onOpenSpellOptions(event);"/>
        <menuitem id="gl-item-options" class="menuitem-iconic" label="&grammalectemenu.other_options;" onclick="oGrammarChecker.onOpenOptions(event);"/>
        <menuitem id="gl-item-options" class="menuitem-iconic" label="&grammalectemenu.lexicon_editor;" onclick="oGrammarChecker.onOpenLexiconEditor(event);"/>
        <menuseparator/>
        <menuitem id="gl-item-about" class="menuitem-iconic" label="&grammalectemenu.about;" oncommand="oGrammarChecker.onAbout(event);"/>
      </menupopup>
    </toolbarbutton>
  </toolbarpalette>


  <vbox id="appcontent">

    <!--

      TEXT FORMATTER PANEL

    -->
    <splitter id="textformatter-splitter" state="collapsed" collapse="after"><grippy /></splitter>

    <vbox id="textformatter-panel">

      <div class="dialogheader-title">Grammalecte · &textformatter; · &automated_replacements;</div>

      <hbox id="tf-columns">
        <vbox class="column" width="400">
          <!-- Supernumerary spaces -->
          <groupbox>
            <hbox class="groupbox-title">
              <label class="header"><checkbox id="o_group_ssp" class="option optiongroup" data-default="true" label="&tf_ssp;" /></label>
            </hbox>
            <vbox id="group_ssp" class="groupblock">
              <hbox class="blockopt underline">
                <checkbox id="o_start_of_paragraph" class="option" data-default="true" label="&tf_start_of_paragraph;" />
                <spacer flex="1" />
                <label id="res_o_start_of_paragraph" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_end_of_paragraph" class="option" data-default="true" label="&tf_end_of_paragraph;" />
                <spacer flex="1" />
                <label id="res_o_end_of_paragraph" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_between_words" class="option" data-default="true" label="&tf_between_words;" />
                <spacer flex="1" />
                <label id="res_o_between_words" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_before_punctuation" class="option" data-default="true" label="&tf_before_punctuation;" />
                <spacer flex="1" />
                <label id="res_o_before_punctuation" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_within_parenthesis" class="option" data-default="true" label="&tf_within_parenthesis;" />
                <spacer flex="1" />
                <label id="res_o_within_parenthesis" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_within_square_brackets" class="option" data-default="true" label="&tf_within_square_brackets;" />
                <spacer flex="1" />
                <label id="res_o_within_square_brackets" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_within_quotation_marks" class="option" data-default="true" label="&tf_within_quotation_marks;" />
                <spacer flex="1" />
                <label id="res_o_within_quotation_marks" class="result" />
              </hbox>
            </vbox>
          </groupbox>

          <!-- Missing spaces -->
          <groupbox>
            <hbox class="groupbox-title">
              <label class="header"><checkbox id="o_group_space" class="option optiongroup" data-default="true" label="&tf_space;" /></label>
            </hbox>
            <vbox id="group_space" class="groupblock">
              <hbox class="blockopt underline">
                <checkbox id="o_add_space_after_punctuation" class="option" data-default="true" label="&tf_add_space_after_punctuation;" />
                <spacer flex="1" />
                <label id="res_o_add_space_after_punctuation" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_add_space_around_hyphens" class="option" data-default="true" label="&tf_add_space_around_hyphens;" />
                <spacer flex="1" />
                <label id="res_o_add_space_around_hyphens" class="result" />
              </hbox>
            </vbox>
          </groupbox>

          <!-- Non breaking spaces -->
          <groupbox>
            <hbox class="groupbox-title">
              <label class="header"><checkbox id="o_group_nbsp" class="option optiongroup" data-default="true" label="&tf_nbsp;" /></label>
            </hbox>
            <vbox id="group_nbsp" class="groupblock">
              <hbox class="blockopt underline">
                <checkbox id="o_nbsp_before_punctuation" class="option" data-default="true" label="&tf_nbsp_before_punctuation;" />
                <!--<div class="secondoption">
                  <checkbox id="o_nnbsp_before_punctuation" class="option" />
                  <label="o_nnbsp_before_punctuation" class="opt_lbl smallw">fines<span>sauf avec “:”</span></label>
                </div>-->
                <spacer flex="1" />
                <label id="res_o_nbsp_before_punctuation" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_nbsp_within_quotation_marks" class="option" data-default="true" label="&tf_nbsp_within_quotation_marks;" />
                <!--<div class="secondoption">
                  <checkbox id="o_nnbsp_within_quotation_marks" class="option" />
                  <label="o_nnbsp_within_quotation_marks" class="opt_lbl smallw">fines</label>
                </div>-->
                <spacer flex="1" />
                <label id="res_o_nbsp_within_quotation_marks" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                  <checkbox id="o_nbsp_before_symbol" class="option" data-default="true" label="&tf_nbsp_before_symbol;" />
                  <spacer flex="1" />
                  <label id="res_o_nbsp_before_symbol" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_nbsp_within_numbers" class="option" data-default="true" label="&tf_nbsp_within_numbers;" />
                <!--<div class="secondoption">
                  <checkbox id="o_nnbsp_within_numbers" class="option" />
                  <label="o_nnbsp_within_numbers" class="opt_lbl smallw">fines</label>
                </div>-->
                <spacer flex="1" />
                <label id="res_o_nbsp_within_numbers" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_nbsp_before_units" class="option" data-default="true" label="&tf_nbsp_before_units;" />
                <spacer flex="1" />
                <label id="res_o_nbsp_before_units" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_nbsp_titles" class="option" data-default="true" label="&tf_nbsp_titles;" />
                <spacer flex="1" />
                <label id="res_o_nbsp_titles" class="result" />
              </hbox>
            </vbox>
          </groupbox>

          <!-- Deletions -->
          <groupbox>
            <hbox class="groupbox-title">
              <label class="header"><checkbox id="o_group_delete" class="option optiongroup" data-default="true" label="&tf_delete;" /></label>
            </hbox>
            <vbox id="group_delete" class="groupblock">
              <hbox class="blockopt underline">
                <checkbox id="o_erase_non_breaking_hyphens" class="option" data-default="true" label="&tf_erase_non_breaking_hyphens;" />
                <spacer flex="1" />
                <label id="res_o_erase_non_breaking_hyphens" class="result" />
              </hbox>
            </vbox>
          </groupbox>
        </vbox>

        <vbox class="column" width="400">
          <!-- Typographical signs -->
          <groupbox>
            <hbox class="groupbox-title">
              <label class="header"><checkbox id="o_group_typo" class="option optiongroup" data-default="true" label="&tf_typo;" /></label>
            </hbox>
            <vbox id="group_typo" class="groupblock">
              <hbox class="blockopt underline">
                <checkbox id="o_ts_apostrophe" class="option" data-default="true" label="&tf_ts_apostrophe;" />
                <spacer flex="1" />
                <label id="res_o_ts_apostrophe" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_ts_ellipsis" class="option" data-default="true" label="&tf_ts_ellipsis;" />
                <spacer flex="1" />
                <label id="res_o_ts_ellipsis" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_ts_dash_middle" class="option" data-default="true" label="&tf_ts_dash_middle;" />
                <spacer flex="1" />
                <label id="res_o_ts_dash_middle" class="result" />
              </hbox>
              <hbox class="blockopt">
                <spacer flex="1" />
                <radiogroup orient="horizontal">
                  <radio id="o_ts_m_dash_middle" class="option" data-default="false" label="&tf_emdash;" />
                  <radio id="o_ts_n_dash_middle" class="option" data-default="true" label="&tf_endash;" selected="true" />
                </radiogroup>
                <spacer flex="3" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_ts_dash_start" class="option" data-default="true" label="&tf_ts_dash_start;" />
                <spacer flex="1" />
                <label id="res_o_ts_dash_start" class="result" />
              </hbox>
              <hbox class="blockopt">
                <spacer flex="1" />
                <radiogroup orient="horizontal">
                  <radio id="o_ts_m_dash_start" class="option"  data-default="true" label="&tf_emdash;" selected="true" />
                  <radio id="o_ts_n_dash_start" class="option" data-default="false" label="&tf_endash;" />
                </radiogroup>
                <spacer flex="3" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_ts_quotation_marks" class="option" data-default="true" label="&tf_ts_quotation_marks;" />
                <spacer flex="1" />
                <label id="res_o_ts_quotation_marks" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_ts_units" class="option" data-default="true" label="&tf_ts_units;" />
                <spacer flex="1" />
                <label id="res_o_ts_units" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_ts_spell" class="option" data-default="true" label="&tf_ts_spell;" />
                <spacer flex="1" />
                <label id="res_o_ts_spell" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_ts_ligature" class="option" data-default="false" label="&tf_ts_ligature;" />
                <input type="radio" id="o_ts_ligature_do" name="liga" class="option" data-default="false" label="&tf_ts_ligature_do;" />
                <input type="radio" id="o_ts_ligature_undo" name="liga" class="option" data-default="true" label="&tf_ts_ligature_undo;" />
                <spacer flex="1" />
                <label id="res_o_ts_ligature" class="result" />
              </hbox>
              <hbox class="blockopt">
                <spacer flex="1" />
                <checkbox id="o_ts_ligature_ff" class="option" data-default="true" label="ff" />
                <checkbox id="o_ts_ligature_fi" class="option" data-default="true" label="fi" />
                <checkbox id="o_ts_ligature_ffi" class="option" data-default="true" label="ffi" />
                <checkbox id="o_ts_ligature_fl" class="option" data-default="true" label="fl" />
                <checkbox id="o_ts_ligature_ffl" class="option" data-default="true" label="ffl" />
                <checkbox id="o_ts_ligature_ft" class="option" data-default="true" label="ft" />
                <checkbox id="o_ts_ligature_st" class="option" data-default="false" label="st" />
                <spacer flex="2" />
              </hbox>
            </vbox>
          </groupbox>

          <!-- Misc -->
          <groupbox>
            <hbox class="groupbox-title">
              <label class="header"><checkbox id="o_group_misc" class="option optiongroup" data-default="true" label="&tf_misc;" /></label>
            </hbox>
            <vbox id="group_misc" class="groupblock">
              <hbox class="blockopt underline">
                <checkbox id="o_ordinals_no_exponant" class="option" data-default="true" label="&tf_ordinals_no_exponant;" />
                <checkbox id="o_ordinals_exponant" class="option" data-default="true" label="&tf_ordinals_exponant;" />
                <spacer flex="1" />
                <label id="res_o_ordinals_no_exponant" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_etc" class="option" data-default="true" label="&tf_etc;" />
                <spacer flex="1" />
                <label id="res_o_etc" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_missing_hyphens" class="option" data-default="true" label="&tf_missing_hyphens;" />
                <spacer flex="1" />
                <label id="res_o_missing_hyphens" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_ma_word" class="option" data-default="true" label="&tf_ma_word;" />
                <spacer flex="1" />
                <label id="res_o_ma_word" class="result" />
              </hbox>
              <hbox class="blockopt">
                <spacer flex="1" />
                <checkbox id="o_ma_1letter_lowercase" class="option" label="&tf_ma_1letter_lowercase;" />
                <checkbox id="o_ma_1letter_uppercase" class="option" label="&tf_ma_1letter_uppercase;" />
                <spacer flex="3" />
              </hbox>
            </vbox>
          </groupbox>

          <!-- Restructuration -->
          <!--<groupbox>
            <hbox class="groupbox-title">
              <label class="header"><checkbox id="o_group_struct" class="option optiongroup" data-default="false" label="&tf_struct;" /></label>
            </hbox>
            <vbox id="group_struct" class="groupblock">
              <hbox class="blockopt underline">
                <checkbox id="o_remove_hyphens_at_end_of_paragraphs" class="option" data-default="false" label="&tf_remove_hyphens_at_end_of_paragraphs;" />
                <spacer flex="1" />
                <label id="res_o_remove_hyphens_at_end_of_paragraphs" class="result" />
              </hbox>
              <hbox class="blockopt underline">
                <checkbox id="o_merge_contiguous_paragraphs" class="option" data-default="false" label="&tf_merge_contiguous_paragraphs;" />
                <spacer flex="1" />
                <label id="res_o_merge_contiguous_paragraphs" class="result" />
              </hbox>
            </vbox>
          </groupbox>-->

          <description id="textformatter-infomsg">&tf_infomsg;</description>
        </vbox>
      </hbox>

      <hbox id="textformatter-commands">
        <button id="reset" label="&tf.button.default;" oncommand="oTextFormatter.onReset(event);" />
        <html:progress id="textformatter-progressbar" max="6"></html:progress>
        <label id="textformatter-timer" width="50"></label>
        <button id="apply" label="&tf.button.apply;" oncommand="oTextFormatter.onApply(event);" />
        <button id="close" label="&tf.button.close;" oncommand="oTextFormatter.onClosePanel(event);" />
      </hbox>

    </vbox>


    <!--

      GRAMMAR CHECKING PANEL

    -->
    <splitter id="grammarchecker-splitter" state="collapsed" collapse="after"><grippy /></splitter>

    <vbox id="grammarchecker-panel">
      <div class="dialogheader-title">Grammalecte · &detected_mistakes;</div>
      <div id="grammalecte-errors"/>
      <hbox id="grammalecte-infobox">
        <label id="grammalecte-info" />
        <spacer flex="1" />
        <label id="closebutton" value="Fermer" onclick="oGrammarChecker.onClosePanel(event);" />
      </hbox>
    </vbox>

  </vbox>

</overlay>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































































































































































































































































































































































































































































































































































































































































































Deleted gc_lang/fr/mailext/content/spell_options.css version [377d800f5a].

1
2
3
4
5
6
7
8
9
10
11
12
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
/* CSS */

#grouptitle {
    font-size: 16px;
    font-weight: bold;
    color: hsl(0, 50%, 50%);
}

.option {
    font-size: 16px;
    font-weight: bold;
    color: hsl(210, 50%, 50%);
}

.suboption {
    margin-left: 30px;
    font-size: 16px;
    font-weight: bold;
    color: hsl(210, 50%, 50%);
}
.suboption2 {
    margin-left: 30px;
}

description {
    width: 340px;
}

.dicdescr {
      margin-left: 27px;
}

.disabled {
    opacity: .25;
}


.dialogheader-title {
    margin: 5px;
    padding: 5px 8px;
    border: 1px solid hsl(210, 50%, 80%);
    background-color: hsl(210, 50%, 50%);
    color: hsl(210, 10%, 90%);
    font-size: larger;
    font-weight: bold;
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




























































































Deleted gc_lang/fr/mailext/content/spell_options.js version [d5cdd1e710].

1
2
3
4
5
6
7
8
9
10
11
12
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// JavaScript

"use strict";


const Cc = Components.classes;
const Ci = Components.interfaces;
// const Cu = Components.utils;
const prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).getBranch("extensions.grammarchecker.");


var oDialogControl = {
    load: function () {
        try {
            // center window
            document.getElementById('grammalecte-spelloptions-window').centerWindowOnScreen();
            // main spelling dictionary
            let sMainDicName = prefs.getCharPref('sMainDicName');
            console.log("spelling dictionary:", sMainDicName);
            if (sMainDicName == "fr-classic.json") {
                document.getElementById("classic").checked = true;
            }
            else if (sMainDicName == "fr-reform.json") {
                document.getElementById("reform").checked = true;
            }
            else if (sMainDicName == "fr-allvars.json") {
                document.getElementById("allvars").checked = true;
            }
            // personal dictionary
            document.getElementById('personal_dic').checked = prefs.getBoolPref('bPersonalDictionary');
            // listen
            this.listen();
        }
        catch (e) {
            console.error(e);
        }
    },
    listen: function () {
        document.addEventListener("dialogaccept", (event) => {
            oDialogControl.setDictionaries();
        });
        document.getElementById("classic").addEventListener("click", (event) => {
            oDialogControl.changeMainDicUI("classic");
        });
        document.getElementById("reform").addEventListener("click", (event) => {
            oDialogControl.changeMainDicUI("reform");
        });
        document.getElementById("allvars").addEventListener("click", (event) => {
            oDialogControl.changeMainDicUI("allvars");
        });
    },
    changeMainDicUI (sDic) {
        document.getElementById("classic").checked = ("classic" === sDic);
        document.getElementById("reform").checked = ("reform" === sDic);
        document.getElementById("allvars").checked = ("allvars" === sDic);
    },
    setDictionaries: function () {
        //oSpellControl.init();
        // main spelling dictionary
        let sMainDicName = "";
        if (document.getElementById("classic").checked) {
            sMainDicName = "fr-classic.json";
        }
        else if (document.getElementById("reform").checked) {
            sMainDicName = "fr-reform.json";
        }
        else if (document.getElementById("allvars").checked) {
            sMainDicName = "fr-allvars.json";
        }
        console.log("selected spelling dictionary:", sMainDicName);
        prefs.setCharPref("sMainDicName", sMainDicName);
        // personal dictionary
        let bActivate = document.getElementById('personal_dic').checked;
        prefs.setBoolPref("bPersonalDictionary", bActivate);
    }
};
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































































































Deleted gc_lang/fr/mailext/content/spell_options.xul version [abb535b915].

1
2
3
4
5
6
7
8
9
10
11
12
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://grammarchecker/content/spell_options.css" type="text/css"?>

<!DOCTYPE dialog SYSTEM "chrome://grammarchecker/locale/spell_options.dtd">

<dialog
  id="grammalecte-spelloptions-window"
  title="&window.title;"
  orient="vertical"
  buttons="accept,cancel"
  width="400"
  height="330"
  onload="oDialogControl.load();"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <!-- Other elements go here -->

  <div class="dialogheader-title">&dialogheader.label;</div>

  <hbox>
    <!--
    <groupbox with="380">
      <caption id="grouptitle" label="&grouptitle_hunspell;" />
      <description id="warning">&warning_hunspell;</description>

      <checkbox id="fr-FR-modern" class="option" label="&option.modern.label;" />
      <description class="dicdescr">&option.modern.descr;</description>
      <checkbox id="fr-FR-classic" class="option" label="&option.classic.label;" />
      <description class="dicdescr">&option.classic.descr;</description>
      <checkbox id="fr-FR-reform" class="option" label="&option.reform.label;" />
      <description class="dicdescr">&option.reform.descr;</description>
      <checkbox id="fr-FR-classic-reform" class="option" label="&option.allvar.label;" />
      <description class="dicdescr">&option.allvar.descr;</description>
    </groupbox>
    -->

    <groupbox with="380">
      <caption id="grouptitle" label="&grouptitle_graphspell;" />
      <description id="warning">&warning_graphspell;</description>

      <checkbox id="main_dic" class="option" label="&option.main_dic.label;" disabled="true" checked="true" />
      <description class="dicdescr">&option.main_dic.descr;</description>
      <label class="suboption" value="&option.main_dic.spelling;" />
      <hbox class="suboption2" >
        <checkbox id="classic" label="&option.main_dic.classic;" checked="false" />
        <checkbox id="reform" label="&option.main_dic.reform;" checked="false" />
        <checkbox id="allvars" label="&option.main_dic.allvars;" checked="false" />
      </hbox>
      <!--<radiogroup id="main_dic_name" class="suboption2" orient="horizontal">
        <radio id="classic" label="&option.main_dic.classic;" value="fr-classic.json" />
        <radio id="reform" label="&option.main_dic.reform;" value="fr-reform.json" />
        <radio id="allvars" label="&option.main_dic.allvars;" value="fr-allvars.json" />
      </radiogroup>-->

      <checkbox id="community_dic" class="option disabled" label="&option.community_dic.label;" disabled="true" />
      <description class="dicdescr disabled">&option.community_dic.descr;</description>

      <checkbox id="personal_dic" class="option" label="&option.personal_dic.label;" />
      <description class="dicdescr">&option.personal_dic.descr;</description>
    </groupbox>
  </hbox>

  <script type="application/javascript" src="spell_options.js"/>
  <script type="application/javascript" src="spellchecker.js"/>

</dialog>
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<






































































































































Deleted gc_lang/fr/mailext/content/spellchecker.js version [ca575ac13b].

1
2
3
4
5
6
7
8
9
10
11
12
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
48
49
50
51
52
53
54
55
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
84
85
86
87
88
89
90
91
92
93
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// JavaScript

/*
    Hunspell wrapper

    XPCOM obsolete (?), but there is nothing else...
    Overly complicated and weird. To throw away ASAP if possible.

    And you can’t access to this from a PromiseWorker (it sucks).

    https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/mozISpellCheckingEngine
    https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Using_spell_checking_in_XUL
    https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFile
    https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/FileUtils.jsm
*/

"use strict";


const { FileUtils } = ChromeUtils.import("resource://gre/modules/FileUtils.jsm");
const { AddonManager } = ChromeUtils.import("resource://gre/modules/AddonManager.jsm");


var oSpellControl = {
    xSCEngine: null,
    init: function () {
        if (this.xSCEngine === null) {
            try {
                let sSpellchecker = "@mozilla.org/spellchecker/myspell;1";
                if ("@mozilla.org/spellchecker/hunspell;1" in Cc) {
                    sSpellchecker = "@mozilla.org/spellchecker/hunspell;1";
                }
                if ("@mozilla.org/spellchecker/engine;1" in Cc) {
                    sSpellchecker = "@mozilla.org/spellchecker/engine;1";
                }
                this.xSCEngine = Cc[sSpellchecker].getService(Ci.mozISpellCheckingEngine);
            }
            catch (e) {
                console.log("Can’t initiate the spellchecker.");
                console.error(e);
            }
        }
    },
    getDictionariesList: function () {
        this.init();
        try {
            let l = {};
            let c = {};
            this.xSCEngine.getDictionaryList(l, c);
            return l.value;
        }
        catch (e) {
            console.error(e);
            return [];
        }
    },
    setDictionary: function (sLocale) {
        if (this.getDictionariesList().includes(sLocale)) {
            try {
                this.xSCEngine.dictionary = sLocale; // en-US, fr, etc.
                return true;
            }
            catch (e) {
                console.error(e);
                return false;
            }
        } else {
            console.log("Warning. No dictionary for locale: " + sLocale);
            console.log("Existing dictionaries: " + this.getDictionariesList().join(" | "));
        }
        return false;
    },
    check: function (sWord) {
        // todo: check in personal dict?
        try {
            return this.xSCEngine.check(sWord);
        }
        catch (e) {
            console.error(e);
            return false;
        }
    },
    suggest: function (sWord) {
        try {
            let lSugg = {};
            this.xSCEngine.suggest(sWord, lSugg, {});
            return lSugg.value;
            // lSugg.value is a JavaScript Array of strings
        }
        catch (e) {
            console.error(e);
            return ['#Erreur.'];
        }
    },
    addDirectory: function (sFolder) {
        try {
            let xNsiFolder = new FileUtils.File(sFolder);
            this.xSCEngine.addDirectory(xNsiFolder);
        }
        catch (e) {
            console.log("Unable to add directory: " + sFolder);
            console.error(e);
        }
    },
    removeDirectory: function (sFolder) {
        // does not work but no exception raised (bug?)
        try {
            let xNsiFolder = new FileUtils.File(sFolder);
            this.xSCEngine.removeDirectory(xNsiFolder);
        }
        catch (e) {
            console.log("Unable to remove directory: " + sFolder);
            console.error(e);
        }
    },
    setExtensionDictFolder: function (sDictName, bActivate) {
        try {
            let that = this;
            let sPath = "/content/dictionaries/" + sDictName;
            AddonManager.getAddonByID("French-GC-TB@grammalecte.net")
            .then(function (xAddon) {
                let xURI = xAddon.getResourceURI(sPath);
                //console.log(xURI);
                let sFolder = xURI.filePath;
                if (sFolder !== undefined) {
                    if (/^\/[A-Z]:\//.test(sFolder)) {
                        // Windows path
                        sFolder = sFolder.slice(1).replace(/\//g, "\\\\");
                    }
                    console.log("folder: " + sFolder);
                    if (bActivate) {
                        that.addDirectory(sFolder);
                    } else {
                        that.removeDirectory(sFolder);
                    }
                }
            });
        }
        catch (e) {
            console.log("Unable to add extension folder");
            console.error(e);
        }
    }
};
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
































































































































































































































































































Deleted gc_lang/fr/mailext/defaults/preferences/grammarchecker.js version [8769787af8].

1
2
3
4
5
6
7
8
9
10
pref("extensions.grammarchecker.sGCOptions", "");
pref("extensions.grammarchecker.sTFOptions", "");
pref("extensions.grammarchecker.bDictModern", false);
pref("extensions.grammarchecker.bDictClassic", true);
pref("extensions.grammarchecker.bDictReform", false);
pref("extensions.grammarchecker.bDictClassicReform", false);
pref("extensions.grammarchecker.bCheckSignature", true);
pref("extensions.grammarchecker.sMainDicName", "fr-allvars.json");
pref("extensions.grammarchecker.bCommunityDictionary", false);
pref("extensions.grammarchecker.bPersonalDictionary", true);
<
<
<
<
<
<
<
<
<
<




















Deleted gc_lang/fr/mailext/gce_worker.js version [946a66a85a].

1
2
3
4
5
6
7
8
9
10
11
12
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
48
49
50
51
52
53
54
55
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
84
85
86
87
88
89
90
91
92
93
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
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
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
/*
    WORKER:
    https://developer.mozilla.org/en-US/docs/Web/API/Worker
    https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope


    JavaScript sucks.
    No module available in WebExtension at the moment! :(
    No require, no import/export.

    In Worker, we have importScripts() which imports everything in this scope.

    In order to use the same base of code with XUL-addon for Thunderbird and SDK-addon for Firefox,
    all modules have been “objectified”. And while they are still imported via “require”
    in the previous extensions, they are loaded as background scripts in WebExtension sharing
    the same memory space…

    When JavaScript become a modern language, “deobjectify” the modules…

    ATM, import/export are not available by default:
    — Chrome 60 – behind the Experimental Web Platform flag in chrome:flags.
    — Firefox 54 – behind the dom.moduleScripts.enabled setting in about:config.
    — Edge 15 – behind the Experimental JavaScript Features setting in about:flags.

    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(self);

importScripts("grammalecte/graphspell/helpers.js");
importScripts("grammalecte/graphspell/str_transform.js");
importScripts("grammalecte/graphspell/char_player.js");
importScripts("grammalecte/graphspell/suggest.js");
importScripts("grammalecte/graphspell/ibdawg.js");
importScripts("grammalecte/graphspell/spellchecker.js");
importScripts("grammalecte/text.js");
importScripts("grammalecte/graphspell/tokenizer.js");
importScripts("grammalecte/fr/conj.js");
importScripts("grammalecte/fr/mfsp.js");
importScripts("grammalecte/fr/phonet.js");
importScripts("grammalecte/fr/cregex.js");
importScripts("grammalecte/fr/gc_options.js");
importScripts("grammalecte/fr/gc_rules.js");
importScripts("grammalecte/fr/gc_rules_graph.js");
importScripts("grammalecte/fr/gc_engine.js");
importScripts("grammalecte/fr/lexicographe.js");
importScripts("grammalecte/tests.js");
/*
    Warning.
    Initialization can’t be completed at startup of the worker,
    for we need the path of the extension to load data stored in JSON files.
    This path is retrieved in background.js and passed with the event “init”.
*/


function createResponse (sActionDone, result, oInfo, bEnd, bError=false) {
    return {
        "sActionDone": sActionDone,
        "result": result, // can be of any type
        "oInfo": oInfo,
        "bEnd": bEnd,
        "bError": bError
    };
}

function createErrorResult (e, sDescr="no description") {
    return {
        "sType": "error",
        "sDescription": sDescr,
        "sMessage": e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message
    };
}

function showData (e) {
    for (let sParam in e) {
        console.log(sParam);
        console.log(e[sParam]);
    }
}


/*
    Message Event Object
    https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent
*/
onmessage = function (e) {
    let {sCommand, oParam, oInfo} = e.data;
    switch (sCommand) {
        case "init":
            init(oParam.sExtensionPath, oParam.dOptions, oParam.sContext, oInfo);
            break;
        case "parse":
            parse(oParam.sText, oParam.sCountry, oParam.bDebug, oParam.bContext, oInfo);
            break;
        case "parseAndSpellcheck":
            parseAndSpellcheck(oParam.sText, oParam.sCountry, oParam.bDebug, oParam.bContext, oInfo);
            break;
        case "parseAndSpellcheck1":
            parseAndSpellcheck1(oParam.sText, oParam.sCountry, oParam.bDebug, oParam.bContext, oInfo);
            break;
        case "parseFull":
            parseFull(oParam.sText, oParam.sCountry, oParam.bDebug, oParam.bContext, oInfo);
            break;
        case "getListOfTokens":
            getListOfTokens(oParam.sText, oInfo);
            break;
        case "getOptions":
            getOptions(oInfo);
            break;
        case "getDefaultOptions":
            getDefaultOptions(oInfo);
            break;
        case "setOptions":
            setOptions(oParam.sOptions, oInfo);
            break;
        case "setOption":
            setOption(oParam.sOptName, oParam.bValue, oInfo);
            break;
        case "resetOptions":
            resetOptions(oInfo);
            break;
        case "textToTest":
            textToTest(oParam.sText, oParam.sCountry, oParam.bDebug, oParam.bContext, oInfo);
            break;
        case "fullTests":
            fullTests(oInfo);
            break;
        case "setDictionary":
            setDictionary(oParam.sDictionary, oParam.oDict, oInfo);
            break;
        case "setDictionaryOnOff":
            setDictionaryOnOff(oParam.sDictionary, oParam.bActivate, oInfo);
            break;
        case "getSpellSuggestions":
            getSpellSuggestions(oParam.sWord, oInfo);
            break;
        case "getVerb":
            getVerb(oParam.sVerb, oParam.bPro, oParam.bNeg, oParam.bTpsCo, oParam.bInt, oParam.bFem, oInfo);
            break;
        default:
            console.log("[Worker] Unknown command: " + sCommand);
            showData(e.data);
    }
}



let bInitDone = false;

let oSpellChecker = null;
let oTokenizer = null;
let oLxg = null;
let oTest = null;
let oLocution = null;


/*
    Technical note:
    This worker don’t work as a PromiseWorker (which returns a promise),  so when we send request
    to this worker, we can’t wait the return of the answer just after the request made.
    The answer is received by the background in another function (onmessage).
    That’s why the full text to analyze is send in one block, but analyse is returned paragraph
    by paragraph.
*/

function init (sExtensionPath, dOptions=null, sContext="JavaScript", oInfo={}) {
    try {
        if (!bInitDone) {
            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…");
            gc_engine.load(sContext, "sCSS", 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) {
                if (!(dOptions instanceof Map)) {
                    dOptions = helpers.objectToMap(dOptions);
                }
                gc_engine.setOptions(dOptions);
            }
            //tests();
            bInitDone = true;
        } else {
            console.log("[Worker] Already initialized…")
        }
        // we always retrieve options from the gc_engine, for setOptions filters obsolete options
        dOptions = helpers.mapToObject(gc_engine.getOptions());
        postMessage(createResponse("init", dOptions, oInfo, true));
    }
    catch (e) {
        console.error(e);
        postMessage(createResponse("init", createErrorResult(e, "init failed"), oInfo, true, true));
    }
}


function parse (sText, sCountry, bDebug, bContext, oInfo={}) {
    sText = sText.replace(/­/g, "").normalize("NFC");
    for (let sParagraph of text.getParagraph(sText)) {
        let aGrammErr = gc_engine.parse(sParagraph, sCountry, bDebug, bContext);
        postMessage(createResponse("parse", aGrammErr, oInfo, false));
    }
    postMessage(createResponse("parse", null, oInfo, true));
}

function parseAndSpellcheck (sText, sCountry, bDebug, bContext, oInfo={}) {
    let i = 0;
    sText = sText.replace(/­/g, "").normalize("NFC");
    for (let sParagraph of text.getParagraph(sText)) {
        let aGrammErr = gc_engine.parse(sParagraph, sCountry, bDebug, null, bContext);
        let aSpellErr = oSpellChecker.parseParagraph(sParagraph);
        postMessage(createResponse("parseAndSpellcheck", {sParagraph: sParagraph, iParaNum: i, aGrammErr: aGrammErr, aSpellErr: aSpellErr}, oInfo, false));
        i += 1;
    }
    postMessage(createResponse("parseAndSpellcheck", null, oInfo, true));
}

function parseAndSpellcheck1 (sParagraph, sCountry, bDebug, bContext, oInfo={}) {
    sParagraph = sParagraph.replace(/­/g, "").normalize("NFC");
    let aGrammErr = gc_engine.parse(sParagraph, sCountry, bDebug, null, bContext);
    let aSpellErr = oSpellChecker.parseParagraph(sParagraph);
    postMessage(createResponse("parseAndSpellcheck1", {sParagraph: sParagraph, aGrammErr: aGrammErr, aSpellErr: aSpellErr}, oInfo, true));
}

function parseFull (sText, sCountry, bDebug, bContext, oInfo={}) {
    let i = 0;
    sText = sText.replace(/­/g, "").normalize("NFC");
    for (let sParagraph of text.getParagraph(sText)) {
        let lSentence = gc_engine.parse(sParagraph, sCountry, bDebug, null, bContext, true);
        console.log("*", lSentence);
        postMessage(createResponse("parseFull", {sParagraph: sParagraph, iParaNum: i, lSentence: lSentence}, oInfo, false));
        i += 1;
    }
    postMessage(createResponse("parseFull", null, oInfo, true));
}

function getListOfTokens (sText, oInfo={}) {
    // lexicographer
    try {
        sText = sText.replace(/­/g, "").normalize("NFC");
        for (let sParagraph of text.getParagraph(sText)) {
            if (sParagraph.trim() !== "") {
                postMessage(createResponse("getListOfTokens", oLxg.getListOfTokensReduc(sParagraph, true), oInfo, false));
            }
        }
        postMessage(createResponse("getListOfTokens", null, oInfo, true));
    }
    catch (e) {
        console.error(e);
        postMessage(createResponse("getListOfTokens", createErrorResult(e, "no tokens"), oInfo, true, true));
    }
}

function getOptions (oInfo={}) {
    let dOptions = helpers.mapToObject(gc_engine.getOptions());
    postMessage(createResponse("getOptions", dOptions, oInfo, true));
}

function getDefaultOptions (oInfo={}) {
    let dOptions = helpers.mapToObject(gc_engine.getDefaultOptions());
    postMessage(createResponse("getDefaultOptions", dOptions, oInfo, true));
}

function setOptions (dOptions, oInfo={}) {
    if (!(dOptions instanceof Map)) {
        dOptions = helpers.objectToMap(dOptions);
    }
    gc_engine.setOptions(dOptions);
    dOptions = helpers.mapToObject(gc_engine.getOptions());
    postMessage(createResponse("setOptions", dOptions, oInfo, true));
}

function setOption (sOptName, bValue, oInfo={}) {
    console.log(sOptName+": "+bValue);
    if (sOptName) {
        gc_engine.setOption(sOptName, bValue);
        let dOptions = helpers.mapToObject(gc_engine.getOptions());
        postMessage(createResponse("setOption", dOptions, oInfo, true));
    }
}

function resetOptions (oInfo={}) {
    gc_engine.resetOptions();
    let dOptions = helpers.mapToObject(gc_engine.getOptions());
    postMessage(createResponse("resetOptions", dOptions, oInfo, true));
}

function tests () {
    console.log(conj.getConj("devenir", ":E", ":2s"));
    console.log(mfsp.getMasForm("emmerdeuse", true));
    console.log(mfsp.getMasForm("pointilleuse", false));
    console.log(phonet.getSimil("est"));
    let aRes = gc_engine.parse("Je suit...");
    for (let oErr of aRes) {
        console.log(text.getReadableError(oErr));
    }
}

function textToTest (sText, sCountry, bDebug, bContext, oInfo={}) {
    if (!gc_engine) {
        postMessage(createResponse("textToTest", "# Grammar checker not loaded.", oInfo, true));
        return;
    }
    sText = sText.replace(/­/g, "").normalize("NFC");
    let aGrammErr = gc_engine.parse(sText, sCountry, bDebug, bContext);
    let sMsg = "";
    for (let oErr of aGrammErr) {
        sMsg += text.getReadableError(oErr) + "\n";
    }
    if (sMsg == "") {
        sMsg =  "Aucune erreur détectée.";
    }
    postMessage(createResponse("textToTest", sMsg, oInfo, true));
}

function fullTests (oInfo={}) {
    if (!gc_engine) {
        postMessage(createResponse("fullTests", "# Grammar checker not loaded.", oInfo, true));
        return;
    }
    let dMemoOptions = gc_engine.getOptions();
    let dTestOptions = gc_engine.getDefaultOptions();
    dTestOptions.set("nbsp", true);
    dTestOptions.set("esp", true);
    dTestOptions.set("unit", true);
    dTestOptions.set("num", true);
    gc_engine.setOptions(dTestOptions);
    let sMsg = "";
    for (let sRes of oTest.testParse()) {
        sMsg += sRes + "\n";
        console.log(sRes);
    }
    gc_engine.setOptions(dMemoOptions);
    postMessage(createResponse("fullTests", sMsg, oInfo, true));
}


// SpellChecker

function setDictionary (sDictionary, oDict, oInfo) {
    if (!oSpellChecker) {
        postMessage(createResponse("setDictionary", "# Error. SpellChecker not loaded.", oInfo, true));
        return;
    }
    //console.log("setDictionary", sDictionary);
    switch (sDictionary) {
        case "main":
            oSpellChecker.setMainDictionary(oDict, oInfo["sExtPath"]+"/grammalecte/graphspell/_dictionaries");
            break;
        case "community":
            oSpellChecker.setCommunityDictionary(oDict);
            break;
        case "personal":
            oSpellChecker.setPersonalDictionary(oDict);
            break;
        default:
            console.log("[worker] setDictionary: Unknown dictionary <"+sDictionary+">");
    }
    postMessage(createResponse("setDictionary", true, oInfo, true));
}

function setDictionaryOnOff (sDictionary, bActivate, oInfo) {
    if (!oSpellChecker) {
        postMessage(createResponse("setDictionary", "# Error. SpellChecker not loaded.", oInfo, true));
        return;
    }
    //console.log("setDictionaryOnOff", sDictionary, bActivate);
    switch (sDictionary) {
        case "community":
            if (bActivate) {
                oSpellChecker.activateCommunityDictionary();
            } else {
                oSpellChecker.deactivateCommunityDictionary();
            }
            break;
        case "personal":
            if (bActivate) {
                oSpellChecker.activatePersonalDictionary();
            } else {
                oSpellChecker.deactivatePersonalDictionary();
            }
            break;
        default:
            console.log("[worker] setDictionaryOnOff: Unknown dictionary <"+sDictionary+">");
    }
    postMessage(createResponse("setDictionaryOnOff", true, oInfo, true));
}

function getSpellSuggestions (sWord, oInfo) {
    if (!oSpellChecker) {
        postMessage(createResponse("getSpellSuggestions", "# Error. SpellChecker not loaded.", oInfo, true));
        return;
    }
    let i = 0;
    for (let aSugg of oSpellChecker.suggest(sWord)) {
        postMessage(createResponse("getSpellSuggestions", {sWord: sWord, aSugg: aSugg, iSuggBlock: i}, oInfo, true));
        i += 1;
    }
}


// Conjugueur

function getVerb (sWord, bPro, bNeg, bTpsCo, bInt, bFem, oInfo) {
    try {
        let oVerb = null;
        let oConjTable = null;
        if (conj.isVerb(sWord)) {
            oVerb = new Verb(sWord);
            oConjTable = oVerb.createConjTable(bPro, bNeg, bTpsCo, bInt, bFem);
        }
        postMessage(createResponse("getVerb", { oVerb: oVerb, oConjTable: oConjTable }, oInfo, true));
    }
    catch (e) {
        console.error(e);
        postMessage(createResponse("getVerb", createErrorResult(e, "no verb"), oInfo, true, true));
    }
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































































































































































































































































































































































































































































































































































































































































































































































































































































Deleted gc_lang/fr/mailext/icon.png version [9598be5e3c].

cannot compute difference between binary files

Deleted gc_lang/fr/mailext/locale/en/about.dtd version [586b114cab].

1
2
3
4
5
6
7
<!ENTITY windowtitle "About Grammalecte">
<!ENTITY description1 "French">
<!ENTITY description2 "Grammar Checker">
<!ENTITY version "Version:">
<!ENTITY license "License:">
<!ENTITY thanks "Thanks to">
<!ENTITY contrib "and those who supported us…">
<
<
<
<
<
<
<














Deleted gc_lang/fr/mailext/locale/en/gc_options.dtd version [6feaf76b9e].

1
2
3
4
<!ENTITY window.title "Grammalecte · Grammar options">
<!ENTITY defaultbutton.label "Default">
<!ENTITY dialogheader.label "Grammar options">
${gc_options_labels_en}
<
<
<
<








Deleted gc_lang/fr/mailext/locale/en/grammarchecker.properties version [ef0da976ea].

1
2
3
processingMessage=Parsing in progress…
errorMessage=Error…
noErrorMessage=No error detected.
<
<
<






Deleted gc_lang/fr/mailext/locale/en/lex_editor.dtd version [d8b06fdebc].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!ENTITY window.title "Grammalecte · Lexical editor lexical">

<!ENTITY button.cancel.label "Close">

<!ENTITY tab.editor.label "Add">
<!ENTITY tab.lexicon.label "Lexicon">
<!ENTITY tab.search.label "Search">
<!ENTITY tab.info.label "Informations">

<!ENTITY dialogheader.newword.label "New word (lemma)">
<!ENTITY dialogheader.generated_words.label "Generated words">
<!ENTITY dialogheader.lexicon.label "Your lexicon">
<!ENTITY dialogheader.search.similar.label "Similar spellings">
<!ENTITY dialogheader.search.regex.label "Regular expressions">
<!ENTITY dialogheader.search.result.label "Result">
<!ENTITY dialogheader.info.label "Informations">
<!ENTITY dialogheader.tags.label "Meaning of tags">
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































Deleted gc_lang/fr/mailext/locale/en/options.dtd version [5fe56718ba].

1
2
3
4
5
6
<!ENTITY window.title "Grammalecte · Options">
<!ENTITY dialogheader.label "Other options">
<!ENTITY check_signature.label "Check signature text (in text mode)">
<!ENTITY check_signature.accesskey "C">


<
<
<
<
<
<












Deleted gc_lang/fr/mailext/locale/en/overlay.dtd version [1e54ceb89b].

1
2
3
4
5
6
7
8
9
10
11
12
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!ENTITY grammarchecker.button.label "Grammar">
<!ENTITY grammarchecker.accesskey "G">
<!ENTITY grammarchecker.tooltip "Grammar checking">

<!ENTITY grammalectemenu.textformatter "Text formatter…">
<!ENTITY grammalectemenu.conjugueur "Conjugation tool…">
<!ENTITY grammalectemenu.start "Proofread the text…">
<!ENTITY grammalectemenu.spell_options "Spelling options…">
<!ENTITY grammalectemenu.gc_options "Grammar options…">
<!ENTITY grammalectemenu.lexicon_editor "Lexical editor…">
<!ENTITY grammalectemenu.other_options "Other options…">
<!ENTITY grammalectemenu.about "About Grammalecte…">

<!ENTITY detected_mistakes "Detected mistakes">

<!ENTITY textformatter "Text Formatter">
<!ENTITY automated_replacements "Automated replacements">
<!ENTITY tf.button.default "Default">
<!ENTITY tf.button.apply "Apply">
<!ENTITY tf.button.close "Close">

<!ENTITY tf_title "Text Formatter">
<!ENTITY tf_ssp "Supernumerary spaces">
<!ENTITY tf_start_of_paragraph "At the beginning of paragraph">
<!ENTITY tf_between_words "Between words">
<!ENTITY tf_end_of_paragraph "At the end of paragraph">
<!ENTITY tf_before_punctuation "Before dots (.), commas (,)">
<!ENTITY tf_within_parenthesis "Within parenthesis">
<!ENTITY tf_within_square_brackets "Within square brackets">
<!ENTITY tf_within_quotation_marks "Within “ and ”">
<!ENTITY tf_space "Missing spaces">
<!ENTITY tf_add_space_after_punctuation "After , ; : ? ! . …">
<!ENTITY tf_add_space_around_hyphens "Surrounding dashes">
<!ENTITY tf_nbsp "Non breaking spaces">
<!ENTITY tf_nbsp_before_punctuation "Before : ; ? and !">
<!ENTITY tf_nbsp_within_quotation_marks "With quoting marks « and »">
<!ENTITY tf_nbsp_before_symbol "Before &#x0025; ‰ € $ £ ¥ ˚C">
<!ENTITY tf_nbsp_within_numbers "Within numbers">
<!ENTITY tf_nbsp_before_units "Before units of measurement">
<!ENTITY tf_nbsp_titles "After titles">
<!ENTITY tf_delete "Deletions">
<!ENTITY tf_erase_non_breaking_hyphens "Soft hyphens">
<!ENTITY tf_typo "Typographical signs">
<!ENTITY tf_ts_apostrophe "Apostrophe (’)">
<!ENTITY tf_ts_ellipsis "Ellipsis (…)">
<!ENTITY tf_ts_dash_middle "Dashes:">
<!ENTITY tf_ts_dash_start "Dashes at beginning of paragraph:">
<!ENTITY tf_emdash "em dash (—)">
<!ENTITY tf_endash "en dash (–)">
<!ENTITY tf_ts_quotation_marks "Change quotation marks  (&quot; and ')">
<!ENTITY tf_ts_units "Interpuncts in units (N·m, Ω·m…)">
<!ENTITY tf_ts_spell "Ligatures (cœur…) and diacritics (ça, État…)">
<!ENTITY tf_ts_ligature "Ligatures">
<!ENTITY tf_ts_ligature_do "Set">
<!ENTITY tf_ts_ligature_undo "Unset">
<!ENTITY tf_misc "Miscellaneous">
<!ENTITY tf_ordinals_no_exponant "Ordinals (15e, XXIe…)">
<!ENTITY tf_ordinals_exponant "e → ᵉ">
<!ENTITY tf_etc "Et cætera, etc.">
<!ENTITY tf_missing_hyphens "Missing hyphens">
<!ENTITY tf_ma_word "Missing apostrophes">
<!ENTITY tf_ma_1letter_lowercase "single letters (j’ n’ m’ t’ s’ c’ d’ l’)">
<!ENTITY tf_ma_1letter_uppercase "Cap.">
<!ENTITY tf_struct "Restructuration [!]">
<!ENTITY tf_remove_hyphens_at_end_of_paragraphs "Remove syllabification hyphens at EOL/EOP">
<!ENTITY tf_merge_contiguous_paragraphs "Merge contiguous paragraphs [!]">
<!ENTITY tf_apply "Apply">
<!ENTITY tf_default "Default">
<!ENTITY tf_close "Close">
<!ENTITY tf_infomsg "The text formatter is a tool which automates correction of typographical errors. Use this tool with caution. Check your text after use. If you write in HTML mode, the use of this module is at your own risk.">
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































Deleted gc_lang/fr/mailext/locale/en/spell_options.dtd version [fc8174b93b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!ENTITY window.title "Grammalecte · Spelling options">
<!ENTITY dialogheader.label "Spelling options">

<!ENTITY grouptitle_graphspell "Graphspell Dictionaries (Grammalecte)">
<!ENTITY warning_graphspell "These dictionaries are used only when analyzing texts.">
<!ENTITY option.main_dic.label "Main dictionary">
<!ENTITY option.main_dic.descr "About 83 000 entries, 500 000 flexions. Not editable, not deactivable.">
<!ENTITY option.main_dic.spelling "Spelling">
<!ENTITY option.main_dic.classic "Classic">
<!ENTITY option.main_dic.reform "Reform 1990">
<!ENTITY option.main_dic.allvars "All variants">
<!ENTITY option.community_dic.label "Community dictionary">
<!ENTITY option.community_dic.descr "Feature to come..">
<!ENTITY option.personal_dic.label "Personal dictionary">
<!ENTITY option.personal_dic.descr "The personal dictionary is created and edited via the lexicon editor.">

<!ENTITY grouptitle_hunspell "Hunspell Dictionaries (Thunderbird)">
<!ENTITY warning_hunspell "These dictionaries are only used when you are writing texts (red underlining). Select dictionaries you want to see in textareas list. Selected dictionaries are added instantly. Whereas unselected dictionnaries will be removed only at Thunderbird’s restart.">
<!ENTITY option.modern.label "“Modern”">
<!ENTITY option.modern.descr "This dictionary offers the French spelling as it is written nowadays most often. This is the recommended dictionary if French is not your mother tongue or if you want only one correct spelling per word.">
<!ENTITY option.classic.label "“Classic” (recommanded)">
<!ENTITY option.classic.descr "This is the “Modern” dictionary plus classical spellings, some of them still widely used, others obsolete. This is the recommended dictionary if French is your native language.">
<!ENTITY option.reform.label "“Reform 1990”">
<!ENTITY option.reform.descr "With this dictionary, only the reformed spelling is recognized. As many of reformed spellings are considered erroneous for many people, this dictionary is unadvised. Reformed spellings commonly used are already included in the “Modern” dictionary.">
<!ENTITY option.allvar.label "“All variants”">
<!ENTITY option.allvar.descr "This dictionary contains all spelling variants, classical and reformed, and some others even rarer. This dictionary is unadvised for those who don’t know very well the French language.">


<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
























































Deleted gc_lang/fr/mailext/locale/fr/about.dtd version [4705e2f2e0].

1
2
3
4
5
6
7
<!ENTITY windowtitle "À propos de Grammalecte">
<!ENTITY description1 "Correcteur grammatical">
<!ENTITY description2 "pour le français">
<!ENTITY version "Version :">
<!ENTITY license "Licence :">
<!ENTITY thanks "Avec le soutien de">
<!ENTITY contrib "et de nombreux contributeurs…">
<
<
<
<
<
<
<














Deleted gc_lang/fr/mailext/locale/fr/gc_options.dtd version [aa14ca951b].

1
2
3
4
<!ENTITY window.title "Grammalecte · Options grammaticales">
<!ENTITY defaultbutton.label "Par défaut">
<!ENTITY dialogheader.label "Options grammaticales">
${gc_options_labels_fr}
<
<
<
<








Deleted gc_lang/fr/mailext/locale/fr/grammarchecker.properties version [e42689d6bb].

1
2
3
processingMessage=Analyse en cours
errorMessage=Erreur…
noErrorMessage=Aucune erreur détectée.
<
<
<






Deleted gc_lang/fr/mailext/locale/fr/lex_editor.dtd version [6b48b9e817].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!ENTITY window.title "Grammalecte · Éditeur lexical">

<!ENTITY button.cancel.label "Fermer">

<!ENTITY tab.editor.label "Ajout">
<!ENTITY tab.lexicon.label "Lexique">
<!ENTITY tab.search.label "Recherche">
<!ENTITY tab.info.label "Informations">

<!ENTITY dialogheader.newword.label "Nouveau mot (lemme)">
<!ENTITY dialogheader.generated_words.label "Mots générés">
<!ENTITY dialogheader.lexicon.label "Votre lexique">
<!ENTITY dialogheader.search.similar.label "Graphies similaires">
<!ENTITY dialogheader.search.regex.label "Expressions régulières">
<!ENTITY dialogheader.search.result.label "Résultat">
<!ENTITY dialogheader.info.label "Informations">
<!ENTITY dialogheader.tags.label "Signification des étiquettes">

<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




































Deleted gc_lang/fr/mailext/locale/fr/options.dtd version [37a043f079].

1
2
3
4
<!ENTITY window.title "Grammalecte · Options">
<!ENTITY dialogheader.label "Autres options">
<!ENTITY check_signature.label "Vérifier le texte de la signature (en mode texte)">
<!ENTITY check_signature.accesskey "V">
<
<
<
<








Deleted gc_lang/fr/mailext/locale/fr/overlay.dtd version [93a8ef80c4].

1
2
3
4
5
6
7
8
9
10
11
12
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!ENTITY grammarchecker.button.label "Grammaire">
<!ENTITY grammarchecker.accesskey "G">
<!ENTITY grammarchecker.tooltip "Correction grammaticale">

<!ENTITY grammalectemenu.textformatter "Formateur de texte…">
<!ENTITY grammalectemenu.conjugueur "Conjugueur…">
<!ENTITY grammalectemenu.start "Analyser le texte…">
<!ENTITY grammalectemenu.spell_options "Options orthographiques…">
<!ENTITY grammalectemenu.gc_options "Options grammaticales…">
<!ENTITY grammalectemenu.lexicon_editor "Éditeur lexical…">
<!ENTITY grammalectemenu.other_options "Autres options…">
<!ENTITY grammalectemenu.about "À propos de Grammalecte…">

<!ENTITY detected_mistakes "Erreurs détectées">

<!ENTITY textformatter "Formateur de texte">
<!ENTITY automated_replacements "Remplacements automatisés">
<!ENTITY tf.button.default "Par défaut">
<!ENTITY tf.button.apply "Appliquer">
<!ENTITY tf.button.close "Fermer">

<!ENTITY tf_title "Formateur de texte">
<!ENTITY tf_ssp "Espaces surnuméraires">
<!ENTITY tf_start_of_paragraph "En début de paragraphe">
<!ENTITY tf_between_words "Entre les mots">
<!ENTITY tf_end_of_paragraph "En fin de paragraphe">
<!ENTITY tf_before_punctuation "Avant les points (.), les virgules (,)">
<!ENTITY tf_within_parenthesis "À l’intérieur des parenthèses">
<!ENTITY tf_within_square_brackets "À l’intérieur des crochets">
<!ENTITY tf_within_quotation_marks "À l’intérieur des guillemets “ et ”">
<!ENTITY tf_space "Espaces manquants">
<!ENTITY tf_add_space_after_punctuation "Après , ; : ? ! . …">
<!ENTITY tf_add_space_around_hyphens "Autour des tirets d’incise">
<!ENTITY tf_nbsp "Espaces insécables">
<!ENTITY tf_nbsp_before_punctuation "Avant : ; ? et !">
<!ENTITY tf_nbsp_within_quotation_marks "Avec les guillemets « et »">
<!ENTITY tf_nbsp_before_symbol "Avant &#x0025; ‰ € $ £ ¥ ˚C">
<!ENTITY tf_nbsp_within_numbers "À l’intérieur des nombres">
<!ENTITY tf_nbsp_before_units "Avant les unités de mesure">
<!ENTITY tf_nbsp_titles "Après les titres de civilité">
<!ENTITY tf_delete "Suppressions">
<!ENTITY tf_erase_non_breaking_hyphens "Tirets conditionnels">
<!ENTITY tf_typo "Signes typographiques">
<!ENTITY tf_ts_apostrophe "Apostrophe (’)">
<!ENTITY tf_ts_ellipsis "Points de suspension (…)">
<!ENTITY tf_ts_dash_middle "Tirets d’incise :">
<!ENTITY tf_ts_dash_start "Tirets en début de paragraphe :">
<!ENTITY tf_emdash "cadratin (—)">
<!ENTITY tf_endash "demi-cadratin (–)">
<!ENTITY tf_ts_quotation_marks "Modifier les guillemets droits (&quot; et ')">
<!ENTITY tf_ts_units "Points médians des unités (N·m, Ω·m…)">
<!ENTITY tf_ts_spell "Ligatures (cœur…) et diacritiques (ça, État…)">
<!ENTITY tf_ts_ligature "Ligatures">
<!ENTITY tf_ts_ligature_do "Faire">
<!ENTITY tf_ts_ligature_undo "Défaire">
<!ENTITY tf_misc "Divers">
<!ENTITY tf_ordinals_no_exponant "Ordinaux (15e, XXIe…)">
<!ENTITY tf_ordinals_exponant "e → ᵉ">
<!ENTITY tf_etc "Et cætera, etc.">
<!ENTITY tf_missing_hyphens "Traits d’union manquants">
<!ENTITY tf_ma_word "Apostrophes manquantes">
<!ENTITY tf_ma_1letter_lowercase "lettres isolées (j’ n’ m’ t’ s’ c’ d’ l’)">
<!ENTITY tf_ma_1letter_uppercase "Maj.">
<!ENTITY tf_struct "Restructuration [!]">
<!ENTITY tf_remove_hyphens_at_end_of_paragraphs "Enlever césures en fin de ligne/paragraphe [!]">
<!ENTITY tf_merge_contiguous_paragraphs "Fusionner les paragraphes contigus [!]">
<!ENTITY tf_apply "Appliquer">
<!ENTITY tf_default "Par défaut">
<!ENTITY tf_close "Fermer">
<!ENTITY tf_infomsg "Le formateur de texte est un outil qui automatise la correction d’erreurs typographiques. Utilisez l’outil avec prudence. Vérifiez votre texte après emploi. Si vous écrivez en mode HTML, l’emploi de ce module est à vos risques et périls.">
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<












































































































































Deleted gc_lang/fr/mailext/locale/fr/spell_options.dtd version [5ab4900b2b].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!ENTITY window.title "Grammalecte · Options orthographiques">
<!ENTITY dialogheader.label "Options orthographiques">

<!ENTITY grouptitle_graphspell "Dictionnaires de Grammalecte">
<!ENTITY warning_graphspell "Ces dictionnaires ne sont utilisés que lors de l’analyse grammaticale.">
<!ENTITY option.main_dic.label "Dictionnaire principal">
<!ENTITY option.main_dic.descr "Environ 83 000 entrées, 500 000 flexions. Ni éditable, ni désactivable.">
<!ENTITY option.main_dic.spelling "Orthographe">
<!ENTITY option.main_dic.classic "Classique">
<!ENTITY option.main_dic.reform "Réforme 1990">
<!ENTITY option.main_dic.allvars "Toutes variantes">
<!ENTITY option.community_dic.label "Dictionnaire communautaire">
<!ENTITY option.community_dic.descr "Fonctionnalité à venir.">
<!ENTITY option.personal_dic.label "Dictionnaire personnel">
<!ENTITY option.personal_dic.descr "Le dictionnaire personnel est créé et édité via l’éditeur lexical.">

<!ENTITY grouptitle_hunspell "Dictionnaires Hunspell (Thunderbird)">
<!ENTITY warning_hunspell "Ces dictionnaires ne sont utilisés que lors de l’écriture de texte (soulignement rouge). Cochez les dictionnaires que vous voulez voir apparaître dans la liste des dictionnaires utilisables. L’ajout des dictionnaires se fait instantanément. En revanche, les dictionnaires ôtés ne disparaîtront qu’au redémarrage de Thunderbird.">
<!ENTITY option.modern.label "“Moderne”">
<!ENTITY option.modern.descr "Ce dictionnaire propose l’orthographe telle qu’elle est écrite aujourd’hui le plus couramment. C’est le dictionnaire recommandé si le français n’est pas votre langue maternelle ou si vous ne désirez qu’une seule graphie correcte par mot.">
<!ENTITY option.classic.label "“Classique” (recommandé)">
<!ENTITY option.classic.descr "Il s’agit du dictionnaire “Moderne”, avec des graphies classiques en sus, certaines encore communément utilisées, d’autres désuètes. C’est le dictionnaire recommandé si le français est votre langue maternelle.">
<!ENTITY option.reform.label "“Réforme 1990”">
<!ENTITY option.reform.descr "Avec ce dictionnaire, seule l’orthographe réformée est reconnue. Attendu que bon nombre de graphies réformées sont considérées comme erronées par beaucoup, ce dictionnaire est déconseillé. Les graphies passées dans l’usage sont déjà incluses dans le dictionnaire “Moderne”.">
<!ENTITY option.allvar.label "“Toutes variantes”">
<!ENTITY option.allvar.descr "Ce dictionnaire contient les variantes graphiques, classiques, réformées, ainsi que d’autres plus rares encore. Ce dictionnaire est déconseillé à ceux qui ne connaissent pas très bien la langue française.">
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































Modified gc_lang/fr/mailext/manifest.json from [8fc810be06] to [57c89d52e2].

1
2
3
4
5
6
7
8
9

10
11
12
13
14
15

16






17






18






19






20






















21
{
  "manifest_version": 2,
  "applications": {
    "gecko": {
      "id": "${tb_identifier}",
      "strict_min_version": "68.0a1"
    }
  },
  "name": "${tb_name}",

  "description": "${description}",
  "version": "${version}",

  "author": "${author}",
  "homepage_url": "${link}",
















  "legacy":  {






    "type": "xul"






  }






















}





|



>






>

>
>
>
>
>
>

>
>
>
>
>
>
|
>
>
>
>
>
>
|
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

1
2
3
4
5
6
7
8
9
10
11
12
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{
  "manifest_version": 2,
  "applications": {
    "gecko": {
      "id": "${tb_identifier}",
      "strict_min_version": "78.0a1"
    }
  },
  "name": "${tb_name}",
  "short_name": "${tb_name}",
  "description": "${description}",
  "version": "${version}",

  "author": "${author}",
  "homepage_url": "${link}",

  "default_locale": "fr",

  "icons": { "16": "img/logo-16.png",
             "32": "img/logo-32.png",
             "48": "img/logo-48.png",
             "64": "img/logo-64.png",
             "80": "img/logo-80.png",
             "96": "img/logo-96.png" },

  "browser_action": {
    "default_icon": "img/logo-32.png",
    "default_title": "Grammalecte",
    "default_popup": "panel/main.html",
    "browser_style": false
  },

  "compose_action": {
    "default_area": "maintoolbar",
    "default_icon": "img/logo-32.png",
    "default_title": "Analyser",
    "browser_style": false
  },

  "background": {
    "scripts": [
      "grammalecte/graphspell/helpers.js",
      "background.js"
    ]
  },

  "commands": {
    "grammar_checker": {
      "suggested_key": { "default": "Ctrl+Shift+F" },
      "description": "Ouvre le correcteur grammatical"
    },
    "conjugueur_tab": {
      "suggested_key": { "default": "Ctrl+Shift+6" },
      "description": "Ouvre le conjugueur"
    },
    "lexicon_editor": {
      "suggested_key": { "default": "Ctrl+Shift+7" },
      "description": "Ouvre l’éditeur lexical"
    }
  },

  "permissions": [
    "activeTab",
    "compose",
    "downloads",
    "storage",
    "tabs"
  ]
}

Deleted gc_lang/fr/mailext/skin/Algoo_logo.png version [59954b3904].

cannot compute difference between binary files

Deleted gc_lang/fr/mailext/skin/LaMouette_small.png version [61c7247845].

cannot compute difference between binary files

Deleted gc_lang/fr/mailext/skin/grammarcheck.png version [9598be5e3c].

cannot compute difference between binary files

Deleted gc_lang/fr/mailext/skin/grammarcheck_disabled.png version [f900d73926].

cannot compute difference between binary files

Deleted gc_lang/fr/mailext/skin/grammarcheck_small.png version [dcb1bf8ae0].

cannot compute difference between binary files

Deleted gc_lang/fr/mailext/skin/grammarcheck_small_disabled.png version [502cc08b3e].

cannot compute difference between binary files

Deleted gc_lang/fr/mailext/skin/logo100.png version [137b3e197f].

cannot compute difference between binary files

Deleted gc_lang/fr/mailext/skin/logo120_text.png version [c438dd0680].

cannot compute difference between binary files

Deleted gc_lang/fr/mailext/worker/gce_worker.js version [abd0c9c4ba].

1
2
3
4
5
6
7
8
9
10
11
12
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
48
49
50
51
52
53
54
55
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
84
85
86
87
88
89
90
91
92
93
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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
// JavaScript

// Grammar checker engine
// PromiseWorker
// This code is executed in a separate thread (×20 faster too!!!)

// Firefox WTF: it’s impossible to use require as in the main thread here,
// so it is required to declare a resource in the file “chrome.manifest”.


"use strict";

// copy/paste
// https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/PromiseWorker.jsm

importScripts("resource://gre/modules/workers/require.js");
let PromiseWorker = require("resource://gre/modules/workers/PromiseWorker.js");

// Instantiate AbstractWorker (see below).
let worker = new PromiseWorker.AbstractWorker();

worker.dispatch = function(method, args = []) {
  // Dispatch a call to method `method` with args `args`
  return self[method](...args);
};
worker.postMessage = function(...args) {
  // Post a message to the main thread
  self.postMessage(...args);
};
worker.close = function() {
  // Close the worker
  self.close();
};
worker.log = function(...args) {
  // Log (or discard) messages (optional)
  dump("Worker: " + args.join(" ") + "\n");
};

// Connect it to message port.
self.addEventListener("message", msg => worker.handleMessage(msg));

// end of copy/paste


// no console here, use “dump”

let gce = null; // module: grammar checker engine
let text = null;
let tkz = null; // module: tokenizer
let lxg = null; // module: lexicographer
let helpers = null;

let oTokenizer = null;
let oSpellChecker = null;
let oLxg = null;

function loadGrammarChecker (sGCOptions="", sContext="JavaScript") {
    if (gce === null) {
        try {
            gce = require("resource://grammalecte/fr/gc_engine.js");
            helpers = require("resource://grammalecte/graphspell/helpers.js");
            text = require("resource://grammalecte/text.js");
            tkz = require("resource://grammalecte/graphspell/tokenizer.js");
            //lxg = require("resource://grammalecte/fr/lexicographe.js");
            oTokenizer = new tkz.Tokenizer("fr");
            gce.load(sContext, "sCSS");
            oSpellChecker = gce.getSpellChecker();
            if (sGCOptions !== "") {
                gce.setOptions(helpers.objectToMap(JSON.parse(sGCOptions)));
            }
            // we always retrieve options from the gce, for setOptions filters obsolete options
            return gce.getOptions().gl_toString();
        }
        catch (e) {
            console.log("# Error: " + e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
        }
    }
}

function setDictionary (sTypeDic, sDictionary) {
    try {
        console.log("set dictionary: " + sTypeDic);
        switch (sTypeDic) {
            case "main":
                oSpellChecker.setMainDictionary(sDictionary);
                break;
            case "community":
                break;
            case "personal":
                let oJSON = JSON.parse(sDictionary);
                oSpellChecker.setPersonalDictionary(oJSON);
                break;
            default:
                console.log("[GCE worker] unknown dictionary type");
        }
    }
    catch (e) {
        console.error(e);
    }
}

function parse (sText, sCountry, bDebug, bContext) {
    let aGrammErr = gce.parse(sText, sCountry, bDebug, bContext);
    return JSON.stringify(aGrammErr);
}

function parseAndSpellcheck (sText, sCountry, bDebug, bContext) {
    let aGrammErr = gce.parse(sText, sCountry, bDebug, null, bContext);
    let aSpellErr = oSpellChecker.parseParagraph(sText);
    return JSON.stringify({ aGrammErr: aGrammErr, aSpellErr: aSpellErr });
}

function suggest (sWord, nSuggLimit=10) {
    let lSugg = []
    for (let aSugg of oSpellChecker.suggest(sWord, nSuggLimit)) {
        lSugg.push(...aSugg);
    }
    return lSugg.join("|");
}

function getOptions () {
    return gce.getOptions().gl_toString();
}

function getDefaultOptions () {
    return gce.getDefaultOptions().gl_toString();
}

function setOptions (sGCOptions) {
    gce.setOptions(helpers.objectToMap(JSON.parse(sGCOptions)));
    return gce.getOptions().gl_toString();
}

function setOption (sOptName, bValue) {
    gce.setOptions(new Map([ [sOptName, bValue] ]));
    return gce.getOptions().gl_toString();
}

function resetOptions () {
    gce.resetOptions();
    return gce.getOptions().gl_toString();
}

function fullTests (sGCOptions="") {
    if (!gce || !oSpellChecker) {
        return "# Error: grammar checker or dictionary not loaded."
    }
    let dMemoOptions = gce.getOptions();
    if (sGCOptions) {
        gce.setOptions(helpers.objectToMap(JSON.parse(sGCOptions)));
    }
    let tests = require("resource://grammalecte/tests.js");
    let oTest = new tests.TestGrammarChecking(gce);
    let sAllRes = "";
    for (let sRes of oTest.testParse()) {
        console.log(sRes+"\n");
        sAllRes += sRes+"\n";
    }
    gce.setOptions(dMemoOptions);
    return sAllRes;
}
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


































































































































































































































































































































Added gc_lang/fr/webext/content_scripts/editor.js version [4bcac7be9b].



























































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
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
48
49
50
51
52
53
54
55
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
84
85
86
87
88
89
90
91
92
93
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
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
232
233
234
235
236
237
// JavaScript

// Editor for HTML page


"use strict";


/*
    Editor for HTML page (Thunderbird or Iframe)
*/
class HTMLPageEditor {

	constructor (xDocument, bCheckSignature=false) {
        this.xDocument = xDocument;
        this.xRootNode = xDocument.body;
        //console.log(xDocument.body);
        //console.log(xDocument.body.innerHTML);
        this.lNode = [];
        this.bCheckSignature = bCheckSignature;
        this._lParsableNodes = ["P", "LI", "H1", "H2", "H3", "H4", "H5", "H6"];
        this._lRootNodes = ["DIV", "UL", "OL"];
    }

    * _getParsableNodes (xRootNode) {
        // recursive function
        try {
            for (let xNode of xRootNode.childNodes) {
                if (xNode.className !== "moz-cite-prefix" && xNode.tagName !== "BLOCKQUOTE"
                    && (xNode.nodeType == Node.TEXT_NODE || (xNode.nodeType == Node.ELEMENT_NODE && !xNode.textContent.startsWith(">")))
                    && xNode.textContent !== "") {
                    if (xNode.tagName === undefined) {
                        if (!this.bCheckSignature && xNode.textContent.startsWith("-- ")) {
                            break;
                        }
                        yield xNode;
                    }
                    else if (this._lParsableNodes.includes(xNode.tagName)) {
                        yield xNode;
                    }
                    else if (this._lRootNodes.includes(xNode.tagName)) {
                        yield* this._getParsableNodes(xNode);
                    }
                }
            }
        }
        catch (e) {
            showError(e);
        }
    }

    * getParagraphs () {
        try {
            let i = 0;
            for (let xNode of this._getParsableNodes(this.xRootNode)) {
                this.lNode.push(xNode);
                yield [i, xNode.textContent];
                i += 1;
            }
        }
        catch (e) {
            showError(e);
        }
    }

    getText () {
        try {
            let sPageText = "";
            for (let [i, sLine] of this.getParagraphs()) {
                sPageText += sLine + "\n";
            }
            return sPageText;
        }
        catch (e) {
            showError(e);
        }
    }

    getParagraph (iPara) {
        try {
            return this.lNode[iPara].textContent;
        }
        catch (e) {
            showError(e);
        }
    }

    setParagraph (iPara, sText) {
        try {
            return this.lNode[iPara].textContent = oGrammalecte.purgeText(sText);
        }
        catch (e) {
            showError(e);
        }
    }

    changeParagraph (iPara, sModif, iStart, iEnd) {
        let sText = this.getParagraph(iPara);
        this.writeParagraph(iPara, sText.slice(0, iStart) + sModif + sText.slice(iEnd));
    }

    clear () {
        this.xDocument = null;
        this.xRootNode = null;
        this.lNode.length = 0;
    }
}


/*
    Editor for TextNode (Textarea or editable node)
*/
class TextNodeEditor {

    constructor (what, xResultNode=null) {
        this.xNode = null;
        this.dParagraph = new Map();
        this.bTextArea = false;
        this.bIframe = false;
        this.bResultInEvent = false; // if true, the node content is not modified, but an event is dispatched on the node with the modified text
        this.xResultNode = null; // only useful for text analysed without node
        if (xResultNode instanceof HTMLElement) {
            this.xResultNode = xResultNode;
            this.bResultInEvent = true;
        }
        if (typeof(what) == "string") {
            // SIMPLE TEXT
            if (!this.xResultNode) {
                oGrammalecte.oGCPanel.addMessageToGCPanel("⛔ Aucun champ textuel défini. Les changements ne seront pas répercutés sur la zone d’où le texte a été extrait.");
            }
            this.loadText(sText);
        }
        else if (what.nodeType && what.nodeType === 1) {
            // NODE
            this.xNode = what;
            this.bResultInEvent = Boolean(this.xNode.dataset.grammalecte_result_via_event && this.xNode.dataset.grammalecte_result_via_event == "true");
            this.bTextArea = (this.xNode.tagName == "TEXTAREA" || this.xNode.tagName == "INPUT");
            this.bIframe = (this.xNode.tagName == "IFRAME");
            if (this.bTextArea) {
                this.xNode.disabled = true;
                this.loadText(this.xNode.value);
            }
            else if (this.bIframe) {
                // iframe
                if (!this.bResultInEvent) {
                    oGrammalecte.oGCPanel.addMessageToGCPanel("⛔ La zone analysée est un cadre contenant une autre page web (“iframe”). Les changements faits ne peuvent être pas répercutés dans cette zone.");
                }
                this.loadText(this.xNode.contentWindow.document.body.innerText);
            }
            else {
                // editable node
                oGrammalecte.oGCPanel.addMessageToGCPanel("❗ La zone de texte analysée est un champ textuel enrichi susceptible de contenir des éléments non textuels qui seront effacés lors de la correction.");
                this.loadText(this.xNode.innerText);
            }
        }
    }

    loadText (sText) {
        // function also used by the text formatter
        if (typeof(sText) === "string") {
            this.dParagraph.clear();
            let i = 0;
            let iStart = 0;
            let iEnd = 0;
            sText = sText.replace(/\r\n/g, "\n").replace(/\r/g, "\n").normalize("NFC");
            while ((iEnd = sText.indexOf("\n", iStart)) !== -1) {
                this.dParagraph.set(i, sText.slice(iStart, iEnd));
                i++;
                iStart = iEnd+1;
            }
            this.dParagraph.set(i, sText.slice(iStart));
            //console.log("Paragraphs number: " + (i+1));
        }
        this.write();
    }

    clear () {
        if (this.xNode !== null) {
            this.xNode.disabled = false;
            this.bTextArea = false;
            this.bIframe = false;
            this.bResultInEvent = false;
            this.xNode = null;
            this.xResultNode = null;
        }
        this.dParagraph.clear();
    }

    getText () {
        return [...this.dParagraph.values()].join("\n").normalize("NFC");
    }

    setParagraph (iParagraph, sText) {
        this.dParagraph.set(iParagraph, oGrammalecte.purgeText(sText));
        this.write();
    }

    getParagraph (iParaNum) {
        return this.dParagraph.get(iParaNum);
    }

    _eraseNodeContent () {
        while (this.xNode.firstChild) {
            this.xNode.removeChild(this.xNode.firstChild);
        }
    }

    write () {
        if (this.xNode !== null) {
            if (this.bResultInEvent) {
                const xEvent = new CustomEvent("GrammalecteResult", { detail: JSON.stringify({ sType: "text", sText: this.getText() }) });
                this.xNode.dispatchEvent(xEvent);
                //console.log("[Grammalecte debug] Text sent to xNode via event:", xEvent.detail);
            }
            else if (this.bTextArea) {
                this.xNode.value = this.getText();
                //console.log("[Grammalecte debug] text written in textarea:", this.getText());
            }
            else if (this.bIframe) {
                //console.log(this.getText());
            }
            else {
                this._eraseNodeContent();
                this.dParagraph.forEach((val, key) => {
                    this.xNode.appendChild(document.createTextNode(val.normalize("NFC")));
                    this.xNode.appendChild(document.createElement("br"));
                });
                //console.log("[Grammalecte debug] text written in editable node:", this.getText());
            }
        }
        else if (this.xResultNode !== null) {
            const xEvent = new CustomEvent("GrammalecteResult", { detail: JSON.stringify({ sType: "text", sText: this.getText() }) });
            this.xResultNode.dispatchEvent(xEvent);
            //console.log("[Grammalecte debug] Text sent to xResultNode via event:", xEvent.detail);
        }
    }
}

Modified gc_lang/fr/webext/content_scripts/html_src.js from [33c5ac1d61] to [32b2f1f9e8].

9
10
11
12
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
    @Reviewers:
    This file only defines HTML nodes in const values
*/


const sGrammalecteConjugueurHTML = `
    <div class="centered_bar">
        <input type="text" id="grammalecte_conj_verb" maxlength="40" value="" placeholder="entrez un verbe" autofocus />
        <div id="grammalecte_conj_button">Conjuguer</div>
    </div>

    <div class="grammalecte_clearer"></div>

    <h1 class="grammalecte_conj_title" id="grammalecte_conj_verb_title" class="center">&nbsp;</h1>
    <div id="grammalecte_conj_verb_info" class="center">&nbsp;</div>

    <div id="grammalecte_conj_options">
        <label for="grammalecte_conj_oneg">Négative</label> <input type="checkbox" id="grammalecte_conj_oneg" value="ON"  />
        · <label for="grammalecte_conj_oint">Interrogative</label> <input type="checkbox" id="grammalecte_conj_oint" value="ON"  />
        · <label for="grammalecte_conj_ofem">Féminin</label> <input type="checkbox" id="grammalecte_conj_ofem" value="ON"  />

        <br/><label id="grammalecte_conj_opro_lbl" for="grammalecte_conj_opro">Pronominal</label> <input type="checkbox" id="grammalecte_conj_opro" value="ON"  />
        · <label id="grammalecte_conj_otco_lbl" for="grammalecte_conj_otco">Temps composés</label> <input type="checkbox" id="grammalecte_conj_otco" value="ON"  />
    </div>
    <div id="grammalecte_conj_note">❦</div>

    <!-- section 1 -->
    <div class="grammalecte_conj_container">
        <div class="grammalecte_conj_column">
            <div id="infinitif">







|









|
|
|
>
|
|







9
10
11
12
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
    @Reviewers:
    This file only defines HTML nodes in const values
*/


const sGrammalecteConjugueurHTML = `
    <div class="centered_bar">
        <div contenteditable="true" id="grammalecte_conj_verb" autofocus >entrez un verbe</div>
        <div id="grammalecte_conj_button">Conjuguer</div>
    </div>

    <div class="grammalecte_clearer"></div>

    <h1 class="grammalecte_conj_title" id="grammalecte_conj_verb_title" class="center">&nbsp;</h1>
    <div id="grammalecte_conj_verb_info" class="center">&nbsp;</div>

    <div id="grammalecte_conj_options">
        <div id="grammalecte_conj_oneg" class="grammalecte_conj_option_off" data-selected="off">Négation</div>
        · <div id="grammalecte_conj_oint" class="grammalecte_conj_option_off" data-selected="off">Interrogatif</div>
        · <div id="grammalecte_conj_ofem" class="grammalecte_conj_option_off" data-selected="off">Féminin</div>
        <br/>
        <div id="grammalecte_conj_opro" class="grammalecte_conj_option_off" data-selected="off">Pronominal</div>
        · <div id="grammalecte_conj_otco" class="grammalecte_conj_option_off" data-selected="off">Temps composés</div>
    </div>
    <div id="grammalecte_conj_note">❦</div>

    <!-- section 1 -->
    <div class="grammalecte_conj_container">
        <div class="grammalecte_conj_column">
            <div id="infinitif">

Modified gc_lang/fr/webext/content_scripts/init.js from [acbd3c2f80] to [1238d56b74].

18
19
20
21
22
23
24

25
26
27
28






29
30
31
32
33
34
35
36
    // console can’t display error objects from content scripts
    console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}

// Chrome don’t follow the W3C specification:
// https://browserext.github.io/browserext/
let bChrome = false;

if (typeof(browser) !== "object") {
    var browser = chrome;
    bChrome = true;
}








/*
function loadImage (sContainerClass, sImagePath) {
    let xRequest = new XMLHttpRequest();
    xRequest.open('GET', browser.extension.getURL("")+sImagePath, false);
    xRequest.responseType = "arraybuffer";
    xRequest.send();







>




>
>
>
>
>
>
|







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
    // console can’t display error objects from content scripts
    console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}

// Chrome don’t follow the W3C specification:
// https://browserext.github.io/browserext/
let bChrome = false;
let bThunderbird = false;
if (typeof(browser) !== "object") {
    var browser = chrome;
    bChrome = true;
}
if (typeof(messenger) === "object" || browser.hasOwnProperty("composeAction")) {
    // JS sucks again.
    // In Thunderbird, <browser> exists in content-scripts, but not <messenger>
    // <browner> has property <composeAction> but is undefined...
    bThunderbird = true;
    //console.log("[Grammalecte] Thunderbird...");
}

/*
function loadImage (sContainerClass, sImagePath) {
    let xRequest = new XMLHttpRequest();
    xRequest.open('GET', browser.extension.getURL("")+sImagePath, false);
    xRequest.responseType = "arraybuffer";
    xRequest.send();
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

    xObserver: null,

    sExtensionUrl: null,

    oOptions: null,

    bAutoRefresh: true,

    listen: function () {
        document.addEventListener("click", (xEvent) => {
            //console.log("click", xEvent.target.id);
            this.oPanelButton.examineNode(xEvent.target);
        });
        document.addEventListener("keyup", (xEvent) => {







|







66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

    xObserver: null,

    sExtensionUrl: null,

    oOptions: null,

    bAutoRefresh: (bThunderbird) ? false : true,

    listen: function () {
        document.addEventListener("click", (xEvent) => {
            //console.log("click", xEvent.target.id);
            this.oPanelButton.examineNode(xEvent.target);
        });
        document.addEventListener("keyup", (xEvent) => {
134
135
136
137
138
139
140




141
142
143
144
145
146
147
        let sPageText = document.body.innerText;
        let nPos = sPageText.indexOf("__grammalecte_panel__");
        if (nPos >= 0) {
            sPageText = sPageText.slice(0, nPos).normalize("NFC");
        }
        return sPageText;
    },





    createNode: function (sType, oAttr, oDataset=null) {
        try {
            let xNode = document.createElement(sType);
            Object.assign(xNode, oAttr);
            if (oDataset) {
                Object.assign(xNode.dataset, oDataset);







>
>
>
>







141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
        let sPageText = document.body.innerText;
        let nPos = sPageText.indexOf("__grammalecte_panel__");
        if (nPos >= 0) {
            sPageText = sPageText.slice(0, nPos).normalize("NFC");
        }
        return sPageText;
    },

    purgeText: function (sText) {
        return sText.replace(/&nbsp;/g, " ").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
    },

    createNode: function (sType, oAttr, oDataset=null) {
        try {
            let xNode = document.createElement(sType);
            Object.assign(xNode, oAttr);
            if (oDataset) {
                Object.assign(xNode.dataset, oDataset);
257
258
259
260
261
262
263



264
265
266
267
268
269
270
        return { top: Math.round(top), left: Math.round(left), bottom: Math.round(bottom), right: Math.round(right) };
    }
};


function autoRefreshOption (oSavedOptions=null) {
    // auto recallable function



    if (oSavedOptions === null) {
        if (bChrome) {
            browser.storage.local.get("autorefresh_option", autoRefreshOption);
            return;
        }
        browser.storage.local.get("autorefresh_option").then(autoRefreshOption, showError);
    }







>
>
>







268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
        return { top: Math.round(top), left: Math.round(left), bottom: Math.round(bottom), right: Math.round(right) };
    }
};


function autoRefreshOption (oSavedOptions=null) {
    // auto recallable function
    if (bThunderbird) {
        return;
    }
    if (oSavedOptions === null) {
        if (bChrome) {
            browser.storage.local.get("autorefresh_option", autoRefreshOption);
            return;
        }
        browser.storage.local.get("autorefresh_option").then(autoRefreshOption, showError);
    }
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
const oGrammalecteBackgroundPort = {

    bConnected: false,

    xConnect: browser.runtime.connect({name: "content-script port"}),

    start: function () {
        //console.log("[Grammalecte] background port: start.");
        this.listen();
        this.listen2();
        //this.ping();
    },

    restart: function () {
        console.log("[Grammalecte] try to reconnect to the background.")







|







296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
const oGrammalecteBackgroundPort = {

    bConnected: false,

    xConnect: browser.runtime.connect({name: "content-script port"}),

    start: function () {
        console.log("[Grammalecte] background port: start.");
        this.listen();
        this.listen2();
        //this.ping();
    },

    restart: function () {
        console.log("[Grammalecte] try to reconnect to the background.")
374
375
376
377
378
379
380

381
382
383
384
385
386
387
            this.bConnected = false;
            this.restart();
        }.bind(this));
        this.xConnect.onMessage.addListener(function (oMessage) {
            let { sActionDone, result, oInfo, bEnd, bError } = oMessage;
            switch (sActionDone) {
                case "init":

                    this.bConnected = true;
                    oGrammalecte.sExtensionUrl = oMessage.sUrl;
                    oGrammalecte.listen();
                    oGrammalecte.createButton();
                    break;
                case "ping":
                    console.log("[Grammalecte] Connection to background done.");







>







388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
            this.bConnected = false;
            this.restart();
        }.bind(this));
        this.xConnect.onMessage.addListener(function (oMessage) {
            let { sActionDone, result, oInfo, bEnd, bError } = oMessage;
            switch (sActionDone) {
                case "init":
                    //console.log("[Grammalecte] content-script: init");
                    this.bConnected = true;
                    oGrammalecte.sExtensionUrl = oMessage.sUrl;
                    oGrammalecte.listen();
                    oGrammalecte.createButton();
                    break;
                case "ping":
                    console.log("[Grammalecte] Connection to background done.");
462
463
464
465
466
467
468







469
470
471
472
473
474
475
                    if (document.activeElement.tagName == "IFRAME") {
                        //console.log(document.activeElement.id); frameId given by result is different than frame.id
                        oGrammalecte.startGCPanel(document.activeElement);
                    } else {
                        oGrammalecte.showMessage("Erreur. Le cadre sur lequel vous avez cliqué n’a pas pu être identifié. Sélectionnez le texte à corriger et relancez le correcteur via le menu contextuel.");
                    }
                    break;







                default:
                    console.log("[Grammalecte] Content-script. Unknown command: ", sActionDone);
            }
        }.bind(this));
    },

    /*







>
>
>
>
>
>
>







477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
                    if (document.activeElement.tagName == "IFRAME") {
                        //console.log(document.activeElement.id); frameId given by result is different than frame.id
                        oGrammalecte.startGCPanel(document.activeElement);
                    } else {
                        oGrammalecte.showMessage("Erreur. Le cadre sur lequel vous avez cliqué n’a pas pu être identifié. Sélectionnez le texte à corriger et relancez le correcteur via le menu contextuel.");
                    }
                    break;
                /*
                    composeAction
                    (Thunderbird only)
                */
                case "grammar_checker_compose_window":
                    oGrammalecte.startGCPanel("__ThunderbirdComposeWindow__");
                    break;
                default:
                    console.log("[Grammalecte] Content-script. Unknown command: ", sActionDone);
            }
        }.bind(this));
    },

    /*
500
501
502
503
504
505
506
507
508

509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566

567
568
569
570
571
572
573

oGrammalecteBackgroundPort.start();



/*
    Callable API for the webpage.

*/

document.addEventListener("GrammalecteCall", function (xEvent) {
    // GrammalecteCall events are dispatched by functions in the API script
    // The script is loaded below.
    try {
        let oCommand = JSON.parse(xEvent.detail);
        switch (oCommand.sCommand) {
            case "openPanelForNode":
                if (oCommand.sNodeId && document.getElementById(oCommand.sNodeId)) {
                    oGrammalecte.startGCPanel(document.getElementById(oCommand.sNodeId));
                }
                break;
            case "openPanelForText":
                if (oCommand.sText) {
                    if (oCommand.sText && oCommand.sNodeId && document.getElementById(oCommand.sNodeId)) {
                        oGrammalecte.startGCPanel(oCommand.sText, document.getElementById(oCommand.sNodeId));
                    }
                    else {
                        oGrammalecte.startGCPanel(oCommand.sText);
                    }
                }
                break;
            case "parseNode":
                if (oCommand.sNodeId && document.getElementById(oCommand.sNodeId)) {
                    let xNode = document.getElementById(oCommand.sNodeId);
                    if (xNode.tagName == "TEXTAREA"  ||  xNode.tagName == "INPUT") {
                        oGrammalecteBackgroundPort.parseAndSpellcheck(xNode.value, oCommand.sNodeId);
                    }
                    else if (xNode.tagName == "IFRAME") {
                        oGrammalecteBackgroundPort.parseAndSpellcheck(xNode.contentWindow.document.body.innerText, oCommand.sNodeId);
                    }
                    else {
                        oGrammalecteBackgroundPort.parseAndSpellcheck(xNode.innerText, oCommand.sNodeId);
                    }
                }
                break;
            case "parseText":
                if (oCommand.sText && oCommand.sNodeId) {
                    oGrammalecteBackgroundPort.parseAndSpellcheck(oCommand.sText, oCommand.sNodeId);
                }
                break;
            case "getSpellSuggestions":
                if (oCommand.sWord && oCommand.sDestination) {
                    oGrammalecteBackgroundPort.getSpellSuggestions(oCommand.sWord, oCommand.sDestination, oCommand.sErrorId);
                }
                break;
            default:
                console.log("[Grammalecte] Event: Unknown command", oCommand.sCommand);
        }
    }
    catch (e) {
        showError(e);
    }
});

// The API script must be injected this way to be callable by the page
let xScriptGrammalecteAPI = document.createElement("script");
xScriptGrammalecteAPI.src = browser.extension.getURL("content_scripts/api.js");
document.documentElement.appendChild(xScriptGrammalecteAPI);



/*
    Note:
    Initialization starts when the background is connected.
    See: oGrammalecteBackgroundPort.listen() -> case "init"
*/







|

>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|
>







522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597

oGrammalecteBackgroundPort.start();



/*
    Callable API for the webpage.
    (Not for Thunderbird)
*/
if (!bThunderbird) {
    document.addEventListener("GrammalecteCall", function (xEvent) {
        // GrammalecteCall events are dispatched by functions in the API script
        // The script is loaded below.
        try {
            let oCommand = JSON.parse(xEvent.detail);
            switch (oCommand.sCommand) {
                case "openPanelForNode":
                    if (oCommand.sNodeId && document.getElementById(oCommand.sNodeId)) {
                        oGrammalecte.startGCPanel(document.getElementById(oCommand.sNodeId));
                    }
                    break;
                case "openPanelForText":
                    if (oCommand.sText) {
                        if (oCommand.sText && oCommand.sNodeId && document.getElementById(oCommand.sNodeId)) {
                            oGrammalecte.startGCPanel(oCommand.sText, document.getElementById(oCommand.sNodeId));
                        }
                        else {
                            oGrammalecte.startGCPanel(oCommand.sText);
                        }
                    }
                    break;
                case "parseNode":
                    if (oCommand.sNodeId && document.getElementById(oCommand.sNodeId)) {
                        let xNode = document.getElementById(oCommand.sNodeId);
                        if (xNode.tagName == "TEXTAREA"  ||  xNode.tagName == "INPUT") {
                            oGrammalecteBackgroundPort.parseAndSpellcheck(xNode.value, oCommand.sNodeId);
                        }
                        else if (xNode.tagName == "IFRAME") {
                            oGrammalecteBackgroundPort.parseAndSpellcheck(xNode.contentWindow.document.body.innerText, oCommand.sNodeId);
                        }
                        else {
                            oGrammalecteBackgroundPort.parseAndSpellcheck(xNode.innerText, oCommand.sNodeId);
                        }
                    }
                    break;
                case "parseText":
                    if (oCommand.sText && oCommand.sNodeId) {
                        oGrammalecteBackgroundPort.parseAndSpellcheck(oCommand.sText, oCommand.sNodeId);
                    }
                    break;
                case "getSpellSuggestions":
                    if (oCommand.sWord && oCommand.sDestination) {
                        oGrammalecteBackgroundPort.getSpellSuggestions(oCommand.sWord, oCommand.sDestination, oCommand.sErrorId);
                    }
                    break;
                default:
                    console.log("[Grammalecte] Event: Unknown command", oCommand.sCommand);
            }
        }
        catch (e) {
            showError(e);
        }
    });

    // The API script must be injected this way to be callable by the page
    let xScriptGrammalecteAPI = document.createElement("script");
    xScriptGrammalecteAPI.src = browser.extension.getURL("content_scripts/api.js");
    document.documentElement.appendChild(xScriptGrammalecteAPI);
}


/*
    Note:
    Initialization starts when the background is connected.
    See: oGrammalecteBackgroundPort.listen() -> case "init"
*/

Modified gc_lang/fr/webext/content_scripts/panel.js from [647c8a603c] to [d95f7c1664].

191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
    setSizeAndPosition () {
        // size
        if (this.xWidthButton && this.xHeightButton) {
            this.xWidthButton.style.opacity = (this.bHorizStrech) ? ".9" : "";
            this.xHeightButton.style.opacity = (this.bVertStrech) ? ".9" : "";
        }
        let nWidth = Math.min(this.nWidth, window.innerWidth-200);
        let nHeight = Math.min(this.nHeight, window.innerHeight-100);
        if (this.bFlexible) {
            // width
            if (this.bHorizStrech) {
                nWidth = Math.min(this.nWidth*1.33, window.innerWidth-200);
            }
            // height
            nHeight = ([4, 5, 6].includes(this.nPosition)) ? nHeight : Math.floor(window.innerHeight*0.45);
            if (this.bVertStrech) {
                nHeight = ([4, 5, 6].includes(this.nPosition)) ? (window.innerHeight-100) : Math.floor(window.innerHeight*0.67);
            }
        }
        this.xPanel.style.width = `${nWidth}px`;
        this.xPanel.style.height = `${nHeight}px`;
        // position
        let oPos = null;
        switch (this.nPosition) {







|








|







191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
    setSizeAndPosition () {
        // size
        if (this.xWidthButton && this.xHeightButton) {
            this.xWidthButton.style.opacity = (this.bHorizStrech) ? ".9" : "";
            this.xHeightButton.style.opacity = (this.bVertStrech) ? ".9" : "";
        }
        let nWidth = Math.min(this.nWidth, window.innerWidth-200);
        let nHeight = Math.min(this.nHeight, window.innerHeight-50);
        if (this.bFlexible) {
            // width
            if (this.bHorizStrech) {
                nWidth = Math.min(this.nWidth*1.33, window.innerWidth-200);
            }
            // height
            nHeight = ([4, 5, 6].includes(this.nPosition)) ? nHeight : Math.floor(window.innerHeight*0.45);
            if (this.bVertStrech) {
                nHeight = ([4, 5, 6].includes(this.nPosition)) ? (window.innerHeight-50) : Math.floor(window.innerHeight*0.67);
            }
        }
        this.xPanel.style.width = `${nWidth}px`;
        this.xPanel.style.height = `${nHeight}px`;
        // position
        let oPos = null;
        switch (this.nPosition) {

Modified gc_lang/fr/webext/content_scripts/panel_conj.css from [e61b4b58d2] to [ec0b4594f9].

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
div.grammalecte_conj_column {
    width: 50%;
    padding: 0 10px;
    font-size: 12px;
}


input#grammalecte_conj_verb {
    display: inline-block;
    width: 230px;
    margin-left: 5px;
    padding: 5px 10px;
    border: 2px solid hsl(0, 0%, 80%);
    border-radius: 3px;
    height: 20px;
    background: transparent;
    font: normal 18px Tahoma, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", sans-serif;
    color: hsl(0, 0%, 30%);
}
input[placeholder]#grammalecte_conj_verb {
    color: hsl(0, 0%, 70%);
}

div#grammalecte_conj_button {
    display: inline-block;
    padding: 7px 10px;
    font-size: 18px;







|











|







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
div.grammalecte_conj_column {
    width: 50%;
    padding: 0 10px;
    font-size: 12px;
}


div#grammalecte_conj_verb {
    display: inline-block;
    width: 230px;
    margin-left: 5px;
    padding: 5px 10px;
    border: 2px solid hsl(0, 0%, 80%);
    border-radius: 3px;
    height: 20px;
    background: transparent;
    font: normal 18px Tahoma, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", sans-serif;
    color: hsl(0, 0%, 30%);
}
div#grammalecte_conj_verb {
    color: hsl(0, 0%, 70%);
}

div#grammalecte_conj_button {
    display: inline-block;
    padding: 7px 10px;
    font-size: 18px;
95
96
97
98
99
100
101



















102
103
104
105
106
107
108
}

div#grammalecte_conj_options {
    margin: 10px 0 0 5px;
    font-size: 16px;
    text-align: center;
}




















div#grammalecte_conj_note {
    margin: 10px 20px;
    font-size: 11px;
    color: hsl(0, 0%, 60%);
    text-align: center;
}







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
126
127
}

div#grammalecte_conj_options {
    margin: 10px 0 0 5px;
    font-size: 16px;
    text-align: center;
}

div.grammalecte_conj_option_off {
    display: inline-block;
    margin: 2px;
    background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTczbp9jAAADGUlEQVQ4T2P4//8/VTFWQUowggEEQJoRiJlB/BfPn6vMbmrp6AqPOdUeGPa4Iyj8cbN/0Kn5HV0db169UoHqA6kF6UGYg8QBSYAw09SKqtoaTYMvtfLq/5t5xf+1MTD9B+FGIZl/ILEaZe2vs5pba0FqkfRhNZChzNx6RYOU0v96Nb3/tWLyH6aVlC8+vHNX8Yn9B4on5RctrpFQ/FCnZfi/hUvsf7W714q3b9/C9YIwsoEMNaERdQ1aRv9rZFX/13r7bH729KkQVA7uirdv3gjVefpsrjez+d8gLPO/PSOzDqoGjOGMnVu3qtcZWryrU9T+3x0Tv+HFy5cMZ44d99+ydm0oTM38SZNDN61e4w9il+qabGgytftfzy34bsGcOeowNXAD8/kl2hpMrP7X8wm/b6mtFQFpbGZg+NfCwPRn5cJFDlPaOxwaROX+tLAL/ls4fYb/vbt3RWo1Dd7XA4Nn87LlbRgGlptbH28QV/o/rbxy6dt37xgak1PqmwQk/zdYO/yrkZD9WCsm/bHO2PIfMJL+d+fk13/79o0hX151aYOS9v8paZnHMQysNDZ/1Cgq939KTW0ZTGxKfUN+rZTy/zoLuz9Aw/7U6Br/7y0uzQfJ/fz5kyFHWKKsUdvof4uX3yOYHkwDa+vgBq5YsNClAeiiekvbP7UGZn/q9Ez+z504yQUk9wNoYJYIHgPBXgaGx+TCkiUg/qye3sgGAalf9daO/4Cu/FOrqgMy9B9IbNnsOZE/fvwAeXlJnYoOdi+DIqXRyPI/MLw+5GdmCk5raSkFJeZmLpH/faVl+eWhkfl1ihqgxP2/JSOr9O6dO4I12kYfcEYKPNnIa/3vT0rdcOnKFYYlU6bVTCwugStuTkppm1hVXfP6zRuGIgMCyQaE4QlbWvl/Q2Dwxtu3bvFB5eAJG5hc+Bp8AzY2ABN2k4A07oQNxGANkKyn8h8YZqAc8356eeXiQzt2Fp/Yt78YlA1rFTXfA9MfLOutxJf1YK6AFw71Mir/m5AKB2C6/AcSAxUOwJKIYOEAM5RqxRdVMFZB8vF/BgAKMNpeW+niqQAAAABJRU5ErkJggg==') no-repeat;
    background-color: none;
    padding: 0 3px 0 22px ;
    border-radius: 3px;
    cursor: pointer;
}
div.grammalecte_conj_option_on {
    display: inline-block;
    margin: 2px;
    background:  url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwQAADsEBuJFr7QAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xNzNun2MAAAMnSURBVDhPY/j//z9VMVZBSjC6ACMQM4PYz1+8UGmaPrsjvL7rVGB1++Oguo7H/pXNpzpmz+949eaNClQ9SC1ID9wMOAOIQRIgzFQxYWqtZk7NF/ms2v+8mc3/GAra/oOwUE7jP5CYcnbN1+aps2pBapH0YTWQwTyrbIVUVsN/rdy6/9KZNe8qJk5fsOvQkeL9x04UF/RMWSAPFAPJcWW1/HcvqF7x9u1buF4QRjaQIbS0pk6rsOG/ItAVLgXVG2/duSMOlYO74v7DR+JuBTVbDPPr/wvnNvzPaGqvg6oBYzhj686d6vq59e/Uc2r/B1U1r3v69ClMjgUNg7zJ4JBbsdK8qPE/d079uznzF6iDxEAYbiB/TH6bGdB1LFnNb3smTZaDioMMgKmBuZJtwtyFZcUNLYb62VWPpHLr/y/buLkNpg6mmME8p/y4PDBssjsmLIKKsQIxcqCDY9+/sGIab07Lf9XUssP66SUbFLPq/qf1TDkBkgNhuIHGOZWPhDIa/zdMnl4O4n/89AmUNPig8mCX+hdWz1AGWmpS0PhfOLF0oWZsVo0GMBw9K1oeQ9UhDDTMrHwkmtX4v6pvYv7xkyflGMqaP/oXV6/89esXWD6gsHKmcnbtf1AY+5Q3r9+0aRODXFhaiVYe2MBHGAYaZZUdNyhu+q+ZkD2ZNb6iTqOg4b9MZv3/6KrG2S6ZBRNVgC7Tyav7b5Zdufr3nz9sv4EWySTmLwaJA718HMNA4ficNsOihv8qOVVvI5PTxFNae6eL5jX+18yt/QM06C/IMAugYe8/fAB7//bde/LAxP9WCmgp1kgBJRvDvLp38sBATmzpXbt582aGhMauuaBYBLnCOLNiPTBcQRHFAAoGrZTidXiTDQiDEzYwTMSAhkbVtW6Yt3ART3Rd63xguoTFPMPd+/clPIvrNoKSGN6EDcTgnADKejJAV4EiwCi35iXQlQuXrN9UcuTM2fyCvimLZDNr3iJlvZX4sh4svTFV9E+pBYbdF4mc+v9AL//jym3+z1Dc+l8st46kwgFmKErxFVbXcdqvpv1JQE0nycUXVTBWQfLxfwYA8YUHpiMfZa8AAAAASUVORK5CYII=') no-repeat;
    background-color: hsla(120, 50%, 50%, .2);
    padding: 0 3px 0 22px;
    border-radius: 3px;
    cursor: pointer;
}

div#grammalecte_conj_note {
    margin: 10px 20px;
    font-size: 11px;
    color: hsl(0, 0%, 60%);
    text-align: center;
}

Modified gc_lang/fr/webext/content_scripts/panel_gc.js from [2282aa660c] to [505aead2d8].

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
        // Editor
        this.xGCPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_gc_panel_content"});
        this.xParagraphList = oGrammalecte.createNode("div", {id: "grammalecte_paragraph_list"});
        this.xGCPanelContent.appendChild(this.xParagraphList);
        this.xPanelContent.addEventListener("click", onGrammalecteGCPanelClick, false);
        this.oTooltip = new GrammalecteTooltip(this.xParent, this.xGCPanelContent);
        this.xPanelContent.appendChild(this.xGCPanelContent);
        this.xNode = null;
        this.oTextControl = new GrammalecteTextControl();
        this.nLastResult = 0;
        this.iLastEditedParagraph = -1;
        // Lexicographer
        this.nLxgCount = 0;
        this.xLxgPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_lxg_panel_content"});
        this.xPanelContent.appendChild(this.xLxgPanelContent);
        // Conjugueur







<
|







55
56
57
58
59
60
61

62
63
64
65
66
67
68
69
        // Editor
        this.xGCPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_gc_panel_content"});
        this.xParagraphList = oGrammalecte.createNode("div", {id: "grammalecte_paragraph_list"});
        this.xGCPanelContent.appendChild(this.xParagraphList);
        this.xPanelContent.addEventListener("click", onGrammalecteGCPanelClick, false);
        this.oTooltip = new GrammalecteTooltip(this.xParent, this.xGCPanelContent);
        this.xPanelContent.appendChild(this.xGCPanelContent);

        this.oTextControl = null;
        this.nLastResult = 0;
        this.iLastEditedParagraph = -1;
        // Lexicographer
        this.nLxgCount = 0;
        this.xLxgPanelContent = oGrammalecte.createNode("div", {id: "grammalecte_lxg_panel_content"});
        this.xPanelContent.appendChild(this.xLxgPanelContent);
        // Conjugueur
98
99
100
101
102
103
104




105
106
107
108
109
110
111
        };
        this.xEditorButton.onclick = () => {
            if (!this.bWorking) {
                this.showEditor();
            }
        };
        this.xAutoRefresh.onclick = () => {




            this.bAutoRefresh = !this.bAutoRefresh;
            oGrammalecte.bAutoRefresh = this.bAutoRefresh;
            browser.storage.local.set({"autorefresh_option": this.bAutoRefresh});
            this.setAutoRefreshButton();
        }
        this.xLxgButton.onclick = () => {
            if (!this.bWorking) {







>
>
>
>







97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
        };
        this.xEditorButton.onclick = () => {
            if (!this.bWorking) {
                this.showEditor();
            }
        };
        this.xAutoRefresh.onclick = () => {
            if (bThunderbird) {
                oGrammalecte.showMessage("À cause d’une limitation de Thunberbird, l’auto-rafraîchissement est indisponible. Si vous modifiez le texte dans ce panneau, cliquez sur le bouton ↻ pour relancer l’analyse grammaticale du paragraphe.")
                return;
            }
            this.bAutoRefresh = !this.bAutoRefresh;
            oGrammalecte.bAutoRefresh = this.bAutoRefresh;
            browser.storage.local.set({"autorefresh_option": this.bAutoRefresh});
            this.setAutoRefreshButton();
        }
        this.xLxgButton.onclick = () => {
            if (!this.bWorking) {
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157

    start (what, xResultNode=null) {
        this.oTooltip.hide();
        this.bWorking = false;
        this.clear();
        this.hideMessage();
        this.resetTimer();
        if (typeof(what) === "string") {
            // text
            this.xNode = null;
            this.oTextControl.setResultNode(xResultNode);
            this.oTextControl.setText(what);
        }
        else if (what.nodeType && what.nodeType === 1) { // 1 = Node.ELEMENT_NODE
            // node
            this.xNode = what;
            this.oTextControl.setNode(this.xNode);
        }
        else {
            // error
            oGrammalecte.oMessageBox.showMessage("[BUG] Analyse d’un élément inconnu…");
            console.log("[Grammalecte] Unknown element:", what);
        }
    }







|
|
<
<
|

|
|
<
|







137
138
139
140
141
142
143
144
145


146
147
148
149

150
151
152
153
154
155
156
157

    start (what, xResultNode=null) {
        this.oTooltip.hide();
        this.bWorking = false;
        this.clear();
        this.hideMessage();
        this.resetTimer();
        if (typeof(what) === "string" && what === "__ThunderbirdComposeWindow__") {
            // Thunderbird compose window


            this.oTextControl = new HTMLPageEditor(document);
        }
        else if (typeof(what) === "string" || (what.nodeType && what.nodeType === 1)) {
            // Text or node

            this.oTextControl = new TextNodeEditor(what, xResultNode);
        }
        else {
            // error
            oGrammalecte.oMessageBox.showMessage("[BUG] Analyse d’un élément inconnu…");
            console.log("[Grammalecte] Unknown element:", what);
        }
    }
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
                    if (this.bAutoRefresh) {
                        // timer for refreshing analysis
                        window.clearTimeout(parseInt(xParagraph.dataset.timer_id, 10));
                        xParagraph.dataset.timer_id = window.setTimeout(this.recheckParagraph.bind(this), 3000, oResult.iParaNum);
                        this.iLastEditedParagraph = oResult.iParaNum;
                    }
                    // write text
                    this.oTextControl.setParagraph(parseInt(xEvent.target.dataset.para_num, 10), this.purgeText(xEvent.target.textContent));
                    this.oTextControl.write();
                }.bind(this)
                , true);
                this._tagParagraph(xParagraph, oResult.sParagraph, oResult.iParaNum, oResult.aGrammErr, oResult.aSpellErr);
                // creation
                xNodeDiv.appendChild(xActionsBar);
                xNodeDiv.appendChild(xParagraph);
                this.xParagraphList.appendChild(xNodeDiv);







|
<







240
241
242
243
244
245
246
247

248
249
250
251
252
253
254
                    if (this.bAutoRefresh) {
                        // timer for refreshing analysis
                        window.clearTimeout(parseInt(xParagraph.dataset.timer_id, 10));
                        xParagraph.dataset.timer_id = window.setTimeout(this.recheckParagraph.bind(this), 3000, oResult.iParaNum);
                        this.iLastEditedParagraph = oResult.iParaNum;
                    }
                    // write text
                    this.oTextControl.setParagraph(parseInt(xEvent.target.dataset.para_num, 10), xEvent.target.textContent);

                }.bind(this)
                , true);
                this._tagParagraph(xParagraph, oResult.sParagraph, oResult.iParaNum, oResult.aGrammErr, oResult.aSpellErr);
                // creation
                xNodeDiv.appendChild(xActionsBar);
                xNodeDiv.appendChild(xParagraph);
                this.xParagraphList.appendChild(xNodeDiv);
279
280
281
282
283
284
285


286

287
288
289
290
291
292
293
    recheckParagraph (iParaNum) {
        if (!this.bOpened) {
            return;
        }
        let sParagraphId = "grammalecte_paragraph" + iParaNum;
        let xParagraph = this.xParent.getElementById(sParagraphId);
        this._blockParagraph(xParagraph);


        //let sText = this.purgeText(xParagraph.textContent);

        let sText = this.oTextControl.getParagraph(iParaNum);
        oGrammalecteBackgroundPort.parseAndSpellcheck1(sText, "__GrammalectePanel__", sParagraphId);
    }

    refreshParagraph (sParagraphId, oResult) {
        // function called when results are sent by the Worker
        if (!this.bOpened) {







>
>
|
>







278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
    recheckParagraph (iParaNum) {
        if (!this.bOpened) {
            return;
        }
        let sParagraphId = "grammalecte_paragraph" + iParaNum;
        let xParagraph = this.xParent.getElementById(sParagraphId);
        this._blockParagraph(xParagraph);
        if (bThunderbird) {
            // WORKAROUND: input event isn’t triggered by key input, so as textContent isn’t up to date, we do it now
            this.oTextControl.setParagraph(iParaNum, xParagraph.textContent);
        }
        let sText = this.oTextControl.getParagraph(iParaNum);
        oGrammalecteBackgroundPort.parseAndSpellcheck1(sText, "__GrammalectePanel__", sParagraphId);
    }

    refreshParagraph (sParagraphId, oResult) {
        // function called when results are sent by the Worker
        if (!this.bOpened) {
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
            let sErrorId = this.xParent.getElementById(sNodeSuggId).dataset.error_id;
            //let sParaNum = sErrorId.slice(0, sErrorId.indexOf("-"));
            let xNodeErr = this.xParent.getElementById("grammalecte_err" + sErrorId);
            xNodeErr.textContent = this.xParent.getElementById(sNodeSuggId).textContent;
            xNodeErr.className = "grammalecte_error_corrected";
            xNodeErr.removeAttribute("style");
            let iParaNum = parseInt(sErrorId.slice(0, sErrorId.indexOf("-")), 10);
            this.oTextControl.setParagraph(iParaNum, this.purgeText(this.xParent.getElementById("grammalecte_paragraph" + iParaNum).textContent));
            this.oTextControl.write();
            this.oTooltip.hide();
            this.recheckParagraph(iParaNum);
            this.iLastEditedParagraph = iParaNum;
        }
        catch (e) {
            showError(e);
        }







|
<







412
413
414
415
416
417
418
419

420
421
422
423
424
425
426
            let sErrorId = this.xParent.getElementById(sNodeSuggId).dataset.error_id;
            //let sParaNum = sErrorId.slice(0, sErrorId.indexOf("-"));
            let xNodeErr = this.xParent.getElementById("grammalecte_err" + sErrorId);
            xNodeErr.textContent = this.xParent.getElementById(sNodeSuggId).textContent;
            xNodeErr.className = "grammalecte_error_corrected";
            xNodeErr.removeAttribute("style");
            let iParaNum = parseInt(sErrorId.slice(0, sErrorId.indexOf("-")), 10);
            this.oTextControl.setParagraph(iParaNum, this.xParent.getElementById("grammalecte_paragraph" + iParaNum).textContent);

            this.oTooltip.hide();
            this.recheckParagraph(iParaNum);
            this.iLastEditedParagraph = iParaNum;
        }
        catch (e) {
            showError(e);
        }
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
            this.oTooltip.hide();
        }
        catch (e) {
            showError(e);
        }
    }

    purgeText (sText) {
        return sText.replace(/&nbsp;/g, " ").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
    }

    addSummary () {
        // todo
    }

    addMessageToGCPanel (sMessage) {
        let xNode = oGrammalecte.createNode("div", {className: "grammalecte_panel_flow_message", textContent: sMessage});
        this.xParagraphList.appendChild(xNode);







<
<
<
<







436
437
438
439
440
441
442




443
444
445
446
447
448
449
            this.oTooltip.hide();
        }
        catch (e) {
            showError(e);
        }
    }





    addSummary () {
        // todo
    }

    addMessageToGCPanel (sMessage) {
        let xNode = oGrammalecte.createNode("div", {className: "grammalecte_panel_flow_message", textContent: sMessage});
        this.xParagraphList.appendChild(xNode);
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
            // Firefox 63+, Chrome 66+
            // Working draft: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard
            navigator.clipboard.writeText(sText)
            .then(
                (res) => { window.setTimeout(() => { this.xClipboardButton.textContent = "📋"; }, 2000); }
            )
            .catch(
                (e) => { console.error(e); this._sendTextToClipboard(sText); }
            );
        } else {
            this._sendTextToClipboardFallback(sText);
        }
    }

    _sendTextToClipboardFallback (sText) {







|







472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
            // Firefox 63+, Chrome 66+
            // Working draft: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard
            navigator.clipboard.writeText(sText)
            .then(
                (res) => { window.setTimeout(() => { this.xClipboardButton.textContent = "📋"; }, 2000); }
            )
            .catch(
                (e) => { showError(e); this._sendTextToClipboard(sText); }
            );
        } else {
            this._sendTextToClipboardFallback(sText);
        }
    }

    _sendTextToClipboardFallback (sText) {
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
                xEvent.clipboardData.setData("text/plain", sText);
            }
            document.addEventListener("copy", setClipboardData, true);
            document.execCommand("copy");
            window.setTimeout(() => { this.xClipboardButton.textContent = "📋"; }, 2000);
        }
        catch (e) {
            console.error(e);
        }
    }

    // Lexicographer

    clearLexicographer () {
        this.nLxgCount = 0;







|







495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
                xEvent.clipboardData.setData("text/plain", sText);
            }
            document.addEventListener("copy", setClipboardData, true);
            document.execCommand("copy");
            window.setTimeout(() => { this.xClipboardButton.textContent = "📋"; }, 2000);
        }
        catch (e) {
            showError(e);
        }
    }

    // Lexicographer

    clearLexicographer () {
        this.nLxgCount = 0;
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607













































608
609
610

611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627

628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
    listenConj () {
        if (!this.bListenConj) {
            // button
            this.xParent.getElementById('grammalecte_conj_button').addEventListener("click", (e) => { this.conjugateVerb(); });
            // text field
            this.xParent.getElementById('grammalecte_conj_verb').addEventListener("change", (e) => { this.conjugateVerb(); });
            // options
            this.xParent.getElementById('grammalecte_conj_oneg').addEventListener("click", (e) => { this.updateConj(); });
            this.xParent.getElementById('grammalecte_conj_opro').addEventListener("click", (e) => { this.updateConj(); });
            this.xParent.getElementById('grammalecte_conj_oint').addEventListener("click", (e) => { this.updateConj(); });
            this.xParent.getElementById('grammalecte_conj_ofem').addEventListener("click", (e) => { this.updateConj(); });
            this.xParent.getElementById('grammalecte_conj_otco').addEventListener("click", (e) => { this.updateConj(); });
            this.bListenConj = true;
        }
    }














































    conjugateVerb (sVerb="") {
        try {
            if (!sVerb) {

                sVerb = this.xParent.getElementById('grammalecte_conj_verb').value;
            }
            this.xParent.getElementById('grammalecte_conj_oneg').checked = false;
            this.xParent.getElementById('grammalecte_conj_opro').checked = false;
            this.xParent.getElementById('grammalecte_conj_oint').checked = false;
            this.xParent.getElementById('grammalecte_conj_otco').checked = false;
            this.xParent.getElementById('grammalecte_conj_ofem').checked = false;
            // request analyzing
            sVerb = sVerb.trim().toLowerCase().replace(/’/g, "'").replace(/  +/g, " ");
            if (sVerb) {
                if (sVerb.startsWith("ne pas ")) {
                    this.xParent.getElementById('grammalecte_conj_oneg').checked = true;
                    sVerb = sVerb.slice(7);
                }
                if (sVerb.startsWith("se ")) {
                    this.xParent.getElementById('grammalecte_conj_opro').checked = true;
                    sVerb = sVerb.slice(3);

                } else if (sVerb.startsWith("s'")) {
                    this.xParent.getElementById('grammalecte_conj_opro').checked = true;
                    sVerb = sVerb.slice(2);
                }
                if (sVerb.endsWith("?")) {
                    this.xParent.getElementById('grammalecte_conj_oint').checked = true;
                    sVerb = sVerb.slice(0,-1).trim();
                }
                if (sVerb) {
                    this.sVerb = sVerb;
                    this.updateConj(true);
                } else {
                    this.xParent.getElementById('grammalecte_conj_verb').value = "";
                }
            }
        }
        catch (e) {
            console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
        }
    }

    updateConj (bStart=false) {
        let bPro = this.xParent.getElementById('grammalecte_conj_opro').checked;
        let bNeg = this.xParent.getElementById('grammalecte_conj_oneg').checked;
        let bTpsCo = this.xParent.getElementById('grammalecte_conj_otco').checked;
        let bInt = this.xParent.getElementById('grammalecte_conj_oint').checked;
        let bFem = this.xParent.getElementById('grammalecte_conj_ofem').checked;
        if (this.sVerb) {
            oGrammalecteBackgroundPort.getVerb(this.sVerb, bStart, bPro, bNeg, bTpsCo, bInt, bFem);
        }
    }

    conjugateWith (oVerb, oConjTable) {
        // function called when results come from the Worker
        if (oVerb) {
            this.xParent.getElementById('grammalecte_conj_verb').style.color = "#999999";
            this.xParent.getElementById('grammalecte_conj_verb').value = "";
            this.xParent.getElementById('grammalecte_conj_verb_title').textContent = oVerb.sVerb;
            this.xParent.getElementById('grammalecte_conj_verb_info').textContent = oVerb.sInfo;
            this.xParent.getElementById('grammalecte_conj_opro_lbl').textContent = oVerb.sProLabel;
            if (oVerb.bUncomplete) {
                this.xParent.getElementById('grammalecte_conj_opro').checked = false;
                this.xParent.getElementById('grammalecte_conj_opro').disabled = true;
                this.xParent.getElementById('grammalecte_conj_opro_lbl').style.color = "#CCC";
                this.xParent.getElementById('grammalecte_conj_otco').checked = false;
                this.xParent.getElementById('grammalecte_conj_otco').disabled = true;
                this.xParent.getElementById('grammalecte_conj_otco_lbl').style.color = "#CCC";
                this.xParent.getElementById('grammalecte_conj_note').textContent = "Ce verbe n’a pas encore été vérifié. C’est pourquoi les options “pronominal” et “temps composés” sont désactivées.";
            } else {
                this.xParent.getElementById('grammalecte_conj_otco').disabled = false;
                this.xParent.getElementById('grammalecte_conj_otco_lbl').style.color = "#000";
                if (oVerb.nPronominable == 0) {
                    this.xParent.getElementById('grammalecte_conj_opro').checked = false;
                    this.xParent.getElementById('grammalecte_conj_opro').disabled = false;
                    this.xParent.getElementById('grammalecte_conj_opro_lbl').style.color = "#000";
                } else if (oVerb.nPronominable == 1) {
                    this.xParent.getElementById('grammalecte_conj_opro').checked = true;
                    this.xParent.getElementById('grammalecte_conj_opro').disabled = true;
                    this.xParent.getElementById('grammalecte_conj_opro_lbl').style.color = "#CCC";
                } else { // -1 or 1 or error
                    this.xParent.getElementById('grammalecte_conj_opro').checked = false;
                    this.xParent.getElementById('grammalecte_conj_opro').disabled = true;
                    this.xParent.getElementById('grammalecte_conj_opro_lbl').style.color = "#CCC";
                }
                this.xParent.getElementById('grammalecte_conj_note').textContent = "❦";
            }
            this.displayConj(oConjTable);
        } else {
            this.xParent.getElementById('grammalecte_conj_verb').style.color = "#BB4411";
        }
    }

    displayConj (oConjTable) {
        // function called when results come from the Worker
        if (oConjTable === null) {
            return;
        }
        try {
            this.xParent.getElementById('grammalecte_conj_verb').Text = "";
            // infinitif
            this.xParent.getElementById('grammalecte_conj_infi').textContent = oConjTable["infi"] || " "; // something or nbsp
            // participe présent
            this.xParent.getElementById('grammalecte_conj_ppre').textContent = oConjTable["ppre"] || " ";
            // participes passés
            this.xParent.getElementById('grammalecte_conj_ppas1').textContent = oConjTable["ppas1"] || " ";
            this.xParent.getElementById('grammalecte_conj_ppas2').textContent = oConjTable["ppas2"] || " ";







|
|
|
|
|




>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



>
|

|
|
|
|
|




|
|


|
|
>
|
|
|


|






|




|




|
|
|
|
|









|


|

|
|
<
|
|
<


|
<

|
<
<

|
|
<
|
|
|
<















|







589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714

715
716

717
718
719

720
721


722
723
724

725
726
727

728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
    listenConj () {
        if (!this.bListenConj) {
            // button
            this.xParent.getElementById('grammalecte_conj_button').addEventListener("click", (e) => { this.conjugateVerb(); });
            // text field
            this.xParent.getElementById('grammalecte_conj_verb').addEventListener("change", (e) => { this.conjugateVerb(); });
            // options
            this.xParent.getElementById('grammalecte_conj_oneg').addEventListener("click", (e) => { this.switchOption('grammalecte_conj_oneg'); this.updateConj(); });
            this.xParent.getElementById('grammalecte_conj_opro').addEventListener("click", (e) => { this.switchOption('grammalecte_conj_opro'); this.updateConj(); });
            this.xParent.getElementById('grammalecte_conj_oint').addEventListener("click", (e) => { this.switchOption('grammalecte_conj_oint'); this.updateConj(); });
            this.xParent.getElementById('grammalecte_conj_ofem').addEventListener("click", (e) => { this.switchOption('grammalecte_conj_ofem'); this.updateConj(); });
            this.xParent.getElementById('grammalecte_conj_otco').addEventListener("click", (e) => { this.switchOption('grammalecte_conj_otco'); this.updateConj(); });
            this.bListenConj = true;
        }
    }

    purgeInputText () {
        // Thunderbird don’t accept input fields
        // So we use editable node and we purge it
        let sVerb = this.xParent.getElementById('grammalecte_conj_verb').innerText;
        let nIndexCut = sVerb.indexOf("\n");
        if (nIndexCut != -1) {
            sVerb = sVerb.slice(0, nIndexCut);
        };
        this.xParent.getElementById('grammalecte_conj_verb').textContent = sVerb.trim();
    }

    switchOption (sOption) {
        if (this.xParent.getElementById(sOption).dataset.disabled == "off") {
            this.xParent.getElementById(sOption).dataset.selected = (this.xParent.getElementById(sOption).dataset.selected == "off") ? "on" : "off";
            this.xParent.getElementById(sOption).className = (this.xParent.getElementById(sOption).dataset.selected == "on") ? "grammalecte_conj_option_on" : "grammalecte_conj_option_off";
        }
    }

    resetOption (sOption) {
        this.xParent.getElementById(sOption).dataset.selected = "off";
        this.xParent.getElementById(sOption).dataset.disabled = "off";
        this.xParent.getElementById(sOption).style.color = "";
        this.xParent.getElementById(sOption).className = "grammalecte_conj_option_off";
    }

    selectOption (sOption) {
        this.xParent.getElementById(sOption).dataset.selected = "on";
        this.xParent.getElementById(sOption).className = "grammalecte_conj_option_on";
    }

    unselectOption (sOption) {
        this.xParent.getElementById(sOption).dataset.selected = "off";
        this.xParent.getElementById(sOption).className = "grammalecte_conj_option_off";
    }

    enableOption (sOption) {
        this.xParent.getElementById(sOption).dataset.disabled = "off";
        this.xParent.getElementById(sOption).style.color = "";
    }

    disableOption (sOption) {
        this.xParent.getElementById(sOption).dataset.disabled = "on";
        this.xParent.getElementById(sOption).style.color = "#CCC";
    }

    conjugateVerb (sVerb="") {
        try {
            if (!sVerb) {
                this.purgeInputText();
                sVerb = this.xParent.getElementById('grammalecte_conj_verb').textContent;
            }
            this.resetOption('grammalecte_conj_oneg');
            this.resetOption('grammalecte_conj_opro');
            this.resetOption('grammalecte_conj_oint');
            this.resetOption('grammalecte_conj_otco');
            this.resetOption('grammalecte_conj_ofem');
            // request analyzing
            sVerb = sVerb.trim().toLowerCase().replace(/’/g, "'").replace(/  +/g, " ");
            if (sVerb) {
                if (sVerb.startsWith("ne pas ")) {
                    this.selectOption('grammalecte_conj_oneg');
                    sVerb = sVerb.slice(7).trim();
                }
                if (sVerb.startsWith("se ")) {
                    this.selectOption('grammalecte_conj_opro');
                    sVerb = sVerb.slice(3).trim();
                }
                else if (sVerb.startsWith("s'")) {
                    this.selectOption('grammalecte_conj_opro');
                    sVerb = sVerb.slice(2).trim();
                }
                if (sVerb.endsWith("?")) {
                    this.selectOption('grammalecte_conj_oint');
                    sVerb = sVerb.slice(0,-1).trim();
                }
                if (sVerb) {
                    this.sVerb = sVerb;
                    this.updateConj(true);
                } else {
                    this.xParent.getElementById('grammalecte_conj_verb').textContent = "";
                }
            }
        }
        catch (e) {
            showError(e);
        }
    }

    updateConj (bStart=false) {
        let bPro = this.xParent.getElementById('grammalecte_conj_opro').dataset.selected == "on";
        let bNeg = this.xParent.getElementById('grammalecte_conj_oneg').dataset.selected == "on";
        let bTpsCo = this.xParent.getElementById('grammalecte_conj_otco').dataset.selected == "on";
        let bInt = this.xParent.getElementById('grammalecte_conj_oint').dataset.selected == "on";
        let bFem = this.xParent.getElementById('grammalecte_conj_ofem').dataset.selected == "on";
        if (this.sVerb) {
            oGrammalecteBackgroundPort.getVerb(this.sVerb, bStart, bPro, bNeg, bTpsCo, bInt, bFem);
        }
    }

    conjugateWith (oVerb, oConjTable) {
        // function called when results come from the Worker
        if (oVerb) {
            this.xParent.getElementById('grammalecte_conj_verb').style.color = "#999999";
            this.xParent.getElementById('grammalecte_conj_verb').textContent = "";
            this.xParent.getElementById('grammalecte_conj_verb_title').textContent = oVerb.sVerb;
            this.xParent.getElementById('grammalecte_conj_verb_info').textContent = oVerb.sInfo;
            this.xParent.getElementById('grammalecte_conj_opro').textContent = oVerb.sProLabel;
            if (oVerb.bUncomplete) {
                this.unselectOption('grammalecte_conj_opro');
                this.disableOption('grammalecte_conj_opro');

                this.unselectOption('grammalecte_conj_otco');
                this.disableOption('grammalecte_conj_otco');

                this.xParent.getElementById('grammalecte_conj_note').textContent = "Ce verbe n’a pas encore été vérifié. C’est pourquoi les options “pronominal” et “temps composés” sont désactivées.";
            } else {
                this.enableOption('grammalecte_conj_otco');

                if (oVerb.nPronominable == 0) {
                    this.enableOption('grammalecte_conj_opro');


                } else if (oVerb.nPronominable == 1) {
                    this.selectOption('grammalecte_conj_opro');
                    this.disableOption('grammalecte_conj_opro');

                } else { // -1 or error
                    this.unselectOption('grammalecte_conj_opro');
                    this.disableOption('grammalecte_conj_opro');

                }
                this.xParent.getElementById('grammalecte_conj_note').textContent = "❦";
            }
            this.displayConj(oConjTable);
        } else {
            this.xParent.getElementById('grammalecte_conj_verb').style.color = "#BB4411";
        }
    }

    displayConj (oConjTable) {
        // function called when results come from the Worker
        if (oConjTable === null) {
            return;
        }
        try {
            this.xParent.getElementById('grammalecte_conj_verb').textContent = "";
            // infinitif
            this.xParent.getElementById('grammalecte_conj_infi').textContent = oConjTable["infi"] || " "; // something or nbsp
            // participe présent
            this.xParent.getElementById('grammalecte_conj_ppre').textContent = oConjTable["ppre"] || " ";
            // participes passés
            this.xParent.getElementById('grammalecte_conj_ppas1').textContent = oConjTable["ppas1"] || " ";
            this.xParent.getElementById('grammalecte_conj_ppas2').textContent = oConjTable["ppas2"] || " ";
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
            this.xParent.getElementById('grammalecte_conj_simp2').textContent = oConjTable["simp2"] || " ";
            this.xParent.getElementById('grammalecte_conj_simp3').textContent = oConjTable["simp3"] || " ";
            this.xParent.getElementById('grammalecte_conj_simp4').textContent = oConjTable["simp4"] || " ";
            this.xParent.getElementById('grammalecte_conj_simp5').textContent = oConjTable["simp5"] || " ";
            this.xParent.getElementById('grammalecte_conj_simp6').textContent = oConjTable["simp6"] || " ";
        }
        catch (e) {
            console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
        }
    }
}


class GrammalecteTooltip {








|







816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
            this.xParent.getElementById('grammalecte_conj_simp2').textContent = oConjTable["simp2"] || " ";
            this.xParent.getElementById('grammalecte_conj_simp3').textContent = oConjTable["simp3"] || " ";
            this.xParent.getElementById('grammalecte_conj_simp4').textContent = oConjTable["simp4"] || " ";
            this.xParent.getElementById('grammalecte_conj_simp5').textContent = oConjTable["simp5"] || " ";
            this.xParent.getElementById('grammalecte_conj_simp6').textContent = oConjTable["simp6"] || " ";
        }
        catch (e) {
            showError(e);
        }
    }
}


class GrammalecteTooltip {

936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
        catch (e) {
            let xSuggBlock = this.xParent.getElementById("grammalecte_tooltip_sugg_block");
            xSuggBlock.appendChild(document.createTextNode("# Oups. Le mécanisme de suggestion orthographique a rencontré un bug… (Ce module est encore en phase β.)"));
            showError(e);
        }
    }
}


class GrammalecteTextControl {

    constructor () {
        this.xNode = null;
        this.dParagraph = new Map();
        this.bTextArea = false;
        this.bIframe = false;
        this.bResultInEvent = false; // if true, the node content is not modified, but an event is dispatched on the node with the modified text
        this.xResultNode = null; // only useful if for text analysed without node
    }

    setNode (xNode) {
        this.clear();
        this.xNode = xNode;
        this.bResultInEvent = Boolean(xNode.dataset.grammalecte_result_via_event && xNode.dataset.grammalecte_result_via_event == "true");
        this.bTextArea = (xNode.tagName == "TEXTAREA" || xNode.tagName == "INPUT");
        this.bIframe = (xNode.tagName == "IFRAME");
        if (this.bTextArea) {
            this.xNode.disabled = true;
            this.loadText(this.xNode.value);
        }
        else if (this.bIframe) {
            // iframe
            if (!this.bResultInEvent) {
                oGrammalecte.oGCPanel.addMessageToGCPanel("⛔ La zone analysée est un cadre contenant une autre page web (“iframe”). Les changements faits ne peuvent être pas répercutés dans cette zone.");
            }
            this.loadText(this.xNode.contentWindow.document.body.innerText);
        }
        else {
            // editable node
            oGrammalecte.oGCPanel.addMessageToGCPanel("❗ La zone de texte analysée est un champ textuel enrichi susceptible de contenir des éléments non textuels qui seront effacés lors de la correction.");
            this.loadText(this.xNode.innerText);
        }
    }

    setResultNode (xNode) {
        if (xNode instanceof HTMLElement) {
            this.xResultNode = xNode;
            this.bResultInEvent = true;
        }
    }

    setText (sText) {
        this.clear();
        if (!this.xResultNode) {
            oGrammalecte.oGCPanel.addMessageToGCPanel("⛔ Aucun champ textuel défini. Les changements ne seront pas répercutés sur la zone d’où le texte a été extrait.");
        }
        this.loadText(sText);
    }

    loadText (sText) {
        // function also used by the text formatter
        if (typeof(sText) === "string") {
            this.dParagraph.clear();
            let i = 0;
            let iStart = 0;
            let iEnd = 0;
            sText = sText.replace(/\r\n/g, "\n").replace(/\r/g, "\n").normalize("NFC");
            while ((iEnd = sText.indexOf("\n", iStart)) !== -1) {
                this.dParagraph.set(i, sText.slice(iStart, iEnd));
                i++;
                iStart = iEnd+1;
            }
            this.dParagraph.set(i, sText.slice(iStart));
            //console.log("Paragraphs number: " + (i+1));
        }
    }

    clear () {
        if (this.xNode !== null) {
            this.xNode.disabled = false;
            this.bTextArea = false;
            this.bIframe = false;
            this.bResultInEvent = false;
            this.xNode = null;
            this.xResultNode = null;
        }
        this.dParagraph.clear();
    }

    getText () {
        return [...this.dParagraph.values()].join("\n").normalize("NFC");
    }

    setParagraph (iParagraph, sText) {
        this.dParagraph.set(iParagraph, sText);
    }

    getParagraph (iParaNum) {
        return this.dParagraph.get(iParaNum);
    }

    eraseNodeContent () {
        while (this.xNode.firstChild) {
            this.xNode.removeChild(this.xNode.firstChild);
        }
    }

    write () {
        if (this.xNode !== null) {
            if (this.bResultInEvent) {
                const xEvent = new CustomEvent("GrammalecteResult", { detail: JSON.stringify({ sType: "text", sText: this.getText() }) });
                this.xNode.dispatchEvent(xEvent);
                //console.log("[Grammalecte debug] Text sent to xNode via event:", xEvent.detail);
            }
            else if (this.bTextArea) {
                this.xNode.value = this.getText();
                //console.log("[Grammalecte debug] text written in textarea:", this.getText());
            }
            else if (this.bIframe) {
                //console.log(this.getText());
            }
            else {
                this.eraseNodeContent();
                this.dParagraph.forEach((val, key) => {
                    this.xNode.appendChild(document.createTextNode(val.normalize("NFC")));
                    this.xNode.appendChild(document.createElement("br"));
                });
                //console.log("[Grammalecte debug] text written in editable node:", this.getText());
            }
        }
        else if (this.xResultNode !== null) {
            const xEvent = new CustomEvent("GrammalecteResult", { detail: JSON.stringify({ sType: "text", sText: this.getText() }) });
            this.xResultNode.dispatchEvent(xEvent);
            //console.log("[Grammalecte debug] Text sent to xResultNode via event:", xEvent.detail);
        }
    }
}







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
973
974
975
976
977
978
979


































































































































        catch (e) {
            let xSuggBlock = this.xParent.getElementById("grammalecte_tooltip_sugg_block");
            xSuggBlock.appendChild(document.createTextNode("# Oups. Le mécanisme de suggestion orthographique a rencontré un bug… (Ce module est encore en phase β.)"));
            showError(e);
        }
    }
}


































































































































Modified gc_lang/fr/webext/content_scripts/panel_tf.js from [c58813ca49] to [dd32e278d0].

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88




89

90
91
92
93
94
95
96
            xTypo.appendChild(this._createLigaturesSelection());
            let xMisc = this._createFieldset("group_misc", true, "Divers");
            xMisc.appendChild(this._createOrdinalOptions());
            xMisc.appendChild(this._createBlockOption("o_etc", true, "Et cætera, etc."));
            xMisc.appendChild(this._createBlockOption("o_missing_hyphens", true, "Traits d’union manquants"));
            xMisc.appendChild(this._createBlockOption("o_ma_word", true, "Apostrophes manquantes"));
            xMisc.appendChild(this._createSingleLetterOptions());
            let xStruct = this._createFieldset("group_struct", false, "Restructuration [!]");
            xStruct.appendChild(this._createBlockOption("o_remove_hyphens_at_end_of_paragraphs", false, "Enlever césures en fin de ligne/paragraphe [!]"));
            xStruct.appendChild(this._createBlockOption("o_merge_contiguous_paragraphs", false, "Fusionner les paragraphes contigus [!]"));
            xColumn1.appendChild(xSSP);
            xColumn1.appendChild(xSpace);
            xColumn1.appendChild(xNBSP);
            xColumn1.appendChild(xDelete);
            xColumn2.appendChild(xTypo);
            xColumn2.appendChild(xMisc);




            xColumn2.appendChild(xStruct);

            xOptions.appendChild(xColumn1);
            xOptions.appendChild(xColumn2);
            // Actions
            let xActions = oGrammalecte.createNode("div", {id: "grammalecte_tf_actions"});
            let xDefaultButton = oGrammalecte.createNode("div", {id: "grammalecte_tf_reset", textContent: "Par défaut", className: "grammalecte_tf_button"});
            xDefaultButton.addEventListener("click", () => { this.reset(); });
            let xApplyButton = oGrammalecte.createNode("div", {id: "grammalecte_tf_apply", textContent: "Appliquer", className: "grammalecte_tf_button"});







<
<
<






>
>
>
>
|
>







73
74
75
76
77
78
79



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
            xTypo.appendChild(this._createLigaturesSelection());
            let xMisc = this._createFieldset("group_misc", true, "Divers");
            xMisc.appendChild(this._createOrdinalOptions());
            xMisc.appendChild(this._createBlockOption("o_etc", true, "Et cætera, etc."));
            xMisc.appendChild(this._createBlockOption("o_missing_hyphens", true, "Traits d’union manquants"));
            xMisc.appendChild(this._createBlockOption("o_ma_word", true, "Apostrophes manquantes"));
            xMisc.appendChild(this._createSingleLetterOptions());



            xColumn1.appendChild(xSSP);
            xColumn1.appendChild(xSpace);
            xColumn1.appendChild(xNBSP);
            xColumn1.appendChild(xDelete);
            xColumn2.appendChild(xTypo);
            xColumn2.appendChild(xMisc);
            if (!bThunderbird) {
                let xStruct = this._createFieldset("group_struct", false, "Restructuration [!]");
                xStruct.appendChild(this._createBlockOption("o_remove_hyphens_at_end_of_paragraphs", false, "Enlever césures en fin de ligne/paragraphe [!]"));
                xStruct.appendChild(this._createBlockOption("o_merge_contiguous_paragraphs", false, "Fusionner les paragraphes contigus [!]"));
                xColumn2.appendChild(xStruct);
            }
            xOptions.appendChild(xColumn1);
            xOptions.appendChild(xColumn2);
            // Actions
            let xActions = oGrammalecte.createNode("div", {id: "grammalecte_tf_actions"});
            let xDefaultButton = oGrammalecte.createNode("div", {id: "grammalecte_tf_reset", textContent: "Par défaut", className: "grammalecte_tf_button"});
            xDefaultButton.addEventListener("click", () => { this.reset(); });
            let xApplyButton = oGrammalecte.createNode("div", {id: "grammalecte_tf_apply", textContent: "Appliquer", className: "grammalecte_tf_button"});
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
            // end of processing

            //window.setCursor("auto"); // restore pointer

            const t1 = Date.now();
            this.xParent.getElementById('grammalecte_tf_time_res').textContent = this.getTimeRes((t1-t0)/1000);
            oGrammalecte.oGCPanel.oTextControl.loadText(sText);
            oGrammalecte.oGCPanel.oTextControl.write();
            this.bTextChanged = true;
        }
        catch (e) {
            showError(e);
        }
    }








<







523
524
525
526
527
528
529

530
531
532
533
534
535
536
            // end of processing

            //window.setCursor("auto"); // restore pointer

            const t1 = Date.now();
            this.xParent.getElementById('grammalecte_tf_time_res').textContent = this.getTimeRes((t1-t0)/1000);
            oGrammalecte.oGCPanel.oTextControl.loadText(sText);

            this.bTextChanged = true;
        }
        catch (e) {
            showError(e);
        }
    }

Modified gc_lang/fr/webext/manifest.json from [8dac256bfb] to [9dc86ec3bd].

45
46
47
48
49
50
51

52
53
54
55
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
      "matches": ["<all_urls>"],
      "exclude_matches": [
        "*://*.wikisource.org/*",
        "*://*.wikipedia.org/*",
        "*://*.wiktionary.org/*"
      ],
      "js": [

        "content_scripts/html_src.js",
        "content_scripts/panel.js",
        "grammalecte/fr/textformatter.js",
        "content_scripts/panel_tf.js",
        "content_scripts/panel_gc.js",
        "content_scripts/message_box.js",
        "content_scripts/menu.js",
        "content_scripts/init.js"
      ],
      "run_at": "document_end"
    },
    {
      "matches": [
        "*://*.wikisource.org/*",
        "*://*.wikipedia.org/*",
        "*://*.wiktionary.org/*"
      ],
      "js": [

        "content_scripts/html_src.js",
        "content_scripts/panel.js",
        "grammalecte/fr/textformatter.js",
        "content_scripts/panel_tf.js",
        "content_scripts/panel_gc.js",

        "content_scripts/menu.js",
        "content_scripts/init.js"
      ],
      "run_at": "document_idle"
    }
  ],








>


















>





>







45
46
47
48
49
50
51
52
53
54
55
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
84
      "matches": ["<all_urls>"],
      "exclude_matches": [
        "*://*.wikisource.org/*",
        "*://*.wikipedia.org/*",
        "*://*.wiktionary.org/*"
      ],
      "js": [
        "content_scripts/editor.js",
        "content_scripts/html_src.js",
        "content_scripts/panel.js",
        "grammalecte/fr/textformatter.js",
        "content_scripts/panel_tf.js",
        "content_scripts/panel_gc.js",
        "content_scripts/message_box.js",
        "content_scripts/menu.js",
        "content_scripts/init.js"
      ],
      "run_at": "document_end"
    },
    {
      "matches": [
        "*://*.wikisource.org/*",
        "*://*.wikipedia.org/*",
        "*://*.wiktionary.org/*"
      ],
      "js": [
        "content_scripts/editor.js",
        "content_scripts/html_src.js",
        "content_scripts/panel.js",
        "grammalecte/fr/textformatter.js",
        "content_scripts/panel_tf.js",
        "content_scripts/panel_gc.js",
        "content_scripts/message_box.js",
        "content_scripts/menu.js",
        "content_scripts/init.js"
      ],
      "run_at": "document_idle"
    }
  ],

Modified gc_lang/fr/webext/panel/conjugueur.html from [78627e28af] to [9eb29a89d3].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!DOCTYPE HTML>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="conjugueur.css" />
        <title>Grammalecte · Conjugueur</title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    </head>
    
    <body>
        <header>
            <div class="mainflow">
                <div class="logo" style="margin: -10px 0 0 0;">
                    <img src="../img/logo-96.png" alt="" />
                </div>
            </div>







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!DOCTYPE HTML>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="conjugueur.css" />
        <title>Grammalecte · Conjugueur</title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    </head>

    <body>
        <header>
            <div class="mainflow">
                <div class="logo" style="margin: -10px 0 0 0;">
                    <img src="../img/logo-96.png" alt="" />
                </div>
            </div>
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
                    <div id="conjugate">Conjuguer</div>
                </div>

                <h1 id="verb_title" class="center">&nbsp;</h1>
                <p id="info" class="center">&nbsp;</p>

                <p id="options">
                    <label for="oneg">Négative</label> <input type="checkbox" id="oneg" name="oneg" value="ON"  /> 
                    · <label for="oint">Interrogative</label> <input type="checkbox" id="oint" name="oint" value="ON"  />
                    · <label for="ofem">Féminin</label> <input type="checkbox" id="ofem" name="ofem" value="ON"  />
                    · <label id="opro_lbl" for="opro">Pronominal</label> <input type="checkbox" id="opro" name="opro" value="ON"  />
                    · <label id="otco_lbl" for="otco">Temps composés</label> <input type="checkbox" id="otco" name="otco" value="ON"  />
                </p>
                <p id="smallnote">❦</p>
                    
                <div class="clearer"></div>

                <!-- section 1 -->
                <div class="container">
                    <div class="colonne">
                        <div id="infinitif" class="box">
                            <h2 id="infinitif_title">Infinitif</h2>
                            <p id="infi">&nbsp;</p>
                        </div>
                        <div id="imperatif" class="box">
                            <h2 id="imperatif_title">Impératif</h2>
                            <h3 id="impe_temps">Présent</h3>
                            <p id="impe1">&nbsp;</p>
                            <p id="impe2">&nbsp;</p>
                            <p id="impe3">&nbsp;</p>
                        </div>
                    </div>
                    
                    <div class="colonne">
                        <div id="partpre" class="box">
                            <h2 id="partpre_title">Participe présent</h2>
                            <p id="ppre">&nbsp;</p>
                        </div>
                        <div id="partpas" class="box">
                            <h2 id="partpas_title">Participes passés</h2>







|
|





|

















|







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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
                    <div id="conjugate">Conjuguer</div>
                </div>

                <h1 id="verb_title" class="center">&nbsp;</h1>
                <p id="info" class="center">&nbsp;</p>

                <p id="options">
                    <label for="oneg">Négation</label> <input type="checkbox" id="oneg" name="oneg" value="ON"  />
                    · <label for="oint">Interrogatif</label> <input type="checkbox" id="oint" name="oint" value="ON"  />
                    · <label for="ofem">Féminin</label> <input type="checkbox" id="ofem" name="ofem" value="ON"  />
                    · <label id="opro_lbl" for="opro">Pronominal</label> <input type="checkbox" id="opro" name="opro" value="ON"  />
                    · <label id="otco_lbl" for="otco">Temps composés</label> <input type="checkbox" id="otco" name="otco" value="ON"  />
                </p>
                <p id="smallnote">❦</p>

                <div class="clearer"></div>

                <!-- section 1 -->
                <div class="container">
                    <div class="colonne">
                        <div id="infinitif" class="box">
                            <h2 id="infinitif_title">Infinitif</h2>
                            <p id="infi">&nbsp;</p>
                        </div>
                        <div id="imperatif" class="box">
                            <h2 id="imperatif_title">Impératif</h2>
                            <h3 id="impe_temps">Présent</h3>
                            <p id="impe1">&nbsp;</p>
                            <p id="impe2">&nbsp;</p>
                            <p id="impe3">&nbsp;</p>
                        </div>
                    </div>

                    <div class="colonne">
                        <div id="partpre" class="box">
                            <h2 id="partpre_title">Participe présent</h2>
                            <p id="ppre">&nbsp;</p>
                        </div>
                        <div id="partpas" class="box">
                            <h2 id="partpas_title">Participes passés</h2>
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
                                <p id="ifut3">&nbsp;</p>
                                <p id="ifut4">&nbsp;</p>
                                <p id="ifut5">&nbsp;</p>
                                <p id="ifut6">&nbsp;</p>
                            </div>
                        </div>
                    </div>
                    
                    <div class="colonne">
                        <div id="subjonctif" class="box">
                            <h2 id="subjontif_title">Subjonctif</h2>
                            <div id="spre">
                                <h3 id="spre_temps">Présent</h3>
                                <p id="spre1">&nbsp;</p>
                                <p id="spre2">&nbsp;</p>







|







109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
                                <p id="ifut3">&nbsp;</p>
                                <p id="ifut4">&nbsp;</p>
                                <p id="ifut5">&nbsp;</p>
                                <p id="ifut6">&nbsp;</p>
                            </div>
                        </div>
                    </div>

                    <div class="colonne">
                        <div id="subjonctif" class="box">
                            <h2 id="subjontif_title">Subjonctif</h2>
                            <div id="spre">
                                <h3 id="spre_temps">Présent</h3>
                                <p id="spre1">&nbsp;</p>
                                <p id="spre2">&nbsp;</p>
167
168
169
170
171
172
173
174
175

        </div>

        <script src="../grammalecte/graphspell/helpers.js"></script>
        <script src="../grammalecte/fr/conj.js"></script>
        <script src="conjugueur.js"></script>
    </body>
    
</html>







|

167
168
169
170
171
172
173
174
175

        </div>

        <script src="../grammalecte/graphspell/helpers.js"></script>
        <script src="../grammalecte/fr/conj.js"></script>
        <script src="conjugueur.js"></script>
    </body>

</html>

Modified gc_lang/fr/webext/panel/conjugueur.js from [d64a44e001] to [bcf093f6ff].

73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
                    document.getElementById('otco').disabled = true;
                    document.getElementById('otco_lbl').style = "color: #CCC;";
                    document.getElementById('smallnote').textContent = "Ce verbe n’a pas encore été vérifié. C’est pourquoi les options “pronominal” et “temps composés” sont désactivées.";
                } else {
                    document.getElementById('otco').disabled = false;
                    document.getElementById('otco_lbl').style = "color: #000;";
                    if (oVerb.nPronominable == 0) {
                        document.getElementById('opro').checked = false;
                        document.getElementById('opro').disabled = false;
                        document.getElementById('opro_lbl').style = "color: #000;";
                    } else if (oVerb.nPronominable == 1) {
                        document.getElementById('opro').checked = true;
                        document.getElementById('opro').disabled = true;
                        document.getElementById('opro_lbl').style = "color: #CCC;";
                    } else { // -1 or 1 or error







<







73
74
75
76
77
78
79

80
81
82
83
84
85
86
                    document.getElementById('otco').disabled = true;
                    document.getElementById('otco_lbl').style = "color: #CCC;";
                    document.getElementById('smallnote').textContent = "Ce verbe n’a pas encore été vérifié. C’est pourquoi les options “pronominal” et “temps composés” sont désactivées.";
                } else {
                    document.getElementById('otco').disabled = false;
                    document.getElementById('otco_lbl').style = "color: #000;";
                    if (oVerb.nPronominable == 0) {

                        document.getElementById('opro').disabled = false;
                        document.getElementById('opro_lbl').style = "color: #000;";
                    } else if (oVerb.nPronominable == 1) {
                        document.getElementById('opro').checked = true;
                        document.getElementById('opro').disabled = true;
                        document.getElementById('opro_lbl').style = "color: #CCC;";
                    } else { // -1 or 1 or error

Modified helpers.py from [20b8bddd75] to [36dfdf0199].

115
116
117
118
119
120
121








122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138


def copyAndFileTemplate (spfSrc, spfDst, dVars):
    "write file <spfSrc> as <spfDst> with variables filed with <dVars>"
    sText = Template(open(spfSrc, "r", encoding="utf-8").read()).safe_substitute(dVars)
    open(spfDst, "w", encoding="utf-8", newline="\n").write(sText)










def addFolderToZipAndFileFile (hZip, spSrc, spDst, dVars, bRecursive):
    "add folder content to zip archive and file files with <dVars>"
    # recursive function
    spSrc = spSrc.strip("/ ")
    spDst = spDst.strip("/ ")
    for sf in os.listdir(spSrc):
        spfSrc = (spSrc + "/" + sf).strip("/ ")
        spfDst = (spDst + "/" + sf).strip("/ ")
        if os.path.isdir(spfSrc):
            if bRecursive:
                addFolderToZipAndFileFile(hZip, spfSrc, spfDst, dVars, bRecursive)
        else:
            if spfSrc.endswith((".py", ".js", ".json", ".css", ".xcu", ".xul", ".rdf", ".dtd", ".properties")):
                hZip.writestr(spfDst, fileFile(spfSrc, dVars))
            else:
                hZip.write(spfSrc, spfDst)







>
>
>
>
>
>
>
>













<
<
<
|
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142



143


def copyAndFileTemplate (spfSrc, spfDst, dVars):
    "write file <spfSrc> as <spfDst> with variables filed with <dVars>"
    sText = Template(open(spfSrc, "r", encoding="utf-8").read()).safe_substitute(dVars)
    open(spfDst, "w", encoding="utf-8", newline="\n").write(sText)


def addFileToZipAndFileFile (hZip, spfSrc, spfDst, dVars):
    "add a file to zip archive and file it with <dVars>"
    if spfSrc.endswith((".py", ".js", ".json", ".html", ".htm", ".css", ".xcu", ".xul", ".rdf", ".dtd", ".properties")):
        hZip.writestr(spfDst, fileFile(spfSrc, dVars))
    else:
        hZip.write(spfSrc, spfDst)


def addFolderToZipAndFileFile (hZip, spSrc, spDst, dVars, bRecursive):
    "add folder content to zip archive and file files with <dVars>"
    # recursive function
    spSrc = spSrc.strip("/ ")
    spDst = spDst.strip("/ ")
    for sf in os.listdir(spSrc):
        spfSrc = (spSrc + "/" + sf).strip("/ ")
        spfDst = (spDst + "/" + sf).strip("/ ")
        if os.path.isdir(spfSrc):
            if bRecursive:
                addFolderToZipAndFileFile(hZip, spfSrc, spfDst, dVars, bRecursive)
        else:



            addFileToZipAndFileFile(hZip, spfSrc, spfDst, dVars)