Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | [fx] get dictionaries list, download dictionaries |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | fx | comdic |
Files: | files | file ages | folders |
SHA3-256: | a0890eba14f9a3f9155981bd9872389c |
User & Date: | olr 2019-01-28 22:17:32 |
Context
2019-01-30
| ||
16:33 | [fx] dictionaries reorganization check-in: c3e4095da4 user: olr tags: comdic, fx | |
2019-01-28
| ||
22:17 | [fx] get dictionaries list, download dictionaries check-in: a0890eba14 user: olr tags: comdic, fx | |
2019-01-23
| ||
16:03 | [graphspell] new date format for consistency with the DB check-in: ef6ea473b6 user: olr tags: comdic, graphspell | |
Changes
Changes to gc_lang/fr/webext/background.js.
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
browser.storage.local.remove("oPersonalDictionary");
}
if (oData.hasOwnProperty("dictionaries")) {
if (oData.dictionaries.hasOwnProperty("__personal__")) {
setDictionary("personal", oData.dictionaries["__personal__"]);
}
if (oData.dictionaries.hasOwnProperty("__community__")) {
setDictionary("personal", oData.dictionaries["__community__"]);
}
}
}
function init () {
if (bChrome) {
browser.storage.local.get("gc_options", initGrammarChecker);
|
| |
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
browser.storage.local.remove("oPersonalDictionary");
}
if (oData.hasOwnProperty("dictionaries")) {
if (oData.dictionaries.hasOwnProperty("__personal__")) {
setDictionary("personal", oData.dictionaries["__personal__"]);
}
if (oData.dictionaries.hasOwnProperty("__community__")) {
setDictionary("community", oData.dictionaries["__community__"]);
}
}
}
function init () {
if (bChrome) {
browser.storage.local.get("gc_options", initGrammarChecker);
|
Changes to gc_lang/fr/webext/manifest.json.
112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
"grammalecte/fr/mfsp_data.json", "grammalecte/fr/phonet_data.json", "grammalecte/fr/tests_data.json", "img/logo-16.png" ], "permissions": [ "activeTab", "contextMenus", "downloads", "storage" ], "chrome_settings_overrides": { |
> > |
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
"grammalecte/fr/mfsp_data.json", "grammalecte/fr/phonet_data.json", "grammalecte/fr/tests_data.json", "img/logo-16.png" ], "permissions": [ "*://localhost/*", "*://dic.grammalecte.net/*", "activeTab", "contextMenus", "downloads", "storage" ], "chrome_settings_overrides": { |
Changes to gc_lang/fr/webext/panel/dictionaries.js.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 .. 97 98 99 100 101 102 103 104 105 106 107 108 109 110 ... 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 ... 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 ... 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
} catch (e) { showError(e); } } class Table { constructor (sNodeId, lColumn, sProgressBarId, sResultId="", bDeleteButtons=true, bActionButtons) { this.sNodeId = sNodeId; this.xTable = document.getElementById(sNodeId); this.nColumn = lColumn.length; this.lColumn = lColumn; this.xProgressBar = document.getElementById(sProgressBarId); this.xNumEntry = document.getElementById(sResultId); this.iEntryIndex = 0; this.lEntry = []; this.nEntry = 0; this.aSelectedDict = new Map(); this.bDeleteButtons = bDeleteButtons; this.bActionButtons = bActionButtons; this._createHeader(); this.listen(); } _createHeader () { ................................................................................ this.lEntry.push(...lFlex); for (let lData of lFlex) { this._addRow(lData); } this.nEntry += lFlex.length; this.showEntryNumber(); } showEntryNumber () { if (this.xNumEntry) { this.xNumEntry.textContent = this.nEntry; } } ................................................................................ } onTableClick (xEvent) { try { let xElem = xEvent.target; if (xElem.className) { switch (xElem.className) { case "delete_entry": this.deleteRow(xElem.dataset.id_entry, xElem.dataset.dict_name); break; case "select_entry": this.selectEntry(xElem.dataset.id_entry, xElem.dataset.dict_name); break; } } } catch (e) { showError(e); } } ................................................................................ if (this.sNodeId == "lexicon_table") { showElement("save_button", "inline-block"); } } selectEntry (nEntryId, sDicName) { let sRowId = this.sNodeId + "_row_" + nEntryId; if (!this.aSelectedDict.has(sDicName)) { this.aSelectedDict.set(sDicName, nEntryId); document.getElementById(sRowId).style.backgroundColor = "hsl(120, 50%, 90%)"; } else { this.aSelectedDict.delete(sDicName); document.getElementById(sRowId).style.backgroundColor = ""; } this.showSelectedDict(); } clearSelectedDict () { let xDicList = document.getElementById("dictionaries_list"); ................................................................................ xDicList.removeChild(xDicList.firstChild); } } showSelectedDict () { this.clearSelectedDict(); let xDicList = document.getElementById("dictionaries_list"); if (this.aSelectedDict.size === 0) { xDicList.textContent = "[Aucun]"; return; } for (let [sName, nDicId] of this.aSelectedDict) { xDicList.appendChild(this.createDictLabel(nDicId, sName)); } } createDictLabel (nDicId, sLabel) { let xLabel = createNode("div", {className: "dic_button"}); let xCloseButton = createNode("div", {className: "dic_button_close", textContent: "×"}, {id_entry: nDicId}); xCloseButton.addEventListener("click", () => { this.aSelectedDict.delete(sLabel); document.getElementById(this.sNodeId+"_row_"+nDicId).style.backgroundColor = ""; xLabel.style.display = "none"; }); xLabel.appendChild(xCloseButton); xLabel.appendChild(createNode("div", {className: "dic_button_label", textContent: sLabel})); return xLabel; } } const oDicTable = new Table("dictionaries_table", ["Id", "Nom", "par", "Entrées", "Description"], "wait_progress", "num_dic", false, true); oDicTable.fill([ [1, "Ambre", "Inconnu", "240", "Univers des Princes d’Ambre (de Roger Zelazny)"], [2, "Malaz", "Inconnu", "2340", "Univers du Livre des Martyrs (de Steven Erikson)"], [3, "Poudlard", "Inconnu", "1440", "Univers d’Harry Potter (de J. K. Rowlings)"], [4, "Dune", "Inconnu", "2359", "Univers de Dune (de Frank Herbert)"], [5, "StarWars", "Inconnu", "4359", "Univers de Star Wars (de George Lucas)"] ]); |
> | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > | > | | | | | | | < < < < < < |
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 .. 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 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 150 151 152 153 154 155 156 157 158 ... 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 ... 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 ... 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
} catch (e) { showError(e); } } class Table { constructor (sNodeId, lColumn, sProgressBarId, sResultId="", bDeleteButtons=true, bActionButtons) { this.sNodeId = sNodeId; this.xTable = document.getElementById(sNodeId); this.nColumn = lColumn.length; this.lColumn = lColumn; this.xProgressBar = document.getElementById(sProgressBarId); this.xNumEntry = document.getElementById(sResultId); this.iEntryIndex = 0; this.lEntry = []; this.nEntry = 0; this.dSelectedDict = new Map(); this.dDict = new Map(); this.bDeleteButtons = bDeleteButtons; this.bActionButtons = bActionButtons; this._createHeader(); this.listen(); } _createHeader () { ................................................................................ this.lEntry.push(...lFlex); for (let lData of lFlex) { this._addRow(lData); } this.nEntry += lFlex.length; this.showEntryNumber(); } getDictionarieslist () { fetch("http://localhost/dictionaries/") .then((response) => { if (response.ok) { return response.json(); } else { return null; } }) .then((response) => { if (response) { this.fill(response); } else { // todo } }) .catch((e) => { showError(e); }); } getDictionary (sId, sName) { console.log("get: "+sName); fetch("http://localhost/download/"+sName) .then((response) => { if (response.ok) { return response.json(); } else { console.log("dictionary not loaded: " + sName); return null; } }) .then((response) => { if (response) { this.selectEntry(sId, sName); this.dDict.set(sName, response); browser.storage.local.set({ "stored_dictionaries": this.dDict }); } else { // } }) .catch((e) => { showError(e); }); } showEntryNumber () { if (this.xNumEntry) { this.xNumEntry.textContent = this.nEntry; } } ................................................................................ } onTableClick (xEvent) { try { let xElem = xEvent.target; if (xElem.className) { switch (xElem.className) { case "delete_entry": this.deleteRow(xElem.dataset.id_entry, xElem.dataset.dict_name); break; case "select_entry": this.getDictionary(xElem.dataset.id_entry, xElem.dataset.dict_name); break; } } } catch (e) { showError(e); } } ................................................................................ if (this.sNodeId == "lexicon_table") { showElement("save_button", "inline-block"); } } selectEntry (nEntryId, sDicName) { let sRowId = this.sNodeId + "_row_" + nEntryId; if (!this.dSelectedDict.has(sDicName)) { this.dSelectedDict.set(sDicName, nEntryId); document.getElementById(sRowId).style.backgroundColor = "hsl(120, 50%, 90%)"; } else { this.dSelectedDict.delete(sDicName); document.getElementById(sRowId).style.backgroundColor = ""; } this.showSelectedDict(); } clearSelectedDict () { let xDicList = document.getElementById("dictionaries_list"); ................................................................................ xDicList.removeChild(xDicList.firstChild); } } showSelectedDict () { this.clearSelectedDict(); let xDicList = document.getElementById("dictionaries_list"); if (this.dSelectedDict.size === 0) { xDicList.textContent = "[Aucun]"; return; } for (let [sName, nDicId] of this.dSelectedDict) { xDicList.appendChild(this.createDictLabel(nDicId, sName)); } } createDictLabel (nDicId, sLabel) { let xLabel = createNode("div", {className: "dic_button"}); let xCloseButton = createNode("div", {className: "dic_button_close", textContent: "×"}, {id_entry: nDicId}); xCloseButton.addEventListener("click", () => { this.dSelectedDict.delete(sLabel); document.getElementById(this.sNodeId+"_row_"+nDicId).style.backgroundColor = ""; xLabel.style.display = "none"; }); xLabel.appendChild(xCloseButton); xLabel.appendChild(createNode("div", {className: "dic_button_label", textContent: sLabel})); return xLabel; } } const oDicTable = new Table("dictionaries_table", ["Id", "Nom", "par", "Entrées", "Description"], "wait_progress", "num_dic", false, true); oDicTable.getDictionarieslist(); |