Grammalecte  Diff

Differences From Artifact [db5cbebcc3]:

To Artifact [2505acbc2a]:


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







+






-
+






-







}

/*
* Creation d'une iframe pour communiquer entre la page visitée et le Shareworker
*/
var sFrameID = browser.extension.getURL("").split('/')[2];
var xIframe = document.createElement('iframe');
let xFrameContent = null;
xIframe.id = sFrameID;
xIframe.src = browser.extension.getURL('content_scripts/communicate.html');
xIframe.hidden = true;
xIframe.onload= function () {
    console.log('[Web] Init protocol de communication');
    //var xFrameContent = xIframe.contentWindow;
    var xFrameContent = document.getElementById(sFrameID).contentWindow;
    xFrameContent = document.getElementById(sFrameID).contentWindow;
    xFrameContent.addEventListener("message", receivedMessageFromIframe, false);
    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(""));
    }
    catch (e) {
        console.error(e);
    }
128
129
130
131
132
133
134
135

136
137
138
139
140
141
142

143
144
145
146
147
148
149

150
151
152
153
154
155
156
128
129
130
131
132
133
134

135
136
137
138
139
140
141

142
143
144
145
146
147
148

149
150
151
152
153
154
155
156







-
+






-
+






-
+







        xConjButton.onclick = function() {
            createConjPanel();
        };
        xToolbar.appendChild(xConjButton);
        let xTFButton = document.createElement("div");
        xTFButton.textContent = "Formater";
        xTFButton.style = sButtonStyle;
        xTFButton.onclick = function() {
        xTFButton.onclick = function(xTextArea) {
            createTFPanel();
        };
        xToolbar.appendChild(xTFButton);
        let xLxgButton = document.createElement("div");
        xLxgButton.textContent = "Analyser";
        xLxgButton.style = sButtonStyle;
        xLxgButton.onclick = function() {
        xLxgButton.onclick = function(xTextArea) {
            createLxgPanel();
        };
        xToolbar.appendChild(xLxgButton);
        let xGCButton = document.createElement("div");
        xGCButton.textContent = "Corriger";
        xGCButton.style = sButtonStyle;
        xGCButton.onclick = function() {
        xGCButton.onclick = function(xTextArea) {
            createGCPanel();
        };
        xToolbar.appendChild(xGCButton);
        return xToolbar;
    }
    catch (e) {
        showError(e);
172
173
174
175
176
177
178
179

180
181
182
183

184
185
186
187

188

189
190
191
192
193
194
195
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







-
+



-
+



-
+

+







        xConjPanel.appendChild(createCloseButton(xConjPanel));
        document.body.appendChild(xConjPanel);
    }
}



function createTFPanel () {
function createTFPanel (xTextArea) {
    console.log("Formateur de texte");
}

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

function createGCPanel () {
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 = "×";