Grammalecte  Check-in [0ecc0883e5]

Overview
Comment:[tb] deprecated code
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | tb
Files: files | file ages | folders
SHA3-256: 0ecc0883e559a0177d1b5898d782a7f8560bb9ab8e870522e0ff15e904cf4e8f
User & Date: olr on 2018-08-07 13:02:33
Other Links: manifest | tags
Context
2018-08-07
13:04
[tb] deprecated code (Hunspell dictionaries) check-in: 119918b0a7 user: olr tags: tb, trunk
13:02
[tb] deprecated code check-in: 0ecc0883e5 user: olr tags: tb, trunk
12:40
[tb] code cleaning: fix import (not necessary for TextDecoder, TextEncoder) check-in: 8ea07ff627 user: olr tags: tb, trunk
Changes

Modified gc_lang/fr/tb/content/overlay.js from [f448460dc2] to [7e5b745ad7].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
...
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
...
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
...
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
...
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
...
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
...
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
...
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
...
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
...
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
...
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
...
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
...
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
...
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
// 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 Task = ChromeUtils.import("resource://gre/modules/Task.jsm").Task;
const prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).getBranch("extensions.grammarchecker.");

//const text = require("resource://grammalecte/text.js");
................................................................................
            }
            return nParagraph;
        }).then(function (res) {
            that.setInfo("Nombre de paragraphes analysés : " + res);
        }, function (e) {
            that.setInfo("Erreur : " + e.message);
            console.error(e);
            // Cu.reportError(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;
................................................................................
                }
            }, function (res) {
                xResultNode.textContent = "Erreur: " + res;
            });
        }
        catch (e) {
            console.error(e);
            // Cu.reportError(e);
        }
    },
    fillResultNode: function (xResultNode, xEditor, sParagraph, iParagraph, aGrammErr, aSpellErr) {
        try {
            if (aGrammErr.length === 0  &&  aSpellErr.length === 0) {
                return null;
            }
................................................................................
            xResultNode.appendChild(xParagraphNode);
            for (let xNode of lNodeError) {
                xResultNode.appendChild(xNode);
            }
        }
        catch (e) {
            console.error(e);
            // Cu.reportError(e);
            xResultNode.textContent = "# Error: " + e.message;
        }
    },
    _createNodeGCErrorDescription: function (xEditor, nError, dErr, iParagraph) {
        let xNodeDiv = document.createElement("div");
        let that = this;
        // message
................................................................................
            xNavBar.currentSet = aSet.join(",");
            document.persist(xNavBar.id, "currentset");
            try {
                BrowserToolboxCustomizeDone(true);
            }
            catch (e) {
                console.error(e);
                // Cu.reportError(e);
            }
        }
    },
    clearPreview: function() {
        let xPreview = document.getElementById("grammalecte-errors");
        while (xPreview.firstChild) {
            xPreview.removeChild(xPreview.firstChild);
................................................................................
        if (xEditor != null) {
            try {
                xEditor.QueryInterface(Ci.nsIEditorStyleSheets);
                xEditor.addOverrideStyleSheet("chrome://grammarchecker/content/overlay.css");
            }
            catch (e) {
                console.error(e);
                // Cu.reportError(e);
            }
        }
        this.setInfo("[vide]");
    },
    setInfo: function (sText) {
        document.getElementById("grammalecte-info").textContent = sText;
    },
................................................................................
    },
    openDialog: function (sWhat, sName="", sOptions="") {
        try {
            window.openDialog(sWhat, sName, sOptions);
        }
        catch (e) {
            console.error(e);
            // Cu.reportError(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");
................................................................................
            xWin.focus();
            if (xTabmail) {
                xTabmail.openTab('contentTab', { contentPage: sURL });
            }
        }
        catch (e) {
            console.error(e);
            // Cu.reportError(e);
        }
    },
    openInBrowserURL: function (sURL) {
        // method found in S3.Google.Translator
        try {
            openURL(sURL);
        }
        catch (e) {
            console.error(e);
            // Cu.reportError(e);
        }
    },
    onParseText: function (e) {
        this.parse();
    },
    onClosePanel: function (e) {
        this.closePanel();
................................................................................
    },
    _setDictionary: function (sDicName, sOptName) {
        try {
            oSpellControl.setExtensionDictFolder(sDicName, prefs.getBoolPref(sOptName));
        }
        catch (e) {
            console.error(e);
            // Cu.reportError(e);
        }
    }
}


var oTextFormatter = {
    init: function () {
................................................................................
                this.resetProgressBar();
            } else {
                this.reset();
            }
        }
        catch (e) {
            console.error(e);
            // Cu.reportError(e);
        }
    },
    apply: function () {
        try {
            this.saveOptions();
            this.resetProgressBar();
            let xEditor = new Editor();
................................................................................
            for (let sParagraph of text.getParagraph(sText)) {
                xEditor.writeParagraph(iParagraph, sParagraph);
                iParagraph += 1;
            }
        }
        catch (e) {
            console.error(e);
            // Cu.reportError(e);
        }
    },
    saveOptions: function () {
        let oOptions = {};
        for (let xNode of document.getElementsByClassName("option")) {
            oOptions[xNode.id] = xNode.checked;
        }
................................................................................
                if (xNode.id.startsWith("o_group_")) {
                    this.switchGroup(xNode.id);
                }
            }
        }
        catch (e) {
            console.error(e);
            // Cu.reportError(e);
        }
    },
    resetProgressBar: function () {
        document.getElementById('progressbar').value = 0;
        document.getElementById('time_res').textContent = "";
    },
    getTimeRes: function (n) {
................................................................................

            //window.setCursor("auto"); // restore pointer
            const t1 = Date.now();
            document.getElementById('time_res').textContent = this.getTimeRes((t1-t0)/1000);
        }
        catch (e) {
            console.error(e);
            // Cu.reportError(e);
        }
        return sText;
    },
    formatText: function (sText, sOptName) {
        let nCount = 0;
        try {
            if (!oReplTable.hasOwnProperty(sOptName)) {
................................................................................
            for (let [zRgx, sRep] of oReplTable[sOptName]) {
                nCount += (sText.match(zRgx) || []).length;
                sText = sText.replace(zRgx, sRep);
            }
        }
        catch (e) {
            console.error(e);
            // Cu.reportError(e);
        }
        return [sText, nCount];
    }
}


/* EVENTS */







|







 







<







 







<







 







<







 







<







 







<







 







<







 







<









<







 







<







 







<







 







<







 







<







 







<







 







<







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
...
165
166
167
168
169
170
171

172
173
174
175
176
177
178
...
193
194
195
196
197
198
199

200
201
202
203
204
205
206
...
243
244
245
246
247
248
249

250
251
252
253
254
255
256
...
391
392
393
394
395
396
397

398
399
400
401
402
403
404
...
407
408
409
410
411
412
413

414
415
416
417
418
419
420
...
427
428
429
430
431
432
433

434
435
436
437
438
439
440
...
442
443
444
445
446
447
448

449
450
451
452
453
454
455
456
457

458
459
460
461
462
463
464
...
518
519
520
521
522
523
524

525
526
527
528
529
530
531
...
537
538
539
540
541
542
543

544
545
546
547
548
549
550
...
554
555
556
557
558
559
560

561
562
563
564
565
566
567
...
597
598
599
600
601
602
603

604
605
606
607
608
609
610
...
873
874
875
876
877
878
879

880
881
882
883
884
885
886
...
890
891
892
893
894
895
896

897
898
899
900
901
902
903
// 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 Task = ChromeUtils.import("resource://gre/modules/Task.jsm").Task;
const prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).getBranch("extensions.grammarchecker.");

//const text = require("resource://grammalecte/text.js");
................................................................................
            }
            return nParagraph;
        }).then(function (res) {
            that.setInfo("Nombre de paragraphes analysés : " + res);
        }, function (e) {
            that.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;
................................................................................
                }
            }, 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;
            }
................................................................................
            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
................................................................................
            xNavBar.currentSet = aSet.join(",");
            document.persist(xNavBar.id, "currentset");
            try {
                BrowserToolboxCustomizeDone(true);
            }
            catch (e) {
                console.error(e);

            }
        }
    },
    clearPreview: function() {
        let xPreview = document.getElementById("grammalecte-errors");
        while (xPreview.firstChild) {
            xPreview.removeChild(xPreview.firstChild);
................................................................................
        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;
    },
................................................................................
    },
    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");
................................................................................
            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();
................................................................................
    },
    _setDictionary: function (sDicName, sOptName) {
        try {
            oSpellControl.setExtensionDictFolder(sDicName, prefs.getBoolPref(sOptName));
        }
        catch (e) {
            console.error(e);

        }
    }
}


var oTextFormatter = {
    init: function () {
................................................................................
                this.resetProgressBar();
            } else {
                this.reset();
            }
        }
        catch (e) {
            console.error(e);

        }
    },
    apply: function () {
        try {
            this.saveOptions();
            this.resetProgressBar();
            let xEditor = new Editor();
................................................................................
            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;
        }
................................................................................
                if (xNode.id.startsWith("o_group_")) {
                    this.switchGroup(xNode.id);
                }
            }
        }
        catch (e) {
            console.error(e);

        }
    },
    resetProgressBar: function () {
        document.getElementById('progressbar').value = 0;
        document.getElementById('time_res').textContent = "";
    },
    getTimeRes: function (n) {
................................................................................

            //window.setCursor("auto"); // restore pointer
            const t1 = Date.now();
            document.getElementById('time_res').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)) {
................................................................................
            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 */