Grammalecte  Diff

Differences From Artifact [56de373e52]:

To Artifact [0cb6672536]:


24
25
26
27
28
29
30
31
32


33
34
35
36
37
38
39
40


41
42
43
44
45
46
47


48
49
50
51
52
53
54
55


56
57
58
59
60
61
62
63


64
65
66
67
68
69
70
71
72
73
74


75
76
77
78
79
80
81
82
83
84
85


86
87
88
89
90
91
92
93
94
95
96
97
98
99
100


101
102
103
104
105
106
107


108
109
110
111
112
113
114


115
116
117
118
119
120
121


122
123
124
125
126
127
128
24
25
26
27
28
29
30


31
32
33
34
35
36
37
38


39
40
41
42
43
44
45


46
47
48
49
50
51
52
53


54
55
56
57
58
59
60
61


62
63
64
65
66
67
68
69
70
71
72


73
74
75
76
77
78
79
80
81
82
83


84
85
86
87
88
89
90
91
92
93
94
95
96
97
98


99
100
101
102
103
104
105


106
107
108
109
110
111
112


113
114
115
116
117
118
119


120
121
122
123
124
125
126
127
128







-
-
+
+






-
-
+
+





-
-
+
+






-
-
+
+






-
-
+
+









-
-
+
+









-
-
+
+













-
-
+
+





-
-
+
+





-
-
+
+





-
-
+
+







    function (xEvent) {
        let xElem = xEvent.target;
        if (xElem.id) {
            // tests
            if (xElem.id === "text_to_test_button") {
                browser.runtime.sendMessage({
                    sCommand: "textToTest",
                    dParam: {sText: document.getElementById("text_to_test").value, sCountry: "FR", bDebug: true, bContext: false},
                    dInfo: {}
                    oParam: {sText: document.getElementById("text_to_test").value, sCountry: "FR", bDebug: true, bContext: false},
                    oInfo: {}
                });
            }
            else if (xElem.id === "fulltests_button") {
                document.getElementById("tests_result").textContent = "Veuillez patienter…";
                browser.runtime.sendMessage({
                    sCommand: "fullTests",
                    dParam: {},
                    dInfo: {}
                    oParam: {},
                    oInfo: {}
                });
            }
            else if (xElem.id == "restart_worker") {
                browser.runtime.sendMessage({
                    sCommand: "restartWorker",
                    dParam: { "nDelayLimit": 3 },
                    dInfo: {}
                    oParam: { "nDelayLimit": 3 },
                    oInfo: {}
                });
            }
            // grammar options
            else if (xElem.id === "default_options_button") {
                browser.runtime.sendMessage({
                   sCommand: "resetOptions",
                   dParam: {},
                   dInfo: {}
                   oParam: {},
                   oInfo: {}
                });
            }
            else if (xElem.id.startsWith("option_")) {
                if (xElem.dataset.option) {
                    browser.runtime.sendMessage({
                        sCommand: "setOption",
                        dParam: {sOptName: xElem.dataset.option, bValue: xElem.checked},
                        dInfo: {}
                        oParam: {sOptName: xElem.dataset.option, bValue: xElem.checked},
                        oInfo: {}
                    });
                }
            }
            // dictionaries options
            else if (xElem.id.endsWith("_dic")) {
                if (xElem.dataset.dictionary) {
                    storeSCOptions();
                    browser.runtime.sendMessage({
                        sCommand: "setDictionaryOnOff",
                        dParam: {sDictionary: xElem.dataset.dictionary, bActivate: xElem.checked},
                        dInfo: {}
                        oParam: {sDictionary: xElem.dataset.dictionary, bActivate: xElem.checked},
                        oInfo: {}
                    });
                }
            }
            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",
                    dParam: { sDictionary: "main", oDict: sMainDicName },
                    dInfo: { sExtPath: browser.extension.getURL("") }
                    oParam: { sDictionary: "main", oDict: sMainDicName },
                    oInfo: { sExtPath: browser.extension.getURL("") }
                });
            }
            // UI options
            else if (xElem.id.startsWith("ui_option_")) {
                storeUIOptions();
            }
            //
            else if (xElem.id.startsWith("link_")) {
                browser.tabs.create({url: xElem.dataset.url});
            }
            else if (xElem.id == "conj_button") {
                browser.runtime.sendMessage({
                    sCommand: "openConjugueurTab",
                    dParam: {},
                    dInfo: {}
                    oParam: {},
                    oInfo: {}
                });
            }
            else if (xElem.id == "dictionaries_button") {
                browser.runtime.sendMessage({
                    sCommand: "openDictionaries",
                    dParam: {},
                    dInfo: {}
                    oParam: {},
                    oInfo: {}
                });
            }
            else if (xElem.id == "dic_community_button") {
                browser.runtime.sendMessage({
                    sCommand: "openLexiconEditor",
                    dParam: { "dictionary": "__community__"},
                    dInfo: {}
                    oParam: { "dictionary": "__community__"},
                    oInfo: {}
                });
            }
            else if (xElem.id == "dic_personal_button") {
                browser.runtime.sendMessage({
                    sCommand: "openLexiconEditor",
                    dParam: { "dictionary": "__personal__"},
                    dInfo: {}
                    oParam: { "dictionary": "__personal__"},
                    oInfo: {}
                });
            }
        // change UI page
        } else if (xElem.className.startsWith("select")) {
            showPage(xElem.dataset.page);
        }/* else if (xElem.tagName === "A") {
            openURL(xElem.getAttribute("href"));
152
153
154
155
156
157
158
159

160
161
162
163
164
165
166
152
153
154
155
156
157
158

159
160
161
162
163
164
165
166







-
+







}


/*
    Messages received
*/
function handleMessage (oMessage, xSender, sendResponse) {
    let {sActionDone, result, dInfo, bEnd, bError} = oMessage;
    let {sActionDone, result, oInfo, bEnd, bError} = oMessage;
    switch(sActionDone) {
        case "textToTest":
        case "fullTests":
            showTestResult(result);
            break;
        case "resetOptions":
            displayGCOptions(result);