Grammalecte  Diff

Differences From Artifact [639403006b]:

To Artifact [5573d033c2]:


11
12
13
14
15
16
17
18
19
20
21
22
23






24

25
26
27
28
29
30
31
11
12
13
14
15
16
17






18
19
20
21
22
23
24
25
26
27
28
29
30
31
32







-
-
-
-
-
-
+
+
+
+
+
+

+








/*
* Pour effectuer différent action sur la page en cours
*/
function receivedMessageFromIframe (oEvent) {
    if (typeof oEvent.data.SharedWorker !== "undefined") {
        console.log('[Web] received (from iframe (Sharedworker)):', oEvent);
        let [sCommand, answer] = oEvent.data.SharedWorker;
        console.log(sCommand);
        switch (sCommand) {
            case "grammar_errors":
                console.log(answer.aGrammErr);
                for (let oErr of answer.aGrammErr) {
        let {sActionDone, result, dInfo, bError} = oEvent.data.SharedWorker;
        console.log(sActionDone);
        switch (sActionDone) {
            case "parse":
                console.log(result);
                for (let oErr of result) {
                    console.log(oErr);
                    console.log(text.getReadableError(oErr));
                }
                break;
        }
    }    
}

/*
45
46
47
48
49
50
51
52

53
54
55
56
57
58
59
46
47
48
49
50
51
52

53
54
55
56
57
58
59
60







-
+







    try {
        //La frame est chargé on envoie l'initialisation du Sharedworker
        console.log('[Web] Initialise the worker :s');
        console.log('[Web] Domaine ext: '+browser.extension.getURL(""));
        xFrameContent.postMessage({sPath: browser.extension.getURL(""), sPage: location.origin.trim("/")}, browser.extension.getURL(""));
        //Un petit test pour débogage ;)
        console.log('[Web] Test the worker :s');
        xFrameContent.postMessage(["parse", {sText: "Vas... J’en aie mare...", sCountry: "FR", bDebug: false, bContext: false}], browser.extension.getURL(""));
        xFrameContent.postMessage({sCommand: "parse", dParam: {sText: "Vas... J’en aie mare...", sCountry: "FR", bDebug: false, bContext: false}, dInfo: {}}, browser.extension.getURL(""));
    }
    catch (e) {
        console.error(e);
    }
}
document.body.appendChild(xIframe);

136
137
138
139
140
141
142
143

144
145
146
147
148
149
150

151
152
153
154
155
156
157
137
138
139
140
141
142
143

144
145
146
147
148
149
150

151
152
153
154
155
156
157
158







-
+






-
+







            createTFPanel(xTextArea);
        };
        xToolbar.appendChild(xTFButton);
        let xLxgButton = document.createElement("div");
        xLxgButton.textContent = "Analyser";
        xLxgButton.style = sButtonStyle;
        xLxgButton.onclick = function() {
            createLxgPanel(xTextArea);
            console.log("Analyser");
        };
        xToolbar.appendChild(xLxgButton);
        let xGCButton = document.createElement("div");
        xGCButton.textContent = "Corriger";
        xGCButton.style = sButtonStyle;
        xGCButton.onclick = function() {
            createGCPanel(xTextArea);
            xFrameContent.postMessage({sCommand: "parse", dParam: {sText: xTextArea.value, sCountry: "FR", bDebug: false, bContext: false}, dInfo: {sInfoId: xTextArea.id}}, browser.extension.getURL(""));
        };
        xToolbar.appendChild(xGCButton);
        return xToolbar;
    }
    catch (e) {
        showError(e);
    }
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
183
184
185
186
187
188
189

190
191
192
193
194
195
196







-








function createLxgPanel (xTextArea) {
    console.log("Analyse");
}

function createGCPanel (xTextArea) {
    console.log("Correction grammaticale");
    xFrameContent.postMessage(["parse", {sText: xTextArea.value, sCountry: "FR", bDebug: false, bContext: false}], browser.extension.getURL(""));
}

function createCloseButton (xParentNode) {
    let xButton = document.createElement("div");
    xButton.style = "float: right; width: 20px; padding: 5px 10px; color: hsl(210, 0%, 100%); text-align: center;"
                  + "font-size: 20px; font-weight: bold; background-color: hsl(0, 80%, 50%); border-radius: 0 0 0 3px; cursor: pointer;";
    xButton.textContent = "×";