Grammalecte  Check-in [be4cac56bf]

Overview
Comment:[fx] code clarification: use one object dedicated to communication between content-script and background
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | fx
Files: files | file ages | folders
SHA3-256: be4cac56bf2b44f37abc13048d7e530e83a49d5017a546f1536444a8f2411b22
User & Date: olr on 2020-03-13 17:08:14
Other Links: manifest | tags
Context
2020-03-13
19:37
[fx] Grammalecte API: parseNode -> result as JSON check-in: 15fc2e7c11 user: olr tags: fx, trunk
17:08
[fx] code clarification: use one object dedicated to communication between content-script and background check-in: be4cac56bf user: olr tags: fx, trunk
2020-03-12
23:53
[fr] ajustements check-in: bdd6bc1361 user: olr tags: fr, trunk
Changes

Modified gc_lang/fr/webext/content_scripts/init.js from [e10aed13d1] to [6fdc529374].

   168    168           this.oGCPanel.clear();
   169    169           this.oGCPanel.show();
   170    170           this.oGCPanel.showEditor();
   171    171           this.oGCPanel.start(what);
   172    172           this.oGCPanel.startWaitIcon();
   173    173           if (what && bCheckText) {
   174    174               let sText = this.oGCPanel.oTextControl.getText();
   175         -            xGrammalectePort.postMessage({
   176         -                sCommand: "parseAndSpellcheck",
   177         -                dParam: {sText: sText, sCountry: "FR", bDebug: false, bContext: false},
   178         -                dInfo: (what.nodeType && what.nodeType === 1) ? {sTextAreaId: what.id} : {}
   179         -            });
          175  +            oGrammalecteBackgroundPort.parseAndSpellcheck(sText, "__GrammalectePanel__");
   180    176           }
   181    177       },
   182    178   
   183    179       showMessage: function (sMessage) {
   184    180           this.createMessageBox();
   185    181           this.oMessageBox.show();
   186    182           this.oMessageBox.setMessage(sMessage);
................................................................................
   304    300   
   305    301   autoRefreshOption();
   306    302   
   307    303   
   308    304   /*
   309    305       Connexion to the background
   310    306   */
   311         -let xGrammalectePort = browser.runtime.connect({name: "content-script port"});
          307  +const oGrammalecteBackgroundPort = {
          308  +
          309  +    xConnect: browser.runtime.connect({name: "content-script port"}),
          310  +
          311  +    /*
          312  +        Send messages to the background
          313  +        object {
          314  +            sCommand: the action to perform
          315  +            dParam: parameters necessary for the execution of the action
          316  +            dInfo: all kind of informations that needs to be sent back (usually to know where to use the result)
          317  +        }
          318  +    */
          319  +    parseAndSpellcheck: function (sText, sDestination) {
          320  +        this.xConnect.postMessage({
          321  +            sCommand: "parseAndSpellcheck",
          322  +            dParam: { sText: sText, sCountry: "FR", bDebug: false, bContext: false },
          323  +            dInfo: { sDestination: sDestination }
          324  +        });
          325  +    },
          326  +
          327  +    parseAndSpellcheck1: function (sText, sDestination, sParagraphId) {
          328  +        this.xConnect.postMessage({
          329  +            sCommand: "parseAndSpellcheck1",
          330  +            dParam: { sText: sText, sCountry: "FR", bDebug: false, bContext: false },
          331  +            dInfo: { sDestination: sDestination, sParagraphId: sParagraphId }
          332  +        });
          333  +    },
          334  +
          335  +    getListOfTokens: function (sText) {
          336  +        this.xConnect.postMessage({ sCommand: "getListOfTokens", dParam: { sText: sText }, dInfo: {} });
          337  +    },
          338  +
          339  +    parseFull: function (sText) {
          340  +        this.xConnect.postMessage({
          341  +            sCommand: "parseFull",
          342  +            dParam: { sText: sTex, sCountry: "FR", bDebug: false, bContext: false },
          343  +            dInfo: {}
          344  +        });
          345  +    },
          346  +
          347  +    getVerb: function (sVerb, bStart=true, bPro=false, bNeg=false, bTpsCo=false, bInt=false, bFem=false) {
          348  +        this.xConnect.postMessage({
          349  +            sCommand: "getVerb",
          350  +            dParam: { sVerb: sVerb, bPro: bPro, bNeg: bNeg, bTpsCo: bTpsCo, bInt: bInt, bFem: bFem },
          351  +            dInfo: { bStart: bStart }
          352  +        });
          353  +    },
          354  +
          355  +    getSpellSuggestions: function (sWord, sErrorId) {
          356  +        this.xConnect.postMessage({ sCommand: "getSpellSuggestions", dParam: { sWord: sWord }, dInfo: { sErrorId: sErrorId } });
          357  +    },
          358  +
          359  +    openURL: function (sURL) {
          360  +        this.xConnect.postMessage({ sCommand: "openURL", dParam: { "sURL": sURL }, dInfo: null });
          361  +    },
          362  +
          363  +    openLexiconEditor: function () {
          364  +        this.xConnect.postMessage({ sCommand: "openLexiconEditor", dParam: null, dInfo: null });
          365  +    },
          366  +
          367  +    restartWorker: function (nTimeDelay=10) {
          368  +        this.xConnect.postMessage({ sCommand: "restartWorker", dParam: { "nTimeDelay": nTimeDelay }, dInfo: {} });
          369  +    },
   312    370   
   313         -xGrammalectePort.onMessage.addListener(function (oMessage) {
   314         -    let {sActionDone, result, dInfo, bEnd, bError} = oMessage;
   315         -    switch (sActionDone) {
   316         -        case "init":
   317         -            oGrammalecte.sExtensionUrl = oMessage.sUrl;
   318         -            oGrammalecte.listenRightClick();
   319         -            oGrammalecte.createButtons();
   320         -            oGrammalecte.observePage();
   321         -            break;
   322         -        case "parseAndSpellcheck":
   323         -            if (!bEnd) {
   324         -                oGrammalecte.oGCPanel.addParagraphResult(result);
   325         -            } else {
   326         -                oGrammalecte.oGCPanel.stopWaitIcon();
   327         -                oGrammalecte.oGCPanel.endTimer();
   328         -            }
   329         -            break;
   330         -        case "parseAndSpellcheck1":
   331         -            oGrammalecte.oGCPanel.refreshParagraph(dInfo.sParagraphId, result);
   332         -            break;
   333         -        case "parseFull":
   334         -            // TODO
   335         -            break;
   336         -        case "getListOfTokens":
   337         -            if (!bEnd) {
   338         -                oGrammalecte.oGCPanel.addListOfTokens(result);
   339         -            } else {
   340         -                oGrammalecte.oGCPanel.stopWaitIcon();
   341         -                oGrammalecte.oGCPanel.endTimer();
          371  +    /*
          372  +        Messages from the background
          373  +    */
          374  +    listen: function () {
          375  +        this.xConnect.onMessage.addListener(function (oMessage) {
          376  +            let {sActionDone, result, dInfo, bEnd, bError} = oMessage;
          377  +            switch (sActionDone) {
          378  +                case "init":
          379  +                    oGrammalecte.sExtensionUrl = oMessage.sUrl;
          380  +                    oGrammalecte.listenRightClick();
          381  +                    oGrammalecte.createButtons();
          382  +                    oGrammalecte.observePage();
          383  +                    break;
          384  +                case "parseAndSpellcheck":
          385  +                    if (dInfo.sDestination == "__GrammalectePanel__") {
          386  +                        if (!bEnd) {
          387  +                            oGrammalecte.oGCPanel.addParagraphResult(result);
          388  +                        } else {
          389  +                            oGrammalecte.oGCPanel.stopWaitIcon();
          390  +                            oGrammalecte.oGCPanel.endTimer();
          391  +                        }
          392  +                    }
          393  +                    break;
          394  +                case "parseAndSpellcheck1":
          395  +                    if (dInfo.sDestination == "__GrammalectePanel__") {
          396  +                        oGrammalecte.oGCPanel.refreshParagraph(dInfo.sParagraphId, result);
          397  +                    }
          398  +                    break;
          399  +                case "parseFull":
          400  +                    // TODO
          401  +                    break;
          402  +                case "getListOfTokens":
          403  +                    if (!bEnd) {
          404  +                        oGrammalecte.oGCPanel.addListOfTokens(result);
          405  +                    } else {
          406  +                        oGrammalecte.oGCPanel.stopWaitIcon();
          407  +                        oGrammalecte.oGCPanel.endTimer();
          408  +                    }
          409  +                    break;
          410  +                case "getSpellSuggestions":
          411  +                    oGrammalecte.oGCPanel.oTooltip.setSpellSuggestionsFor(result.sWord, result.aSugg, result.iSuggBlock, dInfo.sErrorId);
          412  +                    break;
          413  +                case "getVerb":
          414  +                    if (dInfo.bStart) {
          415  +                        oGrammalecte.oGCPanel.conjugateWith(result.oVerb, result.oConjTable);
          416  +                    } else {
          417  +                        oGrammalecte.oGCPanel.displayConj(result.oConjTable);
          418  +                    }
          419  +                    break;
          420  +                case "workerRestarted":
          421  +                    oGrammalecte.oGCPanel.stopWaitIcon();
          422  +                    oGrammalecte.oGCPanel.showMessage("Le serveur grammatical a été arrêté et relancé.");
          423  +                    oGrammalecte.oGCPanel.endTimer();
          424  +                    break;
          425  +                /*
          426  +                    Commands received from the context menu
          427  +                    (Context menu are initialized in background)
          428  +                */
          429  +                // Grammar checker commands
          430  +                case "grammar_checker_editable":
          431  +                    if (oGrammalecte.xRightClickedNode !== null) {
          432  +                        oGrammalecte.startGCPanel(oGrammalecte.xRightClickedNode);
          433  +                    } else {
          434  +                        oGrammalecte.showMessage("Erreur. Le node sur lequel vous avez cliqué n’a pas pu être identifié. Sélectionnez le texte à corriger et relancez le correcteur via le menu contextuel.");
          435  +                    }
          436  +                    break;
          437  +                case "grammar_checker_page":
          438  +                    oGrammalecte.startGCPanel(oGrammalecte.getPageText());
          439  +                    break;
          440  +                case "grammar_checker_selection":
          441  +                    oGrammalecte.startGCPanel(result, false); // result is the selected text
          442  +                    // selected text is sent to the GC worker in the background script.
          443  +                    break;
          444  +                case "grammar_checker_iframe":
          445  +                    console.log("[Grammalecte] selected iframe: ", result);
          446  +                    if (document.activeElement.tagName == "IFRAME") {
          447  +                        //console.log(document.activeElement.id); frameId given by result is different than frame.id
          448  +                        oGrammalecte.startGCPanel(document.activeElement);
          449  +                    } else {
          450  +                        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.");
          451  +                    }
          452  +                    break;
          453  +                // rescan page command
          454  +                case "rescanPage":
          455  +                    oGrammalecte.rescanPage();
          456  +                    break;
          457  +                default:
          458  +                    console.log("[Content script] Unknown command: " + sActionDone);
   342    459               }
   343         -            break;
   344         -        case "getSpellSuggestions":
   345         -            oGrammalecte.oGCPanel.oTooltip.setSpellSuggestionsFor(result.sWord, result.aSugg, result.iSuggBlock, dInfo.sErrorId);
   346         -            break;
   347         -        case "getVerb":
   348         -            if (dInfo.bStart) {
   349         -                oGrammalecte.oGCPanel.conjugateWith(result.oVerb, result.oConjTable);
   350         -            } else {
   351         -                oGrammalecte.oGCPanel.displayConj(result.oConjTable);
   352         -            }
   353         -            break;
   354         -        case "workerRestarted":
   355         -            oGrammalecte.oGCPanel.stopWaitIcon();
   356         -            oGrammalecte.oGCPanel.showMessage("Le serveur grammatical a été arrêté et relancé.");
   357         -            oGrammalecte.oGCPanel.endTimer();
   358         -            break;
   359         -        /*
   360         -            Commands received from the context menu
   361         -            (Context menu are initialized in background)
   362         -        */
   363         -        // Grammar checker commands
   364         -        case "grammar_checker_editable":
   365         -            if (oGrammalecte.xRightClickedNode !== null) {
   366         -                oGrammalecte.startGCPanel(oGrammalecte.xRightClickedNode);
   367         -            } else {
   368         -                oGrammalecte.showMessage("Erreur. Le node sur lequel vous avez cliqué n’a pas pu être identifié. Sélectionnez le texte à corriger et relancez le correcteur via le menu contextuel.");
          460  +        });
          461  +    },
          462  +
          463  +    /*
          464  +        Other messages from background
          465  +    */
          466  +    listen2: function () {
          467  +        browser.runtime.onMessage.addListener(function (oMessage) {
          468  +            let {sActionRequest} = oMessage;
          469  +            let xActiveNode = document.activeElement;
          470  +            switch (sActionRequest) {
          471  +                /*
          472  +                    Commands received from the keyboard (shortcuts)
          473  +                */
          474  +                case "shortcutGrammarChecker":
          475  +                    if (xActiveNode && (xActiveNode.tagName == "TEXTAREA" || xActiveNode.tagName == "INPUT" || xActiveNode.isContentEditable)) {
          476  +                        oGrammalecte.startGCPanel(xActiveNode);
          477  +                    } else {
          478  +                        oGrammalecte.startGCPanel(oGrammalecte.getPageText());
          479  +                    }
          480  +                    break;
          481  +                default:
          482  +                    console.log("[Content script] Unknown command: " + sActionDone);
   369    483               }
   370         -            break;
   371         -        case "grammar_checker_page":
   372         -            oGrammalecte.startGCPanel(oGrammalecte.getPageText());
   373         -            break;
   374         -        case "grammar_checker_selection":
   375         -            oGrammalecte.startGCPanel(result, false); // result is the selected text
   376         -            // selected text is sent to the GC worker in the background script.
   377         -            break;
   378         -        case "grammar_checker_iframe":
   379         -            console.log("[Grammalecte] selected iframe: ", result);
   380         -            if (document.activeElement.tagName == "IFRAME") {
   381         -                //console.log(document.activeElement.id); frameId given by result is different than frame.id
   382         -                oGrammalecte.startGCPanel(document.activeElement);
   383         -            } else {
   384         -                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.");
   385         -            }
   386         -            break;
   387         -        // rescan page command
   388         -        case "rescanPage":
   389         -            oGrammalecte.rescanPage();
   390         -            break;
   391         -        default:
   392         -            console.log("[Content script] Unknown command: " + sActionDone);
          484  +        });
   393    485       }
   394         -});
          486  +}
          487  +
          488  +oGrammalecteBackgroundPort.listen()
          489  +oGrammalecteBackgroundPort.listen2()
   395    490   
   396    491   
   397    492   
   398    493   /*
   399    494       Callable API for the webpage.
   400    495       The API script must be injected this way to be callable by the page
   401    496   */
................................................................................
   428    523                   console.log("[Grammalecte] Event: Unknown command", oCommand.sCommand);
   429    524           }
   430    525       }
   431    526       catch (e) {
   432    527           showError(e);
   433    528       }
   434    529   });
   435         -
   436         -
   437         -
   438         -/*
   439         -    Other messages from background
   440         -*/
   441         -browser.runtime.onMessage.addListener(function (oMessage) {
   442         -    let {sActionRequest} = oMessage;
   443         -    let xActiveNode = document.activeElement;
   444         -    switch (sActionRequest) {
   445         -        /*
   446         -            Commands received from the keyboard (shortcuts)
   447         -        */
   448         -        case "shortcutGrammarChecker":
   449         -            if (xActiveNode && (xActiveNode.tagName == "TEXTAREA" || xActiveNode.tagName == "INPUT" || xActiveNode.isContentEditable)) {
   450         -                oGrammalecte.startGCPanel(xActiveNode);
   451         -            } else {
   452         -                oGrammalecte.startGCPanel(oGrammalecte.getPageText());
   453         -            }
   454         -            break;
   455         -        default:
   456         -            console.log("[Content script] Unknown command: " + sActionDone);
   457         -    }
   458         -});

Modified gc_lang/fr/webext/content_scripts/message_box.js from [1023251c05] to [bb68749e64].

     1      1   // JavaScript
     2      2   // Panel creator
     3      3   
     4      4   /* jshint esversion:6, -W097 */
     5      5   /* jslint esversion:6 */
     6         -/* global oGrammalecte, xGrammalectePort, showError, window, document, console */
            6  +/* global oGrammalecte, showError, window, document, console */
     7      7   
     8      8   "use strict";
     9      9   
    10     10   
    11     11   class GrammalecteMessageBox {
    12     12   
    13     13       constructor (sId, sTitle) {

Modified gc_lang/fr/webext/content_scripts/panel.js from [b5c79a2ce5] to [98261d40f5].

     1      1   // JavaScript
     2      2   // Panel creator
     3      3   
     4      4   /* jshint esversion:6, -W097 */
     5      5   /* jslint esversion:6 */
     6         -/* global GrammalectePanel, oGrammalecte, xGrammalectePort, showError, window, document, console */
            6  +/* global GrammalectePanel, oGrammalecte, showError, window, document, console */
     7      7   
     8      8   "use strict";
     9      9   
    10     10   
    11     11   class GrammalectePanel {
    12     12   
    13     13       constructor (sId, sTitle, nWidth, nHeight, bFlexible=true) {
................................................................................
   268    268       hideMessage () {
   269    269           this.xPanelMessageBlock.style.display = "none";
   270    270           this.xPanelMessageActionButton.style.display = "none";
   271    271       }
   272    272   
   273    273       executeButtonAction (sActionName) {
   274    274           switch (sActionName) {
   275         -            case "":
   276         -                break;
   277    275               case "restartWorker":
   278         -                xGrammalectePort.postMessage({
   279         -                    sCommand: "restartWorker",
   280         -                    dParam: { "nTimeDelay": 10 },
   281         -                    dInfo: {}
   282         -                });
          276  +                oGrammalecteBackgroundPort.restartWorker();
   283    277                   this.stopWaitIcon();
   284    278                   break;
   285    279               default:
   286    280                   console.log("Action inconnue: ", sAction);
   287    281           }
   288    282       }
   289         -
   290         -    openURL (sURL) {
   291         -        xGrammalectePort.postMessage({
   292         -            sCommand: "openURL",
   293         -            dParam: {"sURL": sURL},
   294         -            dInfo: {}
   295         -        });
   296         -    }
   297    283   }

Modified gc_lang/fr/webext/content_scripts/panel_gc.js from [f1590de9e6] to [1cfb37cbb6].

     1      1   // JavaScript
     2      2   
     3      3   /* jshint esversion:6, -W097 */
     4      4   /* jslint esversion:6 */
     5         -/* global GrammalectePanel, oGrammalecte, xGrammalectePort, showError, window, document, console */
            5  +/* global GrammalectePanel, oGrammalecte, oGrammalecteBackgroundPort, showError, window, document, console */
     6      6   
     7      7   "use strict";
     8      8   
     9      9   function onGrammalecteGCPanelClick (xEvent) {
    10     10       try {
    11     11           let xElem = xEvent.target;
    12     12           if (xElem.id) {
................................................................................
    19     19               } else if (xElem.id.startsWith("grammalecte_hide")) {
    20     20                   xElem.parentNode.parentNode.style.display = "none";
    21     21               } else if (xElem.id.startsWith("grammalecte_err")
    22     22                          && xElem.className !== "grammalecte_error_corrected"
    23     23                          && xElem.className !== "grammalecte_error_ignored") {
    24     24                   oGrammalecte.oGCPanel.oTooltip.show(xElem.parentNode, xElem.id);
    25     25               } else if (xElem.id === "grammalecte_tooltip_url"  || xElem.id === "grammalecte_tooltip_db_search") {
    26         -                oGrammalecte.oGCPanel.openURL(xElem.dataset.url);
           26  +                oGrammalecteBackgroundPort.openURL(xElem.dataset.url);
    27     27               } else {
    28     28                   oGrammalecte.oGCPanel.oTooltip.hide();
    29     29               }
    30     30           } else {
    31     31               oGrammalecte.oGCPanel.oTooltip.hide();
    32     32           }
    33     33       }
................................................................................
   107    107               this.setAutoRefreshButton();
   108    108           }
   109    109           this.xLxgButton.onclick = () => {
   110    110               if (!this.bWorking) {
   111    111                   this.showLexicographer();
   112    112                   this.clearLexicographer();
   113    113                   this.startWaitIcon();
   114         -                xGrammalectePort.postMessage({
   115         -                    sCommand: "getListOfTokens",
   116         -                    dParam: {sText: this.oTextControl.getText()},
   117         -                    dInfo: ((this.xNode) ? {sTextAreaId: this.xNode.id} : {})
   118         -                });
   119         -                /*xGrammalectePort.postMessage({
   120         -                    sCommand: "parseFull",
   121         -                    dParam: {sText: this.oTextControl.getText(), sCountry: "FR", bDebug: false, bContext: false},
   122         -                    dInfo: ((this.xNode) ? {sTextAreaId: this.xNode.id} : {})
   123         -                });*/
          114  +                oGrammalecteBackgroundPort.getListOfTokens(this.oTextControl.getText());
          115  +                //oGrammalecteBackgroundPort.parseFull(this.oTextControl.getText())
   124    116               }
   125    117           };
   126    118           this.xConjButton.onclick = () => {
   127    119               if (!this.bWorking) {
   128    120                   this.showConjugueur();
   129    121               }
   130    122           };
   131    123           this.xLexEditButton.onclick = () => {
   132         -            xGrammalectePort.postMessage({sCommand: "openLexiconEditor", dParam: null, dInfo: null});
          124  +            oGrammalecteBackgroundPort.openLexiconEditor();
   133    125           };
   134    126           // Add tabs to menu
   135    127           this.xMenu.appendChild(this.xTFButton)
   136    128           this.xMenu.appendChild(this.xEditorButton)
   137    129           this.xMenu.appendChild(this.xLxgButton)
   138    130           this.xMenu.appendChild(this.xConjButton)
   139    131           this.xPanelBar.appendChild(this.xMenu);
................................................................................
   168    160   
   169    161       recheckAll () {
   170    162           this.oTooltip.hide();
   171    163           this.showEditor();
   172    164           this.clear();
   173    165           this.startWaitIcon();
   174    166           this.resetTimer();
   175         -        xGrammalectePort.postMessage({
   176         -            sCommand: "parseAndSpellcheck",
   177         -            dParam: {sText: this.oTextControl.getText(), sCountry: "FR", bDebug: false, bContext: false},
   178         -            dInfo: ((this.xNode) ? {sTextAreaId: this.xNode.id} : {})
   179         -        });
          167  +        oGrammalecteBackgroundPort.parseAndSpellcheck(this.oTextControl.getText(), "__GrammalectePanel__");
   180    168       }
   181    169   
   182    170       showEditor () {
   183    171           this.switchContentOn(this.xGCPanelContent, this.xEditorButton);
   184    172           this.switchContentOff(this.xLxgPanelContent, this.xLxgButton);
   185    173           this.switchContentOff(this.xConjPanelContent, this.xConjButton);
   186    174           this.xPanel.style.background = "";
................................................................................
   284    272       }
   285    273   
   286    274       recheckParagraph (iParaNum) {
   287    275           let sParagraphId = "grammalecte_paragraph" + iParaNum;
   288    276           let xParagraph = this.xParent.getElementById(sParagraphId);
   289    277           this._blockParagraph(xParagraph);
   290    278           let sText = this.purgeText(xParagraph.textContent);
   291         -        xGrammalectePort.postMessage({
   292         -            sCommand: "parseAndSpellcheck1",
   293         -            dParam: {sText: sText, sCountry: "FR", bDebug: false, bContext: false},
   294         -            dInfo: {sParagraphId: sParagraphId}
   295         -        });
          279  +        oGrammalecteBackgroundPort.parseAndSpellcheck1(sText, "__GrammalectePanel__", sParagraphId);
   296    280           this.oTextControl.setParagraph(iParaNum, sText);
   297    281           this.oTextControl.write();
   298    282       }
   299    283   
   300    284       refreshParagraph (sParagraphId, oResult) {
   301    285           // function called when results are sent by the Worker
   302    286           try {
................................................................................
   636    620       updateConj (bStart=false) {
   637    621           let bPro = this.xParent.getElementById('grammalecte_conj_opro').checked;
   638    622           let bNeg = this.xParent.getElementById('grammalecte_conj_oneg').checked;
   639    623           let bTpsCo = this.xParent.getElementById('grammalecte_conj_otco').checked;
   640    624           let bInt = this.xParent.getElementById('grammalecte_conj_oint').checked;
   641    625           let bFem = this.xParent.getElementById('grammalecte_conj_ofem').checked;
   642    626           if (this.sVerb) {
   643         -            xGrammalectePort.postMessage({
   644         -                sCommand: "getVerb",
   645         -                dParam: {sVerb: this.sVerb, bPro: bPro, bNeg: bNeg, bTpsCo: bTpsCo, bInt: bInt, bFem: bFem},
   646         -                dInfo: {bStart: bStart}
   647         -            });
          627  +            oGrammalecteBackgroundPort.getVerb(this.sVerb, bStart, bPro, bNeg, bTpsCo, bInt, bFem);
   648    628           }
   649    629       }
   650    630   
   651    631       conjugateWith (oVerb, oConjTable) {
   652    632           // function called when results come from the Worker
   653    633           if (oVerb) {
   654    634               this.xParent.getElementById('grammalecte_conj_verb').style.color = "#999999";
................................................................................
   872    852                       this.xParent.getElementById("grammalecte_tooltip_db_search").style.display = "inline";
   873    853                       this.xParent.getElementById("grammalecte_tooltip_db_search").dataset.url = "https://grammalecte.net/dictionary.php?prj=fr&lemma="+xNodeErr.textContent;
   874    854                   } else {
   875    855                       this.xParent.getElementById("grammalecte_tooltip_db_search").style.display = "none";
   876    856                   }
   877    857                   this.clearSuggestionBlock();
   878    858                   this.xTooltipSuggBlock.textContent = "Recherche de graphies possibles…";
   879         -                xGrammalectePort.postMessage({
   880         -                    sCommand: "getSpellSuggestions",
   881         -                    dParam: {sWord: xNodeErr.textContent},
   882         -                    dInfo: {sErrorId: xNodeErr.dataset.error_id}
   883         -                });
          859  +                oGrammalecteBackgroundPort.getSpellSuggestions(xNodeErr.textContent, xNodeErr.dataset.error_id);
   884    860               }
   885    861               this.xTooltipArrow.style.display = "block";
   886    862               this.xTooltip.style.display = "block";
   887    863           }
   888    864           catch (e) {
   889    865               showError(e);
   890    866           }
................................................................................
   962    938           this.clear();
   963    939           this.xNode = xNode;
   964    940           this.bResultInEvent = Boolean(xNode.dataset.grammalecte_result_via_event && xNode.dataset.grammalecte_result_via_event == "true");
   965    941           this.bTextArea = (xNode.tagName == "TEXTAREA" || xNode.tagName == "INPUT");
   966    942           this.bIframe = (xNode.tagName == "IFRAME");
   967    943           if (this.bTextArea) {
   968    944               this.xNode.disabled = true;
   969         -            this._loadText(this.xNode.value);
          945  +            this.loadText(this.xNode.value);
   970    946           }
   971    947           else if (this.bIframe) {
   972    948               // iframe
   973    949               if (!this.bResultInEvent) {
   974    950                   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.");
   975    951               }
   976         -            this._loadText(this.xNode.contentWindow.document.body.innerText);
          952  +            this.loadText(this.xNode.contentWindow.document.body.innerText);
   977    953           }
   978    954           else {
   979    955               // editable node
   980    956               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.");
   981         -            this._loadText(this.xNode.innerText);
          957  +            this.loadText(this.xNode.innerText);
   982    958           }
   983    959       }
   984    960   
   985    961       setText (sText) {
   986    962           this.clear();
   987    963           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.");
   988         -        this._loadText(sText);
          964  +        this.loadText(sText);
   989    965       }
   990    966   
   991         -    _loadText (sText) {
          967  +    loadText (sText) {
   992    968           if (typeof(sText) === "string") {
   993    969               this.dParagraph.clear();
   994    970               let i = 0;
   995    971               let iStart = 0;
   996    972               let iEnd = 0;
   997    973               sText = sText.replace(/\r\n/g, "\n").replace(/\r/g, "\n").normalize("NFC");
   998    974               while ((iEnd = sText.indexOf("\n", iStart)) !== -1) {