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 on 2019-01-28 22:17:32 |
Other Links: | branch diff | manifest | tags |
Context
2019-01-30
| ||
16:33 | [fx] dictionaries reorganization check-in: c3e4095da4 user: olr tags: fx, comdic | |
2019-01-28
| ||
22:17 | [fx] get dictionaries list, download dictionaries check-in: a0890eba14 user: olr tags: fx, comdic | |
2019-01-23
| ||
16:03 | [graphspell] new date format for consistency with the DB check-in: ef6ea473b6 user: olr tags: graphspell, comdic | |
Changes
Modified gc_lang/fr/webext/background.js from [8000393b2f] to [dfd47dd30f].
︙ | ︙ | |||
151 152 153 154 155 156 157 | browser.storage.local.remove("oPersonalDictionary"); } if (oData.hasOwnProperty("dictionaries")) { if (oData.dictionaries.hasOwnProperty("__personal__")) { setDictionary("personal", oData.dictionaries["__personal__"]); } if (oData.dictionaries.hasOwnProperty("__community__")) { | | | 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); |
︙ | ︙ |
Modified gc_lang/fr/webext/manifest.json from [928cff8b51] to [c2f849d8b2].
︙ | ︙ | |||
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": { |
︙ | ︙ |
Modified gc_lang/fr/webext/panel/dictionaries.js from [85a136186d] to [35271f2dab].
︙ | ︙ | |||
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | } 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; | > | > | 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 | } 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 () { |
︙ | ︙ | |||
97 98 99 100 101 102 103 104 105 106 107 108 109 110 | 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; } } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | 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; } } |
︙ | ︙ | |||
133 134 135 136 137 138 139 | } onTableClick (xEvent) { try { let xElem = xEvent.target; if (xElem.className) { switch (xElem.className) { | > | > > | > | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | } 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); } } |
︙ | ︙ | |||
157 158 159 160 161 162 163 | if (this.sNodeId == "lexicon_table") { showElement("save_button", "inline-block"); } } selectEntry (nEntryId, sDicName) { let sRowId = this.sNodeId + "_row_" + nEntryId; | | | | | | | | < < < < < < | 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 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | 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"); while (xDicList.firstChild) { 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(); |