Grammalecte  Diff

Differences From Artifact [fb85dd36b8]:

To Artifact [c869a84f0a]:


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
*/
var scriptEvent = document.createElement('script');
scriptEvent.src = browser.extension.getURL("content_scripts/event.js");
document.documentElement.appendChild(scriptEvent);

document.addEventListener('GrammalecteEvent', function(event) {
    let actionFromPage = event.detail;
    console.log(event);

    let sText = false;
    let dInfo = {};
    let elmForGramma = null;
    if (actionFromPage.elm){
        elmForGramma = document.getElementById(actionFromPage.elm);
        sText = (elmForGramma.tagName == "TEXTAREA") ? elmForGramma.value : elmForGramma.innerText;
        dInfo = {sTextAreaId: elmForGramma.id};
    }

    if (actionFromPage.spellcheck){
        oGrammalecte.startGCPanel(elmForGramma);
        xGrammalectePort.postMessage({
            sCommand: "parseAndSpellcheck",
            dParam: {sText: sText || actionFromPage.parseAndSpellcheck, sCountry: "FR", bDebug: false, bContext: false},
            dInfo: dInfo
        });
    }
    if (actionFromPage.lexique){
        oGrammalecte.startLxgPanel();
        xGrammalectePort.postMessage({
            sCommand: "getListOfTokens",
            dParam: {sText: sText || actionFromPage.lexique},
            dInfo: dInfo
        });
    }



});







|
>
|
|
|
|
|
|
|
|

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

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
*/
var scriptEvent = document.createElement('script');
scriptEvent.src = browser.extension.getURL("content_scripts/event.js");
document.documentElement.appendChild(scriptEvent);

document.addEventListener('GrammalecteEvent', function(event) {
    let actionFromPage = event.detail;
    //console.log(event);
    if(actionFromPage){
        let sText = false;
        let dInfo = {};
        let elmForGramma = null;
        if (actionFromPage.elm){
            elmForGramma = document.getElementById(actionFromPage.elm);
            sText = (elmForGramma.tagName == "TEXTAREA") ? elmForGramma.value : elmForGramma.innerText;
            dInfo = {sTextAreaId: elmForGramma.id};
        }

        if (actionFromPage.spellcheck){
            oGrammalecte.startGCPanel(elmForGramma);
            xGrammalectePort.postMessage({
                sCommand: "parseAndSpellcheck",
                dParam: {sText: sText || actionFromPage.parseAndSpellcheck, sCountry: "FR", bDebug: false, bContext: false},
                dInfo: dInfo
            });
        }
        if (actionFromPage.lexique){
            oGrammalecte.startLxgPanel();
            xGrammalectePort.postMessage({
                sCommand: "getListOfTokens",
                dParam: {sText: sText || actionFromPage.lexique},
                dInfo: dInfo
            });
        }
    } else {
        console.log("Vous devez spécifier l'action à effectuer");
    }
});