Grammalecte  Check-in [db25c98bc2]

Overview
Comment:[fx] Use only the Sharedworker (cleanup code in background)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fx | webext_sharedworker
Files: files | file ages | folders
SHA3-256: db25c98bc2d49319935f19df8248e97f305440f7208536b6f447cb0707ee4752
User & Date: IllusionPerdu on 2017-08-10 21:20:31
Other Links: branch diff | manifest | tags
Context
2017-08-11
06:05
[fx] some code cleaning + another test check-in: b1dd1ce191 user: olr tags: fx, webext_sharedworker
2017-08-10
21:20
[fx] Use only the Sharedworker (cleanup code in background) check-in: db25c98bc2 user: IllusionPerdu tags: fx, webext_sharedworker
18:25
[fx] Fix previous commit check-in: 438b74bcdf user: IllusionPerdu tags: fx, webext_sharedworker
Changes

Modified gc_lang/fr/webext/background.js from [eb2f1b3278] to [b961377700].

     5      5   function showError (e) {
     6      6       console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
     7      7   }
     8      8   
     9      9   /*
    10     10       Worker (separate thread to avoid freezing Firefox)
    11     11   */
    12         -let xGCEWorker = new Worker("gce_worker.js");
           12  +//let xGCEWorker = new Worker("gce_worker.js");
           13  +let xGCESharedWorker = new SharedWorker(browser.extension.getURL("gce_sharedworker.js"));
           14  +let xGCEWorker = xGCESharedWorker.port;
    13     15   
    14     16   xGCEWorker.onmessage = function (e) {
    15     17       // https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent
    16     18       try {
    17     19           switch (e.data[0]) {
    18     20               case "grammar_errors":
    19     21                   console.log("GRAMMAR ERRORS");
................................................................................
   174    176           type: 'panel', url: browser.extension.getURL("panel/conjugueur.html"), top: top, left: left, width: width, height: height,
   175    177       });
   176    178       browser.windows.update(xWin.id, { top:top, left:left, }); // firefox currently ignores top and left in .create(), so move it here
   177    179       console.log("Async done");
   178    180   }
   179    181   
   180    182   //newwin();
   181         -
   182         -
   183         -/*
   184         -    Worker (separate thread to avoid freezing Firefox)
   185         -*/
   186         -/*
   187         -let xGCESharedWorker = new SharedWorker("gce_sharedworker.js");
   188         -
   189         -xGCESharedWorker.port.onmessage = function (e) {
   190         -    // https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent
   191         -    try {
   192         -        switch (e.data[0]) {
   193         -            case "grammar_errors":
   194         -                console.log("GRAMMAR ERRORS (SHARE)");
   195         -                console.log(e.data[1].aGrammErr);
   196         -                //browser.runtime.sendMessage({sCommand: "grammar_errors", aGrammErr: e.data[1].aGrammErr});
   197         -                break;
   198         -            case "spelling_and_grammar_errors":
   199         -                console.log("SPELLING AND GRAMMAR ERRORS (SHARE)");
   200         -                console.log(e.data[1].aSpellErr);
   201         -                console.log(e.data[1].aGrammErr);
   202         -                break;
   203         -            case "text_to_test_result":
   204         -                console.log("TESTS RESULTS (SHARE)");
   205         -                console.log(e.data[1]);
   206         -                break;
   207         -            case "fulltests_result":
   208         -                console.log("TESTS RESULTS (SHARE)");
   209         -                console.log(e.data[1]);
   210         -                break;
   211         -            case "options":
   212         -                console.log("OPTIONS (SHARE)");
   213         -                console.log(e.data[1]);
   214         -                break;
   215         -            case "tokens":
   216         -                console.log("TOKENS (SHARE)");
   217         -                console.log(e.data[1]);
   218         -                let xLxgTab = browser.tabs.create({
   219         -                    url: browser.extension.getURL("panel/lexicographer.html"),
   220         -                });
   221         -                xLxgTab.then(onCreated, onError);
   222         -                break;
   223         -            case "error":
   224         -                console.log("ERROR (SHARE)");
   225         -                console.log(e.data[1]);
   226         -                break;
   227         -            default:
   228         -                console.log("Unknown command (SHARE): " + e.data[0]);
   229         -        }
   230         -    }
   231         -    catch (e) {
   232         -        showError(e);
   233         -    }
   234         -};
   235         -
   236         -console.log("Content script [worker]");
   237         -console.log(xGCESharedWorker);
   238         -
   239         -
   240         -//xGCESharedWorker.port.start();
   241         -//console.log("Content script [port started]");
   242         -
   243         -xGCESharedWorker.port.postMessage(["init", {sExtensionPath: browser.extension.getURL("."), sOptions: "", sContext: "Firefox"}]);
   244         -
   245         -console.log("Content script [worker initialzed]");
   246         -
   247         -xGCESharedWorker.port.postMessage(["parse", {sText: "Vas... J’en aie mare...", sCountry: "FR", bDebug: false, bContext: false}]);
   248         -//xGCESharedWorker.port.postMessage(["parseAndSpellcheck", {sText: oRequest.sText, sCountry: "FR", bDebug: false, bContext: false}]);
   249         -//xGCESharedWorker.port.postMessage(["getListOfTokens", {sText: oRequest.sText}]);
   250         -//xGCESharedWorker.port.postMessage(["textToTest", {sText: oRequest.sText, sCountry: "FR", bDebug: false, bContext: false}]);
   251         -//xGCESharedWorker.port.postMessage(["fullTests"]);
   252         -
   253         -
   254         -*/