Grammalecte  Check-in [b6e7aac88a]

Overview
Comment:[fx] text formatter options
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | fx | webext2
Files: files | file ages | folders
SHA3-256: b6e7aac88a3dda2268406a1938c5fa4d4ba9f2d420851a9b9d1053824ab4128e
User & Date: olr on 2017-08-25 10:26:23
Other Links: branch diff | manifest | tags
Context
2017-08-25
11:16
[fx] wrap code within a singleton check-in: 4c672a2689 user: olr tags: fx, webext2
10:26
[fx] text formatter options check-in: b6e7aac88a user: olr tags: fx, webext2
2017-08-24
11:28
[fx] text formatter update check-in: ab1793ecaf user: olr tags: fx, webext2
Changes

Modified gc_lang/fr/webext/background.js from [ce09d05446] to [81c56b5090].

114
115
116
117
118
119
120

121
122
123
124
125
126
127
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128







+







            case "getListOfTokens":
                oRequest.dInfo.iReturnPort = iPortId; // we pass the id of the return port to receive answer
                console.log(oRequest);
                xGCEWorker.postMessage(oRequest);
                break;
            default:
                console.log("[background] Unknown command: " + oRequest.sCommand);
                console.log(oRequest);
        }
    });
    xPort.postMessage({sActionDone: "newId", result: iPortId});
}

browser.runtime.onConnect.addListener(handleConnexion);

Modified gc_lang/fr/webext/content_scripts/content_modifier.js from [8ce1a9bdc9] to [206795793d].

107
108
109
110
111
112
113
114

115
116
117
118
119
120

121
122
123
124
125
126
127
107
108
109
110
111
112
113

114
115
116
117
118
119

120
121
122
123
124
125
126
127







-
+





-
+







        oConjPanel.insertIntoPage();
    }
}

function createTFPanel (xTextArea) {
    console.log("Formateur de texte");
    if (oTFPanel !== null) {
        oTFPanel.setTextArea(xTextArea);
        oTFPanel.start(xTextArea);
        oTFPanel.show();
    } else {
        // create the panel
        oTFPanel = new GrammalecteTextFormatter("grammalecte_tf_panel", "Formateur de texte", 800, 620, false);
        oTFPanel.logInnerHTML();
        oTFPanel.setTextArea(xTextArea);
        oTFPanel.start(xTextArea);
        oTFPanel.insertIntoPage();
    }
}

function createLxgPanel () {
    console.log("Lexicographe");
    if (oLxgPanel !== null) {

Modified gc_lang/fr/webext/content_scripts/tf_content.js from [8ddc3692fd] to [236732302d].

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
9
10
11
12
13
14
15




16
17
18
19
20
21
22







-
-
-
-







    constructor (...args) {
        super(...args);
        this.xTFNode = this._createTextFormatter();
        this.xPanelContent.appendChild(this.xTFNode);
        this.xTextArea = null;
    }

    setTextArea (xTextArea) {
        this.xTextArea = xTextArea;
    }

    _createTextFormatter () {
        let xTFNode = document.createElement("div");
        try {
            // Options
            let xOptions = createNode("div", {id: "grammalecte_tf_options"});
            let xColumn1 = createNode("div", {className: "grammalecte_tf_column"});
            let xSSP = this._createFieldset("group_ssp", true, "Espaces surnuméraires");
74
75
76
77
78
79
80
81

82
83
84
85
86
87
88
70
71
72
73
74
75
76

77
78
79
80
81
82
83
84







-
+







            xOptions.appendChild(xColumn1);
            xOptions.appendChild(xColumn2);
            // Actions
            let xActions = createNode("div", {id: "grammalecte_tf_actions"});
            let xDefaultButton = createNode("div", {id: "grammalecte_tf_reset", textContent: "Par défaut", className: "grammalecte_button", style: "background-color: hsl(210, 50%, 50%)"});
            xDefaultButton.addEventListener("click", () => { this.reset(); });
            let xApplyButton = createNode("div", {id: "grammalecte_tf_apply", textContent: "Appliquer", className: "grammalecte_button", style: "background-color: hsl(180, 50%, 50%)"});
            xApplyButton.addEventListener("click", () => { this.apply(); });
            xApplyButton.addEventListener("click", () => { this.saveOptions(); this.apply(); });
            xActions.appendChild(xDefaultButton);
            xActions.appendChild(createNode("progress", {id: "grammalecte_tf_progressbar"}));
            xActions.appendChild(createNode("span", {id: "grammalecte_tf_time_res", textContent: "…"}));
            xActions.appendChild(xApplyButton);
            //xActions.appendChild(createNode("div", {id: "grammalecte_infomsg", textContent: "blabla"}));
            // create result
            xTFNode.appendChild(xOptions);
177
178
179
180
181
182
183






184
185
186
187
188
189
190
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192







+
+
+
+
+
+







        return xInlineBlock;
    }


    /*
        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).checked) {
            document.getElementById(sOptName.slice(2)).style.opacity = 1;
        } else {
            document.getElementById(sOptName.slice(2)).style.opacity = 0.3;
        }
        this.resetProgressBar();
202
203
204
205
206
207
208
209

210
211
212

213
214
215
216
217
218









219
220
221
222
223
224
225
226

227
228

229
230
231
232
233
234
235
204
205
206
207
208
209
210

211



212






213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231

232
233
234
235
236
237
238
239







-
+
-
-
-
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+








+

-
+








    resetProgressBar () {
        document.getElementById('grammalecte_tf_progressbar').value = 0;
        document.getElementById('grammalecte_tf_time_res').textContent = "";
    }

    setOptions (oOptions) {
        for (let sOptName in oOptions) {
        if (oOptions.hasOwnProperty("tf_options")) {
            //console.log(sOptName + ":" + oOptions[sOptName]);
            if (document.getElementById(sOptName) !== null) {
                document.getElementById(sOptName).checked = oOptions[sOptName];
            oOptions = oOptions.tf_options;
                if (sOptName.startsWith("o_group_")) {
                    switchGroup(sOptName);
                } 
                if (document.getElementById("res_"+sOptName) !== null) {
                    document.getElementById("res_"+sOptName).textContent = "";
                }
        }
        for (let xNode of document.getElementsByClassName("option")) {
            //console.log(xNode.id + " > " + oOptions.hasOwnProperty(xNode.id) + ": " + oOptions[xNode.id] + " [" + xNode.dataset.default + "]");
            xNode.checked = (oOptions.hasOwnProperty(xNode.id)) ? oOptions[xNode.id] : (xNode.dataset.default === "true");
            if (document.getElementById("res_"+xNode.id) !== null) {
                document.getElementById("res_"+xNode.id).textContent = "";
            }
            if (xNode.id.startsWith("o_group_")) {
                this.switchGroup(xNode.id);
            }
        }
    }

    saveOptions () {
        let oOptions = {};
        for (let xNode of document.getElementsByClassName("option")) {
            oOptions[xNode.id] = xNode.checked;
            console.log(xNode.id + ": " + xNode.checked);
        }
        self.port.emit("saveOptions", JSON.stringify(oOptions));
        browser.storage.local.set({"tf_options": oOptions});
    }

    apply () {
        try {
            const t0 = Date.now();
            //window.setCursor("wait"); // change pointer
            this.resetProgressBar();

Modified gc_lang/fr/webext/manifest.json from [5ecb19059a] to [0fb7cb35d1].

59
60
61
62
63
64
65
66


67
68
69
70
71
72
73
74
75
76
59
60
61
62
63
64
65

66
67
68
69
70
71
72
73
74
75
76
77







-
+
+










    "grammalecte/fr/mfsp_data.json",
    "grammalecte/fr/phonet_data.json",
    "grammalecte/fr/tests_data.json",
    "img/logo-16.png"
  ],
  "permissions": [
    "activeTab",
    "contextMenus"
    "contextMenus",
    "storage"
  ],
  "chrome_settings_overrides": {
    "search_provider": {
      "name": "Grammalecte",
      "search_url": "https://www.dicollecte.org/dictionary.php?prj=fr&lemma={searchTerms}",
      "keyword": "disc",
      "favicon_url": "https://www.dicollecte.org/favicon.ico"
    }
  }
}