Grammalecte  Diff

Differences From Artifact [405aefbae4]:

To Artifact [4bafd8a9dd]:


1
2
3
4
5
6
7
8
9








10
11
12
13
14
15
16
// Main panel

"use strict";


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










/*
    Events
*/
window.addEventListener(
    "click",
    function (xEvent) {









>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Main panel

"use strict";


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(
    "click",
    function (xEvent) {
121
122
123
124
125
126
127
128

129




130
131


132
133
134
135
136
137
138
139
140
141







142
143

144
145
146
147
148
149
    }
}


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;
        }
    }
}








>

>
>
>
>

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






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
161
162
163
164
165
166
167
168
    }
}


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) {
    // 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;
        }
    }
}