Grammalecte  Check-in [939c8db8c7]

Overview
Comment:[fx] WebExt: adaptation to Chrome (load options)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | fx
Files: files | file ages | folders
SHA3-256: 939c8db8c7d9226203a028c791f3fc61b2414d663721f7ba2e9bf160b790cc37
User & Date: olr on 2017-09-26 11:36:04
Other Links: manifest | tags
Context
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
10:25
[fx] WebExt: adaptation to Chrome (GC init) check-in: b93b38b03d user: olr tags: fx, trunk
Changes

Modified gc_lang/fr/webext/content_scripts/init.js from [0b754e6438] to [70b0a5f3fd].

12
13
14
15
16
17
18

19
20

21
22
23
24
25
26
27

function showError (e) {
    console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}

// Chrome don’t follow the W3C specification:
// https://browserext.github.io/browserext/

if (typeof(browser) !== "object") {
    var browser = chrome;

}


function createNode (sType, oAttr, oDataset=null) {
    try {
        let xNode = document.createElement(sType);
        Object.assign(xNode, oAttr);







>


>







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

function showError (e) {
    console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}

// Chrome don’t follow the W3C specification:
// https://browserext.github.io/browserext/
let bChrome = false;
if (typeof(browser) !== "object") {
    var browser = chrome;
    bChrome = true;
}


function createNode (sType, oAttr, oDataset=null) {
    try {
        let xNode = document.createElement(sType);
        Object.assign(xNode, oAttr);

Modified gc_lang/fr/webext/content_scripts/panel_tf.js from [ee3e21ae91] to [1a7fb65c7e].

160
161
162
163
164
165
166



167
168

169
170
171
172
173
174
175
    }
    
    /*
        Actions
    */
    start (xTextArea) {
        this.xTextArea = xTextArea;



        let xPromise = browser.storage.local.get("tf_options");
        xPromise.then(this.setOptions.bind(this), this.reset.bind(this));

    }

    switchGroup (sOptName) {
        if (document.getElementById(sOptName).dataset.selected == "true") {
            document.getElementById(sOptName.slice(2)).style.opacity = 1;
        } else {
            document.getElementById(sOptName.slice(2)).style.opacity = 0.3;







>
>
>
|
|
>







160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
    }
    
    /*
        Actions
    */
    start (xTextArea) {
        this.xTextArea = xTextArea;
        if (bChrome) {
            browser.storage.local.get("tf_options", this.setOptions.bind(this));
        } else {
            let xPromise = browser.storage.local.get("tf_options");
            xPromise.then(this.setOptions.bind(this), this.reset.bind(this));
        }
    }

    switchGroup (sOptName) {
        if (document.getElementById(sOptName).dataset.selected == "true") {
            document.getElementById(sOptName.slice(2)).style.opacity = 1;
        } else {
            document.getElementById(sOptName.slice(2)).style.opacity = 0.3;

Modified gc_lang/fr/webext/panel/main.js from [9a8dec5f0d] to [57b0e4a29a].

5
6
7
8
9
10
11

12
13

14
15
16
17
18
19
20
...
127
128
129
130
131
132
133
134

135




136
137


138
139
140
141
142
143
144
145
146
147
148
149

150
151
152
153
154
155

function showError (e) {
    console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}

// Chrome don’t follow the W3C specification:
// https://browserext.github.io/browserext/

if (typeof(browser) !== "object") {
    var browser = chrome;

}


/*
    Events
*/
window.addEventListener(
................................................................................
    }
}


function showTestResult (sText) {
    document.getElementById("tests_result").textContent = sText;
}


function setGCOptionsFromStorage () {




    let xPromise = browser.storage.local.get("gc_options");
    xPromise.then(


        function (dSavedOptions) {
            if (dSavedOptions.hasOwnProperty("gc_options")) {
                setGCOptions(dSavedOptions.gc_options);
            }
        },
        function (e) {
            showError(e);
        }
    );
}

function setGCOptions (dOptions) {

    for (let [sOpt, bVal] of dOptions) {
        if (document.getElementById("option_"+sOpt)) {
            document.getElementById("option_"+sOpt).checked = bVal;
        }
    }
}







>


>







 








>

>
>
>
>

|
>
>
|
|
|
|
<
<
<
<
<



>






5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150





151
152
153
154
155
156
157
158
159
160

function showError (e) {
    console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message);
}

// Chrome don’t follow the W3C specification:
// https://browserext.github.io/browserext/
let bChrome = false;
if (typeof(browser) !== "object") {
    var browser = chrome;
    bChrome = true;
}


/*
    Events
*/
window.addEventListener(
................................................................................
    }
}


function showTestResult (sText) {
    document.getElementById("tests_result").textContent = sText;
}


function setGCOptionsFromStorage () {
    if (bChrome) {
        browser.storage.local.get("gc_options", _setGCOptions);
        return;
    }
    let xPromise = browser.storage.local.get("gc_options");
    xPromise.then(_setGCOptions, showError);
}

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





}

function setGCOptions (dOptions) {
    console.log(dOptions);
    for (let [sOpt, bVal] of dOptions) {
        if (document.getElementById("option_"+sOpt)) {
            document.getElementById("option_"+sOpt).checked = bVal;
        }
    }
}