Overview
Comment: | [fx] listen to port disconnection from background |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | fx |
Files: | files | file ages | folders |
SHA3-256: |
7ca0d4636e084fa7f06984387e3640a3 |
User & Date: | olr on 2020-04-10 09:47:16 |
Other Links: | manifest | tags |
Context
2020-04-10
| ||
09:49 | [fx] web API: use var instead of const -> prevent error when the script is reloaded check-in: 677d2fc041 user: olr tags: trunk, fx | |
09:47 | [fx] listen to port disconnection from background check-in: 7ca0d4636e user: olr tags: trunk, fx | |
06:29 | [fx] recheck paragraph: don’t replace caret in the previous position if last edited paragraph is another one check-in: 2b9b61bc32 user: olr tags: trunk, fx | |
Changes
Modified gc_lang/fr/webext/content_scripts/init.js from [d79ff895de] to [b6a51f3cb6].
︙ | ︙ | |||
288 289 290 291 292 293 294 | object { sCommand: the action to perform oParam: parameters necessary for the execution of the action oInfo: all kind of informations that needs to be sent back (usually to know where to use the result) } */ | | | | > > < < | < < < < | < < | < < | < < < < | < < | | | | > > > > > > > > > > > > | 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 | object { sCommand: the action to perform oParam: parameters necessary for the execution of the action oInfo: all kind of informations that needs to be sent back (usually to know where to use the result) } */ send: function (sCommand, oParam={}, oInfo={}) { if (this.xConnect) { this.xConnect.postMessage({ sCommand: sCommand, oParam: oParam, oInfo: oInfo }); } else { oGrammalecte.showMessage("Erreur. La connexion vers le correcteur grammatical est perdue."); } }, parseAndSpellcheck: function (sText, sDestination) { this.send("parseAndSpellcheck", { sText: sText, sCountry: "FR", bDebug: false, bContext: false }, { sDestination: sDestination }); }, parseAndSpellcheck1: function (sText, sDestination, sParagraphId) { this.send("parseAndSpellcheck1", { sText: sText, sCountry: "FR", bDebug: false, bContext: false }, { sDestination: sDestination, sParagraphId: sParagraphId }); }, getListOfTokens: function (sText) { this.send("getListOfTokens", { sText: sText }, {}); }, parseFull: function (sText) { this.send("parseFull", { sText: sText, sCountry: "FR", bDebug: false, bContext: false }, {}); }, getVerb: function (sVerb, bStart=true, bPro=false, bNeg=false, bTpsCo=false, bInt=false, bFem=false) { this.send("getVerb", { sVerb: sVerb, bPro: bPro, bNeg: bNeg, bTpsCo: bTpsCo, bInt: bInt, bFem: bFem }, { bStart: bStart }); }, getSpellSuggestions: function (sWord, sDestination, sErrorId) { this.send("getSpellSuggestions", { sWord: sWord }, { sDestination: sDestination, sErrorId: sErrorId }); }, openURL: function (sURL) { this.send("openURL", { "sURL": sURL }); }, openLexiconEditor: function () { this.send("openLexiconEditor"); }, restartWorker: function (nTimeDelay=10) { this.send("restartWorker", { "nTimeDelay": nTimeDelay }); }, /* Messages from the background */ listen: function () { this.xConnect.onDisconnect.addListener(function (xPort) { let sError = ""; if (xPort.error) { sError = xPort.error.message; } else if (browser.runtime.lastError) { sError = browser.runtime.lastError.message; } console.log("[Grammalecte] Connection to the background script has been lost. Error :", sError); this.xConnect = browser.runtime.connect({name: "content-script port"}); this.listen(); }.bind(this)); this.xConnect.onMessage.addListener(function (oMessage) { let { sActionDone, result, oInfo, bEnd, bError } = oMessage; switch (sActionDone) { case "init": oGrammalecte.sExtensionUrl = oMessage.sUrl; oGrammalecte.listen(); oGrammalecte.createButton(); |
︙ | ︙ |