Grammalecte  Check-in [a1ab0ad435]

Overview
Comment:[fx][core] extension.getURL -> runtime.getURL
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | core | fx
Files: files | file ages | folders
SHA3-256: a1ab0ad435d4c012e6883e4fb641f8aad08fddbad3204ed009538671d5c7c5ae
User & Date: olr on 2020-07-10 13:09:58
Other Links: manifest | tags
Context
2020-07-10
13:38
[tb] useless permissions check-in: d7e571ac2c user: olr tags: tb, trunk
13:09
[fx][core] extension.getURL -> runtime.getURL check-in: a1ab0ad435 user: olr tags: core, fx, trunk
12:57
[core] remove obsolete cruft about importation for Thunderbird/Firefox Addon-SDK check-in: c8ed6a6f41 user: olr tags: core, trunk
Changes

Modified gc_lang/fr/modules-js/conj.js from [6b8df706bd] to [9439cc3700].

602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619

// Initialization
if(!conj.bInit && typeof(process) !== 'undefined') {
    // NodeJS
    conj.init(helpers.loadFile(__dirname+"/conj_data.json"));
} else if (!conj.bInit && typeof(browser) !== 'undefined') {
    // WebExtension Standard (but not in Worker)
    conj.init(helpers.loadFile(browser.extension.getURL("grammalecte/fr/conj_data.json")));
} else if (!conj.bInit && typeof(chrome) !== 'undefined') {
    // WebExtension Chrome (but not in Worker)
    conj.init(helpers.loadFile(chrome.extension.getURL("grammalecte/fr/conj_data.json")));
} else if (conj.bInit){
    console.log("Module conj déjà initialisé");
} else {
    //console.log("Module conj non initialisé");
}









|


|







602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619

// Initialization
if(!conj.bInit && typeof(process) !== 'undefined') {
    // NodeJS
    conj.init(helpers.loadFile(__dirname+"/conj_data.json"));
} else if (!conj.bInit && typeof(browser) !== 'undefined') {
    // WebExtension Standard (but not in Worker)
    conj.init(helpers.loadFile(browser.runtime.getURL("grammalecte/fr/conj_data.json")));
} else if (!conj.bInit && typeof(chrome) !== 'undefined') {
    // WebExtension Chrome (but not in Worker)
    conj.init(helpers.loadFile(chrome.runtime.getURL("grammalecte/fr/conj_data.json")));
} else if (conj.bInit){
    console.log("Module conj déjà initialisé");
} else {
    //console.log("Module conj non initialisé");
}


Modified gc_lang/fr/modules-js/mfsp.js from [abc12c1177] to [060aa1f919].

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118

// Initialization
if (!mfsp.bInit && typeof(process) !== 'undefined') {
    // NodeJS
    mfsp.init(helpers.loadFile(__dirname+"/mfsp_data.json"));
} else if (!mfsp.bInit && typeof(browser) !== 'undefined') {
    // WebExtension
    mfsp.init(helpers.loadFile(browser.extension.getURL("grammalecte/fr/mfsp_data.json")));
} else if (mfsp.bInit){
    console.log("Module mfsp déjà initialisé");
} else {
    //console.log("Module mfsp non initialisé");
}









|







104
105
106
107
108
109
110
111
112
113
114
115
116
117
118

// Initialization
if (!mfsp.bInit && typeof(process) !== 'undefined') {
    // NodeJS
    mfsp.init(helpers.loadFile(__dirname+"/mfsp_data.json"));
} else if (!mfsp.bInit && typeof(browser) !== 'undefined') {
    // WebExtension
    mfsp.init(helpers.loadFile(browser.runtime.getURL("grammalecte/fr/mfsp_data.json")));
} else if (mfsp.bInit){
    console.log("Module mfsp déjà initialisé");
} else {
    //console.log("Module mfsp non initialisé");
}


Modified gc_lang/fr/modules-js/phonet.js from [591db698ab] to [0562e85836].

88
89
90
91
92
93
94
95
96
97
98
99
100
101
102

// Initialization
if (!phonet.bInit && typeof(process) !== 'undefined') {
    // NodeJS
    phonet.init(helpers.loadFile(__dirname+"/phonet_data.json"));
} else if (!phonet.bInit && typeof(browser) !== 'undefined') {
    // WebExtension
    phonet.init(helpers.loadFile(browser.extension.getURL("grammalecte/fr/phonet_data.json")));
} else if (phonet.bInit){
    console.log("Module phonet déjà initialisé");
} else {
    //console.log("Module phonet non initialisé");
}









|







88
89
90
91
92
93
94
95
96
97
98
99
100
101
102

// Initialization
if (!phonet.bInit && typeof(process) !== 'undefined') {
    // NodeJS
    phonet.init(helpers.loadFile(__dirname+"/phonet_data.json"));
} else if (!phonet.bInit && typeof(browser) !== 'undefined') {
    // WebExtension
    phonet.init(helpers.loadFile(browser.runtime.getURL("grammalecte/fr/phonet_data.json")));
} else if (phonet.bInit){
    console.log("Module phonet déjà initialisé");
} else {
    //console.log("Module phonet non initialisé");
}


Modified gc_lang/fr/webext/background.js from [713fa99463] to [58462d987c].

197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
...
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
...
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
...
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
...
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
...
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
...
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
            let dOptions = (oSavedOptions.hasOwnProperty("gc_options")) ? oSavedOptions.gc_options : null;
            if (dOptions !== null && Object.getOwnPropertyNames(dOptions).length == 0) {
                console.log("# Error: the saved options was an empty object.");
                dOptions = null;
            }
            oWorkerHandler.xGCEWorker.postMessage({
                sCommand: "init",
                oParam: {sExtensionPath: browser.extension.getURL(""), dOptions: dOptions, sContext: "Firefox"},
                oInfo: {}
            });
        }
        catch (e) {
            console.log("initGrammarChecker failed");
            showError(e);
        }
................................................................................
            // 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: {} });
        }
................................................................................
            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);



/*
................................................................................
    }
}

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});
    }
}
................................................................................
    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});
    }
}
................................................................................
    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);
}







|







 







|







 







|







 







|




|







 







|




|







 







|




|







 







|







|











197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
...
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
...
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
...
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
...
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
...
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
...
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
            let dOptions = (oSavedOptions.hasOwnProperty("gc_options")) ? oSavedOptions.gc_options : null;
            if (dOptions !== null && Object.getOwnPropertyNames(dOptions).length == 0) {
                console.log("# Error: the saved options was an empty object.");
                dOptions = null;
            }
            oWorkerHandler.xGCEWorker.postMessage({
                sCommand: "init",
                oParam: {sExtensionPath: browser.runtime.getURL(""), dOptions: dOptions, sContext: "Firefox"},
                oInfo: {}
            });
        }
        catch (e) {
            console.log("initGrammarChecker failed");
            showError(e);
        }
................................................................................
            // 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.runtime.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: {} });
        }
................................................................................
            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.runtime.getURL("")});
}

browser.runtime.onConnect.addListener(handleConnexion);



/*
................................................................................
    }
}

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

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

function openConjugueurTab () {
    if (nTabConjugueur === null) {
        if (bChrome) {
            browser.tabs.create({
                url: browser.runtime.getURL("panel/conjugueur.html")
            }, onConjugueurOpened);
            return;
        }
        let xConjTab = browser.tabs.create({
            url: browser.runtime.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.runtime.getURL("panel/conjugueur.html"),
            type: "popup",
            width: 710,
            height: 980
        });
        return;
    }
    let xConjWindow = browser.windows.create({
        url: browser.runtime.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);
}

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

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
...
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
    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();
    let blobTxt = new Blob([xRequest.response], {type: 'image/png'});
    let img = document.createElement('img');
    img.src = (URL || webkitURL).createObjectURL(blobTxt); // webkitURL is obsolete: https://bugs.webkit.org/show_bug.cgi?id=167518
    Array.filter(document.getElementsByClassName(sContainerClass), function (oElem) {
        oElem.appendChild(img);
................................................................................
        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"
*/







|







 







|









34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
...
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
    bThunderbird = true;
    //console.log("[Grammalecte] Thunderbird...");
}

/*
function loadImage (sContainerClass, sImagePath) {
    let xRequest = new XMLHttpRequest();
    xRequest.open('GET', browser.runtime.getURL("")+sImagePath, false);
    xRequest.responseType = "arraybuffer";
    xRequest.send();
    let blobTxt = new Blob([xRequest.response], {type: 'image/png'});
    let img = document.createElement('img');
    img.src = (URL || webkitURL).createObjectURL(blobTxt); // webkitURL is obsolete: https://bugs.webkit.org/show_bug.cgi?id=167518
    Array.filter(document.getElementsByClassName(sContainerClass), function (oElem) {
        oElem.appendChild(img);
................................................................................
        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.runtime.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/panel/lex_editor.js from [621914c742] to [f63b876c0b].

780
781
782
783
784
785
786
787
788
789
790
791
792
793
794


const oSearch = {

    oSpellChecker: null,

    load: function () {
        this.oSpellChecker = new SpellChecker("fr", browser.extension.getURL("")+"grammalecte/graphspell/_dictionaries", "fr-allvars.json");
    },

    loadOtherDictionaries: function () {
        //TODO
    },

    listen: function () {







|







780
781
782
783
784
785
786
787
788
789
790
791
792
793
794


const oSearch = {

    oSpellChecker: null,

    load: function () {
        this.oSpellChecker = new SpellChecker("fr", browser.runtime.getURL("")+"grammalecte/graphspell/_dictionaries", "fr-allvars.json");
    },

    loadOtherDictionaries: function () {
        //TODO
    },

    listen: function () {

Modified gc_lang/fr/webext/panel/main.js from [0cb6672536] to [2b924690ef].

78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
            else if (xElem.id.startsWith("spelling_")) {
                updateSpellingChoiceUI(xElem.id);
                let sMainDicName = document.getElementById(xElem.id).dataset.dicname;
                browser.storage.local.set({"main_dic_name": sMainDicName});
                browser.runtime.sendMessage({
                    sCommand: "setDictionary",
                    oParam: { sDictionary: "main", oDict: sMainDicName },
                    oInfo: { sExtPath: browser.extension.getURL("") }
                });
            }
            // UI options
            else if (xElem.id.startsWith("ui_option_")) {
                storeUIOptions();
            }
            //







|







78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
            else if (xElem.id.startsWith("spelling_")) {
                updateSpellingChoiceUI(xElem.id);
                let sMainDicName = document.getElementById(xElem.id).dataset.dicname;
                browser.storage.local.set({"main_dic_name": sMainDicName});
                browser.runtime.sendMessage({
                    sCommand: "setDictionary",
                    oParam: { sDictionary: "main", oDict: sMainDicName },
                    oInfo: { sExtPath: browser.runtime.getURL("") }
                });
            }
            // UI options
            else if (xElem.id.startsWith("ui_option_")) {
                storeUIOptions();
            }
            //