Grammalecte  Check-in [5c25db680b]

Overview
Comment:Added the possibility to web page script open gcpanel or lexicographe
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | comunicate
Files: files | file ages | folders
SHA3-256: 5c25db680b3a8c064bb8de68520e61aaf4ef9625e30e2cee70a4afa0029f036e
User & Date: IllusionPerdu on 2018-11-06 23:42:33
Other Links: branch diff | manifest | tags
Context
2018-11-07
11:37
Check if action is in event check-in: 9f8939c97c user: IllusionPerdu tags: comunicate
2018-11-06
23:42
Added the possibility to web page script open gcpanel or lexicographe check-in: 5c25db680b user: IllusionPerdu tags: comunicate
18:33
[fr] nr: confusions diverses check-in: 9b6a855c65 user: olr tags: trunk, fr
Changes

Added gc_lang/fr/webext/content_scripts/event.js version [8e71634c5b].



























































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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

var min = Math.ceil(0);
var max = Math.floor(9999999);
function uniqueID() {
    return (Date.now()).toString(36) + '-' + (Math.floor(Math.random() * (max - min)) + min).toString(36);
}

// Retourne un identifiant unique au cas ou si besoin
// La ID unique peut être util si on permet d'intérogé grammalecte sans zone
function sendToGrammalecte(dataAction) {
    let dataToSend = dataAction;
    dataToSend.IdAction = uniqueID();
    if (dataAction.elm){
        if (!dataAction.elm.id){
            dataAction.elm.id = uniqueID();
        }
        dataToSend.elm = dataAction.elm.id;
    }

    //console.log('dataToSend', dataToSend);
    var eventGrammalecte = new CustomEvent('GrammalecteEvent', {"detail":dataToSend});
    document.dispatchEvent(eventGrammalecte);
    return dataToSend.IdAction;
}

// On informe la page qu'il y a Grammalecte ;)
var customAPILoaded = new CustomEvent('GrammalecteIsLoaded');
document.dispatchEvent(customAPILoaded);

/* // ! In the webpage script :
document.addEventListener('GrammalecteIsLoaded', function() {
    // Le gestionnaire d'évènement est prêt!
    // La page web peut effectuer des actions
    ...
});
...
// Pour demander une correction sur le texte
sendToGrammalecte({"spellcheck": "salut comment ca vaa?"});
// Pour demander une correction sur un élément html
sendToGrammalecte({"spellcheck": true, "elm": elementHTML});
// Pour avoir le lexicographe sur un texte
sendToGrammalecte({"lexique": "salut comment ca vaa?"});
// Pour avoir le lexicographe sur un élément html
sendToGrammalecte({"lexique": true, "elm": elementHTML});
*/

Modified gc_lang/fr/webext/content_scripts/init.js from [31953bf9da] to [fb85dd36b8].

351
352
353
354
355
356
357





































        case "rescanPage":
            oGrammalecte.rescanPage();
            break;
        default:
            console.log("[Content script] Unknown command: " + sActionDone);
    }
});












































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
        case "rescanPage":
            oGrammalecte.rescanPage();
            break;
        default:
            console.log("[Content script] Unknown command: " + sActionDone);
    }
});

/*
    Communicate webpage script <=> web-extension
*/
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
        });
    }
});

Modified gc_lang/fr/webext/manifest.json from [756d794e19] to [6f106795b7].

110
111
112
113
114
115
116

117
118
119
120
121
122
123
    "grammalecte/graphspell/_dictionaries/fr-allvars.json",
    "grammalecte/graphspell/_dictionaries/fr-classic.json",
    "grammalecte/graphspell/_dictionaries/fr-reform.json",
    "grammalecte/fr/conj_data.json",
    "grammalecte/fr/mfsp_data.json",
    "grammalecte/fr/phonet_data.json",
    "grammalecte/fr/tests_data.json",

    "img/logo-16.png"
  ],

  "permissions": [
    "activeTab",
    "contextMenus",
    "downloads",







>







110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
    "grammalecte/graphspell/_dictionaries/fr-allvars.json",
    "grammalecte/graphspell/_dictionaries/fr-classic.json",
    "grammalecte/graphspell/_dictionaries/fr-reform.json",
    "grammalecte/fr/conj_data.json",
    "grammalecte/fr/mfsp_data.json",
    "grammalecte/fr/phonet_data.json",
    "grammalecte/fr/tests_data.json",
    "content_scripts/event.js",
    "img/logo-16.png"
  ],

  "permissions": [
    "activeTab",
    "contextMenus",
    "downloads",