Grammalecte  Diff

Differences From Artifact [f8304ae53e]:

To Artifact [1969da4c97]:


55
56
57
58
59
60
61



62


63
64
65
66


67



68
69
70
71
72
73
74
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







+
+
+
-
+
+




+
+
-
+
+
+







        let xConjButton = createNode("div", {className: "grammalecte_wrapper_button", textContent: "Conjuguer"});
        xConjButton.onclick = function() { createConjPanel(); };
        let xTFButton = createNode("div", {className: "grammalecte_wrapper_button", textContent: "Formater"});
        xTFButton.onclick = function() { createTFPanel(xTextArea); };
        let xLxgButton = createNode("div", {className: "grammalecte_wrapper_button", textContent: "Analyser"});
        xLxgButton.onclick = function() {
            createLxgPanel();
            xPort.postMessage({
                sCommand: "getListOfTokens",
                dParam: {sText: xTextArea.value},
            xPort.postMessage({sCommand: "getListOfTokens", dParam: {sText: xTextArea.value}, dInfo: {sTextAreaId: xTextArea.id}});
                dInfo: {sTextAreaId: xTextArea.id}
            });
        };
        let xGCButton = createNode("div", {className: "grammalecte_wrapper_button", textContent: "Corriger"});
        xGCButton.onclick = function() {
            createGCPanel();
            xPort.postMessage({
                sCommand: "parseAndSpellcheck",
            xPort.postMessage({sCommand: "parseAndSpellcheck", dParam: {sText: xTextArea.value, sCountry: "FR", bDebug: false, bContext: false}, dInfo: {sTextAreaId: xTextArea.id}});
                dParam: {sText: xTextArea.value, sCountry: "FR", bDebug: false, bContext: false},
                dInfo: {sTextAreaId: xTextArea.id}
            });
        };
        // Create
        //xToolbar.appendChild(createNode("img", {scr: browser.extension.getURL("img/logo-16.png")}));
        // can’t work, due to content-script policy: https://bugzilla.mozilla.org/show_bug.cgi?id=1267027
        xToolbar.appendChild(createLogo());
        xToolbar.appendChild(document.createTextNode("Grammalecte"));
        xToolbar.appendChild(xConjButton);
144
145
146
147
148
149
150
151

152
153

154
155
156
157
158
159
160
161
162
163

164
165




166
167

168
169
170
171
172
173

174





175
176
177
178
179
180
152
153
154
155
156
157
158

159
160
161
162
163
164
165
166
167
168
169
170
171

172
173
174
175
176
177
178
179

180
181
182
183
184
185
186
187

188
189
190
191
192
193
194
195
196
197
198







-
+


+









-
+


+
+
+
+

-
+






+
-
+
+
+
+
+






    sendResponse({response: "response from content script"});
}

browser.runtime.onMessage.addListener(handleMessage);


/*
    Connexion
    Connexion to the background
*/
let xPort = browser.runtime.connect({name: "content-script port"});

xPort.onMessage.addListener(function (oMessage) {
    console.log("[Content script] received…");
    let {sActionDone, result, dInfo, bError} = oMessage;
    switch (sActionDone) {
        case "getCurrentTabId":
            console.log("[Content script] tab id: " + result);
            nTadId = result;
            break;
        case "parseAndSpellcheck":
            console.log(result);
            console.log("[content script] received: parseAndSpellcheck");
            oGCPanelContent.addParagraphResult(result);
            break;
        case "parseAndSpellcheck1":
            console.log("[content script] received: parseAndSpellcheck1");
            oGCPanelContent.refreshParagraph(dInfo.sParagraphId, result);
            break;
        case "getListOfTokens":
            console.log(result);
            console.log("[content script] received: getListOfTokens");
            oLxgPanelContent.addListOfTokens(result);
            break;
        default:
            console.log("[Content script] Unknown command: " + sActionDone);
    }
});

xPort.postMessage({sCommand: "getCurrentTabId", dParam: {}, dInfo: {}});
xPort.postMessage({
    sCommand: "getCurrentTabId",
    dParam: {},
    dInfo: {}
});

/*document.body.addEventListener("click", function () {
    xPort.postMessage({greeting: "they clicked the page!"});
});*/

wrapTextareas();