30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
} else {
console.log("[background] don’t know where to send results");
console.log(e.data);
}
break;
case "textToTest":
case "fullTests":
case "getOptions":
case "getDefaultOptions":
case "resetOptions":
// send result to panel
browser.runtime.sendMessage(e.data);
browser.storage.local.set({"gc_options": result});
break;
|
>
>
>
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
} else {
console.log("[background] don’t know where to send results");
console.log(e.data);
}
break;
case "textToTest":
case "fullTests":
// send result to panel
browser.runtime.sendMessage(e.data);
break;
case "getOptions":
case "getDefaultOptions":
case "resetOptions":
// send result to panel
browser.runtime.sendMessage(e.data);
browser.storage.local.set({"gc_options": result});
break;
|
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
129
130
131
132
133
134
135
136
137
138
139
|
/*
Messages from the extension (not the Worker)
*/
function handleMessage (oRequest, xSender, sendResponse) {
//console.log(xSender);
switch (oRequest.sCommand) {
case "parse":
case "parseAndSpellcheck":
case "parseAndSpellcheck1":
case "getListOfTokens":
case "textToTest":
case "getOptions":
case "getDefaultOptions":
case "setOptions":
case "setOption":
case "resetOptions":
case "fullTests":
xGCEWorker.postMessage(oRequest);
break;
default:
console.log("[background] Unknown command: " + oRequest.sCommand);
}
//sendResponse({response: "response from background script"});
}
browser.runtime.onMessage.addListener(handleMessage);
function handleConnexion (xPort) {
let iPortId = xPort.sender.tab.id; // identifier for the port: each port can be found at dConnx[iPortId]
dConnx.set(iPortId, xPort);
xPort.onMessage.addListener(function (oRequest) {
switch (oRequest.sCommand) {
case "parse":
case "parseAndSpellcheck":
case "parseAndSpellcheck1":
case "getListOfTokens":
oRequest.dInfo.iReturnPort = iPortId; // we pass the id of the return port to receive answer
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);
|
>
|
<
<
<
<
<
>
>
>
>
|
>
|
>
>
>
|
|
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
/*
Messages from the extension (not the Worker)
*/
function handleMessage (oRequest, xSender, sendResponse) {
//console.log(xSender);
let {sCommand, dParam, dInfo} = oRequest;
switch (sCommand) {
case "getOptions":
case "getDefaultOptions":
case "setOptions":
case "setOption":
case "resetOptions":
case "textToTest":
case "fullTests":
xGCEWorker.postMessage(oRequest);
break;
case "openURL":
browser.tabs.create({url: dParam.sURL});
break;
default:
console.log("[background] Unknown command: " + sCommand);
}
//sendResponse({response: "response from background script"});
}
browser.runtime.onMessage.addListener(handleMessage);
function handleConnexion (xPort) {
let iPortId = xPort.sender.tab.id; // identifier for the port: each port can be found at dConnx[iPortId]
dConnx.set(iPortId, xPort);
xPort.onMessage.addListener(function (oRequest) {
let {sCommand, dParam, dInfo} = oRequest;
switch (sCommand) {
case "parse":
case "parseAndSpellcheck":
case "parseAndSpellcheck1":
case "getListOfTokens":
oRequest.dInfo.iReturnPort = iPortId; // we pass the id of the return port to receive answer
xGCEWorker.postMessage(oRequest);
break;
case "openURL":
browser.tabs.create({url: dParam.sURL});
break;
default:
console.log("[background] Unknown command: " + sCommand);
console.log(oRequest);
}
});
xPort.postMessage({sActionDone: "newId", result: iPortId});
}
browser.runtime.onConnect.addListener(handleConnexion);
|