Grammalecte  Check-in [68fe952d73]

Overview
Comment:[fx] WebExt: adaptation to Chrome: Map can’t be sent via extension messaging interface
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | fx
Files: files | file ages | folders
SHA3-256: 68fe952d7354adcae9bd64476ac4c7abd285ab8ec8b71b6457b952a73647f89c
User & Date: olr on 2017-09-28 09:29:30
Other Links: manifest | tags
Context
2017-09-28
10:27
[fx] WebExt: add Oswald font as equivalent to Yanone K. check-in: ca229fd382 user: olr tags: trunk, fx
09:29
[fx] WebExt: adaptation to Chrome: Map can’t be sent via extension messaging interface check-in: 68fe952d73 user: olr tags: trunk, fx
2017-09-27
12:26
[fx] WebExt: no infinite animation: stop after 10 iterations check-in: 53c3063ab1 user: olr tags: trunk, fx
Changes

Modified gc_lang/fr/webext/background.js from [33ad7410c9] to [006072374b].

48
49
50
51
52
53
54
55
56




57
58
59
60
61
62
63
                // 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);
                storeGCOptions(result);




                break;
            case "setOptions":
            case "setOption":
                storeGCOptions(result);
                break;
            default:
                console.log("[background] Unknown command: " + sActionDone);







<

>
>
>
>







48
49
50
51
52
53
54

55
56
57
58
59
60
61
62
63
64
65
66
                // send result to panel
                browser.runtime.sendMessage(e.data);
                break;
            case "getOptions":
            case "getDefaultOptions":
            case "resetOptions":
                // send result to panel

                storeGCOptions(result);
                if (bChrome) {
                    e.data.result = helpers.mapToObject(e.data.result);
                }
                browser.runtime.sendMessage(e.data);
                break;
            case "setOptions":
            case "setOption":
                storeGCOptions(result);
                break;
            default:
                console.log("[background] Unknown command: " + sActionDone);
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
/*
    Actions
*/

function storeGCOptions (dOptions) {
    if (bChrome) {
        // JS crap again. Chrome can’t store Map object.
        let obj = {};
        for (let [k, v] of dOptions) {
            obj[k] = v;
        }
        dOptions = obj;
    }
    browser.storage.local.set({"gc_options": dOptions});
}

function parseAndSpellcheckSelectedText (iTab, sText) {
    // send message to the tab
    let xTabPort = dConnx.get(iTab);







<
<
<
<
|







265
266
267
268
269
270
271




272
273
274
275
276
277
278
279
/*
    Actions
*/

function storeGCOptions (dOptions) {
    if (bChrome) {
        // JS crap again. Chrome can’t store Map object.




        dOptions = helpers.mapToObject(dOptions);
    }
    browser.storage.local.set({"gc_options": dOptions});
}

function parseAndSpellcheckSelectedText (iTab, sText) {
    // send message to the tab
    let xTabPort = dConnx.get(iTab);

Modified gc_lang/fr/webext/manifest.json from [540693d351] to [bbea6aa8bb].

31
32
33
34
35
36
37

38
39
40
41
42
43
44
    "default_popup": "panel/main.html",
    "default_title": "Grammalecte [fr]",
    "browser_style": false
  },

  "background": {
    "scripts": [

      "background.js"
    ]
  },

  "content_scripts": [
    {
      "matches": ["<all_urls>"],







>







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
    "default_popup": "panel/main.html",
    "default_title": "Grammalecte [fr]",
    "browser_style": false
  },

  "background": {
    "scripts": [
      "grammalecte/helpers.js",
      "background.js"
    ]
  },

  "content_scripts": [
    {
      "matches": ["<all_urls>"],

Modified gc_lang/fr/webext/panel/main.js from [515cc52320] to [4bafd8a9dd].

147
148
149
150
151
152
153

154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
function _setGCOptions (dSavedOptions) {
    if (dSavedOptions.hasOwnProperty("gc_options")) {
        setGCOptions(dSavedOptions.gc_options);
    }
}

function setGCOptions (dOptions) {

    if (bChrome) {
        // JS crap again. Chrome can’t store Map object.
        let m = new Map();
        for (let param in dOptions) {
            m.set(param, dOptions[param]);
        }
        dOptions = m;
    }
    for (let [sOpt, bVal] of dOptions) {
        console.log(sOpt + ": " + bVal);
        if (document.getElementById("option_"+sOpt)) {
            document.getElementById("option_"+sOpt).checked = bVal;
        }
    }
}







>

|







<





147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163

164
165
166
167
168
function _setGCOptions (dSavedOptions) {
    if (dSavedOptions.hasOwnProperty("gc_options")) {
        setGCOptions(dSavedOptions.gc_options);
    }
}

function setGCOptions (dOptions) {
    // dOptions is supposed to be a Map
    if (bChrome) {
        // JS crap again. Chrome can’t store/send Map object.
        let m = new Map();
        for (let param in dOptions) {
            m.set(param, dOptions[param]);
        }
        dOptions = m;
    }
    for (let [sOpt, bVal] of dOptions) {

        if (document.getElementById("option_"+sOpt)) {
            document.getElementById("option_"+sOpt).checked = bVal;
        }
    }
}