Grammalecte  Check-in [e2850f295a]

Overview
Comment:[fx] WebExt: a Map is not a Map anymore on Chrome (not working)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | fx
Files: files | file ages | folders
SHA3-256: e2850f295a172b37656d530e3b2d0f757f85421642213830d867167fbe396382
User & Date: olr on 2017-09-26 13:46:40
Other Links: manifest | tags
Context
2017-09-27
09:10
[fx] WebExt: adaptation to Chrome (write and read gc options) check-in: 6d2246be0e user: olr tags: trunk, fx
2017-09-26
13:46
[fx] WebExt: a Map is not a Map anymore on Chrome (not working) check-in: e2850f295a user: olr tags: trunk, fx
11:36
[fx] WebExt: adaptation to Chrome (load options) check-in: 939c8db8c7 user: olr tags: trunk, fx
Changes

Modified gc_lang/fr/build.py from [677a5b04fd] to [e6bfac7235].

29
30
31
32
33
34
35
36

37
38
39
40
41
42
43
29
30
31
32
33
34
35

36
37
38
39
40
41
42
43







-
+







def _createOptionsForWebExtension (dVars):
    sHTML = ""
    sLang = dVars['sDefaultUILang']
    for sSection, lOpt in dVars['lStructOpt']:
        sHTML += f'\n<div id="subsection_{sSection}" class="opt_subsection">\n  <h2 data-l10n-id="option_{sSection}">{dVars["dOptLabel"][sLang][sSection][0]}</h2>\n'
        for lLineOpt in lOpt:
            for sOpt in lLineOpt:
                sHTML += f'  <p><input type="checkbox" id="option_{sOpt}" data-option="{sOpt}"/><label id="option_label_{sOpt}" for="option_{sOpt}" data-l10n-id="option_{sOpt}">{dVars["dOptLabel"][sLang][sOpt][0]}</label></p>\n'
                sHTML += f'  <p><input type="checkbox" id="option_{sOpt}" class="gc_option" data-option="{sOpt}"/><label id="option_label_{sOpt}" for="option_{sOpt}" data-l10n-id="option_{sOpt}">{dVars["dOptLabel"][sLang][sOpt][0]}</label></p>\n'
        sHTML += '</div>\n'
    return sHTML


def createFirefoxExtension (sLang, dVars):
    "create extension for Firefox"
    print("Building extension for Firefox")

Modified gc_lang/fr/webext/panel/main.js from [57b0e4a29a] to [0dd514b39a].

147
148
149
150
151
152
153

154
155

156
157
158







159
160



147
148
149
150
151
152
153
154
155

156
157
158
159
160
161
162
163
164
165
166


167
168
169







+

-
+



+
+
+
+
+
+
+
-
-
+
+
+
function _setGCOptions (dSavedOptions) {
    if (dSavedOptions.hasOwnProperty("gc_options")) {
        setGCOptions(dSavedOptions.gc_options);
    }
}

function setGCOptions (dOptions) {
    console.log(typeof(dOptions));
    console.log(dOptions);
    for (let [sOpt, bVal] of dOptions) {
    /*for (let [sOpt, bVal] of dOptions) {
        if (document.getElementById("option_"+sOpt)) {
            document.getElementById("option_"+sOpt).checked = bVal;
        }
    }*/
    // JS bullshit never ends. For some reason, it’s not a Map anymore on Chrome! 
    for (let xOption of document.getElementsByClassName("gc_option")) {
        console.log(xOption.id);
        let sOpt = xOption.id.slice(7);
        if (dOptions.has(sOpt)) {
            xOption.checked = dOptions.get(sOpt);
    }
}
        }
    }
}