Overview
Comment: | [fx] update: lexical editor |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | fx |
Files: | files | file ages | folders |
SHA3-256: |
4c7933e88b532e03518e7874f1579f22 |
User & Date: | olr on 2018-01-26 17:15:00 |
Other Links: | manifest | tags |
Context
2018-01-27
| ||
16:41 | [fx] lexicon editor: conjugation tables check-in: f21fb89872 user: olr tags: trunk, fx | |
2018-01-26
| ||
17:15 | [fx] update: lexical editor check-in: 4c7933e88b user: olr tags: trunk, fx | |
2018-01-24
| ||
16:24 | [fx] update: lexicon editor check-in: ae6457bb81 user: olr tags: trunk, fx | |
Changes
Modified gc_lang/fr/webext/manifest.json from [444665e26c] to [d0c2c44fc6].
︙ | ︙ | |||
31 32 33 34 35 36 37 | "default_popup": "panel/main.html", "default_title": "Grammalecte [fr]", "browser_style": false }, "background": { "scripts": [ | | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | "default_popup": "panel/main.html", "default_title": "Grammalecte [fr]", "browser_style": false }, "background": { "scripts": [ "grammalecte/graphspell/helpers.js", "background.js" ] }, "content_scripts": [ { "matches": ["<all_urls>"], |
︙ | ︙ |
Modified gc_lang/fr/webext/panel/lex_editor.css from [d9e3b0412e] to [2b16d91579].
︙ | ︙ | |||
48 49 50 51 52 53 54 | } h3 { margin: 3px 0 2px 0; color: hsl(210, 50%, 50%); font: bold 16px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif; } | > > > | > > > | | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | } h3 { margin: 3px 0 2px 0; color: hsl(210, 50%, 50%); font: bold 16px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif; } #buttons { padding: 10px; justify-content: center; } #lexicon_button { background-color: hsl(210, 80%, 90%); } .main_button { margin: 0 5px; padding: 10px 30px; background-color: hsl(210, 10%, 95%); border-radius: 5px; cursor: pointer; } #add_word_page { display: none; |
︙ | ︙ |
Modified gc_lang/fr/webext/panel/lex_editor.html from [53b86a285e] to [1af617725b].
︙ | ︙ | |||
8 9 10 11 12 13 14 | <body> <div class="inbox"> <h1>Éditeur lexical</h1> | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <body> <div class="inbox"> <h1>Éditeur lexical</h1> <div id="buttons" class="container"> <div id="lexicon_button" class="main_button">Lexique</div> <div id="add_word_button" class="main_button">Ajout</div> </div> <div id="add_word_page"> <h2>Nouveau mot</h2> <input type="text" id="word" name="word" maxlength="60" value="" placeholder="votre mot" pattern="^[a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ._-]+$" autofocus /> |
︙ | ︙ | |||
222 223 224 225 226 227 228 | <div id="section_autre" class="section"> <h2>Autre</h2> <p>Indiquez les étiquettes grammaticales que vous voulez appliquer au mot. À utiliser seulement si vous savez ce que vous faites. Dans le cas contraire, tant pis pour vous.</p> <h3>Lemme</h3> <p><input type="text" id="lemma" name="lemma" maxlength="20" value="" pattern="^[a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ._-]+$" placeholder="lemme" /></p> <h3>Étiquettes</h3> | | < < < < < < < < | 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 | <div id="section_autre" class="section"> <h2>Autre</h2> <p>Indiquez les étiquettes grammaticales que vous voulez appliquer au mot. À utiliser seulement si vous savez ce que vous faites. Dans le cas contraire, tant pis pour vous.</p> <h3>Lemme</h3> <p><input type="text" id="lemma" name="lemma" maxlength="20" value="" pattern="^[a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ._-]+$" placeholder="lemme" /></p> <h3>Étiquettes</h3> <p><input type="text" id="tags" name="tags" maxlength="20" value="" pattern="^:[a-zA-Zà-ö0-9À-Öø-ÿØ-ßĀ-ʯ:._-]+$" placeholder="étiquettes" /></p> </div> </div> </div> <div id="actions"> <h2>Mots générés</h2> <h3>Forme fléchie (lemme), étiquettes</h3> <div id="results"> </div> <div id="buttonline"> <div id="add_to_lexicon">Ajouter au dictionnaire</div> </div> </div> </div> <div id="lexicon_page"> <h2>Votre lexique</h2> <table id="table"> </table> </div> </div> <script src="../grammalecte/graphspell/helpers.js"></script> <script src="lex_editor.js"></script> </body> </html> |
Modified gc_lang/fr/webext/panel/lex_editor.js from [b986ace5c1] to [07c481136a].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | // JavaScript "use strict"; function createNode (sType, oAttr, oDataset=null) { try { let xNode = document.createElement(sType); Object.assign(xNode, oAttr); if (oDataset) { Object.assign(xNode.dataset, oDataset); } return xNode; } catch (e) { showError(e); } } function showError (e) { console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message); } | > > > > > > > | > > | | | > | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 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 61 62 63 64 65 66 | // JavaScript "use strict"; // 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); if (oDataset) { Object.assign(xNode.dataset, oDataset); } return xNode; } catch (e) { showError(e); } } function showError (e) { console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message); } document.getElementById("lexicon_button").addEventListener("click", () => { oPage.showPage("lexicon"); }, false); document.getElementById("add_word_button").addEventListener("click", () => { oPage.showPage("word"); }, false); document.getElementById("editor").addEventListener("click", (xEvent) => { oPage.onSelectionClick(xEvent); }, false); document.getElementById("word").addEventListener("keyup", () => { oPage.onWrite(); }, false); document.getElementById("word2").addEventListener("keyup", () => { oPage.onWrite2(); }, false); document.getElementById("lemma").addEventListener("keyup", () => { oFlex.update(); }, false); document.getElementById("tags").addEventListener("keyup", () => { oFlex.update(); }, false); document.getElementById("add_to_lexicon").addEventListener("click", () => { oFlex.addToLexicon(); }, false); /* ACTIONS */ const oPage = { showPage: function (sPage) { if (sPage == "lexicon") { document.getElementById("add_word_page").style.display = "none"; document.getElementById("lexicon_page").style.display = "block"; document.getElementById("lexicon_button").style.backgroundColor = "hsl(210, 80%, 90%)"; document.getElementById("add_word_button").style.backgroundColor = "hsl(210, 10%, 95%)"; } else { document.getElementById("lexicon_page").style.display = "none"; document.getElementById("add_word_page").style.display = "block"; document.getElementById("lexicon_button").style.backgroundColor = "hsl(210, 10%, 95%)"; document.getElementById("add_word_button").style.backgroundColor = "hsl(210, 80%, 90%)"; } }, showEditor: function () { document.getElementById("editor").style.display = "block"; }, |
︙ | ︙ | |||
71 72 73 74 75 76 77 78 79 80 81 82 83 84 | if (document.getElementById(sName)) { document.getElementById(sName).style.display = "block"; } }, clear: function () { try { // nom, adjectif, noms propres for (let xElem of document.getElementsByName("POS")) { xElem.checked = false; } for (let xElem of document.getElementsByName("POS2")) { xElem.checked = false; } | > > | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | if (document.getElementById(sName)) { document.getElementById(sName).style.display = "block"; } }, clear: function () { try { document.getElementById("word2").value = ""; this.hideWord2(); // nom, adjectif, noms propres for (let xElem of document.getElementsByName("POS")) { xElem.checked = false; } for (let xElem of document.getElementsByName("POS2")) { xElem.checked = false; } |
︙ | ︙ | |||
129 130 131 132 133 134 135 136 137 138 139 140 141 142 | } }, onWrite: function () { if (document.getElementById("word").value.trim() !== "") { this.showEditor(); } else { this.hideEditor(); this.hideActions(); } }, onWrite2: function () { if (document.getElementById("word2").value.trim() !== "") { | > | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | } }, onWrite: function () { if (document.getElementById("word").value.trim() !== "") { this.showEditor(); } else { this.showSection("section_vide"); this.hideEditor(); this.hideActions(); } }, onWrite2: function () { if (document.getElementById("word2").value.trim() !== "") { |
︙ | ︙ | |||
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | try { this.clear(); let sGenderTag = ""; let sWord = document.getElementById("word").value.trim(); if (sWord.length > 0) { switch (this.cMainTag) { case "N": let sTag = this.getRadioValue("POS") + this.getRadioValue("genre"); switch (this.getRadioValue("pluriel")) { case "s": this.addFlexion(sWord, sWord, sTag+":s"); this.addFlexion(sWord+"s", sWord, sTag+":p"); break; case "x": this.addFlexion(sWord, sWord, sTag+":s"); this.addFlexion(sWord+"x", sWord, sTag+":p"); break; case "i": this.addFlexion(sWord, sWord, sTag+":i"); break; } let sWord2 = document.getElementById("word2").value.trim(); | > > > | | > > > > > | | > > | 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 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 264 265 266 267 268 269 270 271 272 273 274 275 | try { this.clear(); let sGenderTag = ""; let sWord = document.getElementById("word").value.trim(); if (sWord.length > 0) { switch (this.cMainTag) { case "N": if (!this.getRadioValue("POS") || !this.getRadioValue("genre")) { break; } let sTag = this.getRadioValue("POS") + this.getRadioValue("genre"); switch (this.getRadioValue("pluriel")) { case "s": this.addFlexion(sWord, sWord, sTag+":s"); this.addFlexion(sWord+"s", sWord, sTag+":p"); break; case "x": this.addFlexion(sWord, sWord, sTag+":s"); this.addFlexion(sWord+"x", sWord, sTag+":p"); break; case "i": this.addFlexion(sWord, sWord, sTag+":i"); break; } let sWord2 = document.getElementById("word2").value.trim(); if (sWord2.length > 0 && this.getRadioValue("POS2") && this.getRadioValue("genre2")) { let sTag2 = this.getRadioValue("POS2") + this.getRadioValue("genre2"); switch (this.getRadioValue("pluriel2")) { case "s": this.addFlexion(sWord2, sWord, sTag2+":s"); this.addFlexion(sWord2+"s", sWord, sTag2+":p"); break; case "x": this.addFlexion(sWord2, sWord, sTag2+":s"); this.addFlexion(sWord2+"x", sWord, sTag2+":p"); break; case "i": this.addFlexion(sWord2, sWord, sTag2+":i"); break; } } break; case "V": { if (!sWord.endsWith("er") && !sWord.endsWith("ir")) { break; } sWord = sWord.toLowerCase(); let c_g = (sWord.endsWith("er")) ? "1" : "2"; let c_i = (document.getElementById("up_v_i").checked) ? "i" : "_"; let c_t = (document.getElementById("up_v_t").checked) ? "t" : "_"; let c_n = (document.getElementById("up_v_n").checked) ? "n" : "_"; let c_p = (document.getElementById("up_v_p").checked) ? "p" : "_"; let c_m = (document.getElementById("up_v_m").checked) ? "m" : "_"; let c_ae = (document.getElementById("up_v_ae").checked) ? "e" : "_"; let c_aa = (document.getElementById("up_v_aa").checked) ? "a" : "_"; let sVerbTag = c_i + c_t + c_n + c_p + c_m + c_ae + c_aa; if (!sVerbTag.endsWith("__") && !sVerbTag.startsWith("____")) { if (sWord.endsWith("ir")) { for (let [nCut, sAdd, sFlexTags] of oConj["V2"]) { this.addFlexion(sWord.slice(0,-nCut)+sAdd, sWord, ":V" + c_g + "_" + sVerbTag+sFlexTags); } } else { this.addFlexion(sWord, sWord, ":V" + c_g + "_" + sVerbTag+":Y"); } } break; } case "W": sWord = sWord.toLowerCase(); this.addFlexion(sWord, sWord, ":W"); break; case "M1": sWord = sWord.slice(0,1).toUpperCase() + sWord.slice(1); sGenderTag = this.getRadioValue("genre_m1"); |
︙ | ︙ | |||
302 303 304 305 306 307 308 309 310 311 312 313 314 315 | } }, addToLexicon: function () { try { oLexicon.addFlexions(this.lFlexion); oLexicon.save(); } catch (e) { showError(e); } } } | > > > > > > | 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | } }, addToLexicon: function () { try { oLexicon.addFlexions(this.lFlexion); oLexicon.save(); document.getElementById("word").value = ""; oPage.showSection("section_vide"); oPage.hideEditor(); oPage.hideActions(); oPage.clear(); this.clear(); } catch (e) { showError(e); } } } |
︙ | ︙ | |||
332 333 334 335 336 337 338 | return; } let xPromise = browser.storage.local.get("lexicon_list"); xPromise.then(this._setList, showError); }, _setList: function (dResult) { | < > > > | | | | > > > > > > > > > > > > | 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | return; } let xPromise = browser.storage.local.get("lexicon_list"); xPromise.then(this._setList, showError); }, _setList: function (dResult) { if (dResult.hasOwnProperty("lexicon_list")) { this.lFlexion = dResult.lexicon_list; } }, display: function () { this.clearTable(); let xTable = document.getElementById("table"); let n = 0; if (this.lFlexion.length > 0) { xTable.appendChild(this._createTableHeader()); for (let [sFlexion, sLemma, sTags] of this.lFlexion) { xTable.appendChild(this._createRowNode(n, sFlexion, sLemma, sTags)); n += 1; } } else { xTable.appendChild(createNode("tr", { textContent: "Aucun élément." })); } }, _createTableHeader: function () { let xRowNode = createNode("tr"); xRowNode.appendChild(createNode("th", { textContent: "#" })); xRowNode.appendChild(createNode("th", { textContent: "Forme fléchie" })); xRowNode.appendChild(createNode("th", { textContent: "Lemme" })); xRowNode.appendChild(createNode("th", { textContent: "Étiquettes" })); return xRowNode; }, _createRowNode: function (n, sFlexion, sLemma, sTags) { let xRowNode = createNode("tr", { id: "row_"+n }); xRowNode.appendChild(createNode("td", { textContent: n })); xRowNode.appendChild(createNode("td", { textContent: sFlexion })); xRowNode.appendChild(createNode("td", { textContent: sLemma })); xRowNode.appendChild(createNode("td", { textContent: sTags })); |
︙ | ︙ | |||
372 373 374 375 376 377 378 | }, build: function () { return null; }, export: function () { | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | }, build: function () { return null; }, export: function () { let xBlob = new Blob(['{ "app": "grammalecte", "data": ' + JSON.stringify(this.lFlexion) + ' }'], {type: 'application/json'}); let sURL = URL.createObjectURL(xBlob); browser.downloads.download({ filename: "grammalecte_dictionnaire_personnel.json", url: sURL, saveAs: true }); } } oLexicon.load(); oLexicon.display(); /* DATA */ const oConj = { // deuxième groupe (le seul groupe régulier) "V2": [ [2, "ir", ":Y/*"], [2, "issant", ":P/*"], [2, "is", ":Ip:Is:1s:2s/*"], [2, "it", ":Ip:Is:3s/*"], [2, "issons", ":Ip:1p/*"], [2, "issez", ":Ip:2p/*"], [2, "issent", ":Ip:Sp:Sq:3p/*"], [2, "issais", ":Iq:1s:2s/*"], [2, "issait", ":Iq:3s/*"], [2, "issions", ":Iq:Sp:Sq:1p/*"], [2, "issiez", ":Iq:Sp:Sq:2p/*"], [2, "issaient", ":Iq:3p/*"], [2, "îmes", ":Is:1p/*"], [2, "îtes", ":Is:2p/*"], [2, "irent", ":Is:3p!/*"], [2, "irai", ":If:1s/*"], [2, "iras", ":If:2s/*"], [2, "ira", ":If:3s/*"], [2, "irons", ":If:1p/*"], [2, "irez", ":If:2p/*"], [2, "iront", ":If:3p!/*"], [2, "irais", ":K:1s:2s/*"], [2, "irait", ":K:3s/*"], [2, "irions", ":K:1p/*"], [2, "iriez", ":K:2p/*"], [2, "iraient", ":K:3p/*"], [2, "isse", ":Sp:Sq:1s/*"], [2, "isses", ":Sp:Sq:2s/*"], [2, "isse", ":Sp:3s/*"], [2, "ît", ":Sq:3s/*"], [2, "is", ":E:2s/*"], [2, "issons", ":E:1p/*"], [2, "issez", ":E:2p/*"], ], // premier groupe "V1": { }, "V1ger": { } }; |