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: fx, trunk
2017-09-26
13:46
[fx] WebExt: a Map is not a Map anymore on Chrome (not working) check-in: e2850f295a user: olr tags: fx, trunk
11:36
[fx] WebExt: adaptation to Chrome (load options) check-in: 939c8db8c7 user: olr tags: fx, trunk
Changes

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

    29     29   def _createOptionsForWebExtension (dVars):
    30     30       sHTML = ""
    31     31       sLang = dVars['sDefaultUILang']
    32     32       for sSection, lOpt in dVars['lStructOpt']:
    33     33           sHTML += f'\n<div id="subsection_{sSection}" class="opt_subsection">\n  <h2 data-l10n-id="option_{sSection}">{dVars["dOptLabel"][sLang][sSection][0]}</h2>\n'
    34     34           for lLineOpt in lOpt:
    35     35               for sOpt in lLineOpt:
    36         -                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'
           36  +                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'
    37     37           sHTML += '</div>\n'
    38     38       return sHTML
    39     39   
    40     40   
    41     41   def createFirefoxExtension (sLang, dVars):
    42     42       "create extension for Firefox"
    43     43       print("Building extension for Firefox")

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

   147    147   function _setGCOptions (dSavedOptions) {
   148    148       if (dSavedOptions.hasOwnProperty("gc_options")) {
   149    149           setGCOptions(dSavedOptions.gc_options);
   150    150       }
   151    151   }
   152    152   
   153    153   function setGCOptions (dOptions) {
          154  +    console.log(typeof(dOptions));
   154    155       console.log(dOptions);
   155         -    for (let [sOpt, bVal] of dOptions) {
          156  +    /*for (let [sOpt, bVal] of dOptions) {
   156    157           if (document.getElementById("option_"+sOpt)) {
   157    158               document.getElementById("option_"+sOpt).checked = bVal;
   158    159           }
          160  +    }*/
          161  +    // JS bullshit never ends. For some reason, it’s not a Map anymore on Chrome! 
          162  +    for (let xOption of document.getElementsByClassName("gc_option")) {
          163  +        console.log(xOption.id);
          164  +        let sOpt = xOption.id.slice(7);
          165  +        if (dOptions.has(sOpt)) {
          166  +            xOption.checked = dOptions.get(sOpt);
          167  +        }
   159    168       }
   160    169   }