Grammalecte  Diff

Differences From Artifact [c3523915ae]:

To Artifact [b3d1a36d31]:


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






129
130
131
132
133
134
135


function handleConnexion (p) {
    var xPort = p;
    let iPortId = aConnx.length; // identifier for the port: each port can be found at aConnx[iPortId]
    aConnx.push(xPort);
    console.log("Port: " + p.name + ", id: " + iPortId);

    xPort.onMessage.addListener(function (oRequest) {
        console.log("[background] message via connexion:");
        console.log(oRequest);
        switch (oRequest.sCommand) {
            case "getCurrentTabId":

                xPort.postMessage({sActionDone: "getCurrentTabId", result: "getCurrentTabId()", dInfo: null, bError: false});
                break;
            case "parse":
            case "parseAndSpellcheck":
            case "parseAndSpellcheck1":
            case "getListOfTokens":
                oRequest.dInfo.iReturnPort = iPortId; // we pass the id of the return port to receive answer
                console.log(oRequest);
                xGCEWorker.postMessage(oRequest);
                break;
            default:
                console.log("[background] Unknown command: " + oRequest.sCommand);
                console.log(oRequest);
        }
    });
    xPort.postMessage({sActionDone: "newId", result: iPortId});
}

browser.runtime.onConnect.addListener(handleConnexion);








/*
    Context Menu
*/
browser.contextMenus.create({
    id: "grammar_checking",
    title: "Correction grammaticale",







>





>




















>
>
>
>
>
>







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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143


function handleConnexion (p) {
    var xPort = p;
    let iPortId = aConnx.length; // identifier for the port: each port can be found at aConnx[iPortId]
    aConnx.push(xPort);
    console.log("Port: " + p.name + ", id: " + iPortId);
    console.log(xPort);
    xPort.onMessage.addListener(function (oRequest) {
        console.log("[background] message via connexion:");
        console.log(oRequest);
        switch (oRequest.sCommand) {
            case "getCurrentTabId":
                console.log(getCurrentTabId());
                xPort.postMessage({sActionDone: "getCurrentTabId", result: "getCurrentTabId()", dInfo: null, bError: false});
                break;
            case "parse":
            case "parseAndSpellcheck":
            case "parseAndSpellcheck1":
            case "getListOfTokens":
                oRequest.dInfo.iReturnPort = iPortId; // we pass the id of the return port to receive answer
                console.log(oRequest);
                xGCEWorker.postMessage(oRequest);
                break;
            default:
                console.log("[background] Unknown command: " + oRequest.sCommand);
                console.log(oRequest);
        }
    });
    xPort.postMessage({sActionDone: "newId", result: iPortId});
}

browser.runtime.onConnect.addListener(handleConnexion);


async function getCurrentTabId () {
    let xTab = await browser.tabs.getCurrent();
    return xTab.id;
}


/*
    Context Menu
*/
browser.contextMenus.create({
    id: "grammar_checking",
    title: "Correction grammaticale",
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
                width: 710,
                height: 980
            });
            xConjWindow.then(onCreated, onError);
            break;
        case "conjugueur_tab":
            xConjTab = browser.tabs.create({
                url: browser.extension.getURL("panel/conjugueur.html"),
                pinned: true
            });
            xConjTab.then(onCreated, onError);
            break;
    }    
});


async function getCurrentTabId () {
    let xTab = await browser.tabs.getCurrent();
    return xTab.id;
}

/*
    TESTS ONLY
*/
async function newwin () {
    // test for popup window-like, which doesn’t close when losing the focus
    console.log("Async on");







|
<







<
<
<
<







195
196
197
198
199
200
201
202

203
204
205
206
207
208
209




210
211
212
213
214
215
216
                width: 710,
                height: 980
            });
            xConjWindow.then(onCreated, onError);
            break;
        case "conjugueur_tab":
            xConjTab = browser.tabs.create({
                url: browser.extension.getURL("panel/conjugueur.html")

            });
            xConjTab.then(onCreated, onError);
            break;
    }    
});







/*
    TESTS ONLY
*/
async function newwin () {
    // test for popup window-like, which doesn’t close when losing the focus
    console.log("Async on");