Index: gc_lang/fr/webext/background.js ================================================================== --- gc_lang/fr/webext/background.js +++ gc_lang/fr/webext/background.js @@ -224,10 +224,11 @@ case "openLexiconEditor": openLexiconEditor(dParam["dictionary"]); break; case "openDictionaries": openDictionaries(); + break; default: console.log("[background] Unknown command: " + sCommand); console.log(oRequest); } //sendResponse({response: "response from background script"}); @@ -287,13 +288,15 @@ browser.contextMenus.create({ id: "separator_editable", type: "separator", contexts: ["editable"] }); // Page browser.contextMenus.create({ id: "rightClickLxgPage", title: "Lexicographe (page)", contexts: ["all"] }); // on all parts, due to unwanted selection browser.contextMenus.create({ id: "rightClickGCPage", title: "Correction grammaticale (page)", contexts: ["all"] }); browser.contextMenus.create({ id: "separator_page", type: "separator", contexts: ["all"] }); -// Conjugueur +// Tools browser.contextMenus.create({ id: "conjugueur_window", title: "Conjugueur [fenêtre]", contexts: ["all"] }); browser.contextMenus.create({ id: "conjugueur_tab", title: "Conjugueur [onglet]", contexts: ["all"] }); +browser.contextMenus.create({ id: "dictionaries", title: "Dictionnaires", contexts: ["all"] }); +browser.contextMenus.create({ id: "lexicon_editor", title: "Éditeur lexical", contexts: ["all"] }); // Rescan page browser.contextMenus.create({ id: "separator_rescan", type: "separator", contexts: ["editable"] }); browser.contextMenus.create({ id: "rescanPage", title: "Rechercher à nouveau les zones de texte", contexts: ["editable"] }); @@ -333,10 +336,16 @@ openConjugueurWindow(); break; case "conjugueur_tab": openConjugueurTab(); break; + case "lexicon_editor": + openLexiconEditor(); + break; + case "dictionaries": + openDictionaries(); + break; // rescan page case "rescanPage": let xPort = dConnx.get(xTab.id); xPort.postMessage({sActionDone: "rescanPage"}); break; @@ -357,13 +366,16 @@ openConjugueurTab(); break; case "conjugueur_window": openConjugueurWindow(); break; - case "lex_editor": + case "lexicon_editor": openLexiconEditor(); break; + case "dictionaries": + openDictionaries(); + break; } }); /* Index: gc_lang/fr/webext/manifest.json ================================================================== --- gc_lang/fr/webext/manifest.json +++ gc_lang/fr/webext/manifest.json @@ -79,26 +79,24 @@ } ], "commands": { "conjugueur_tab": { - "suggested_key": { - "default": "Ctrl+Shift+6" - }, + "suggested_key": { "default": "Ctrl+Shift+6" }, "description": "Ouvre le conjugueur dans un onglet" }, "conjugueur_window": { - "suggested_key": { - "default": "Ctrl+Shift+7" - }, + "suggested_key": { "default": "Ctrl+Shift+7" }, "description": "Ouvre le conjugueur dans une fenêtre" }, - "lex_editor": { - "suggested_key": { - "default": "Ctrl+Shift+8" - }, + "lexicon_editor": { + "suggested_key": { "default": "Ctrl+Shift+8" }, "description": "Ouvre l’éditeur lexical" + }, + "dictionaries": { + "suggested_key": { "default": "Ctrl+Shift+9" }, + "description": "Ouvre le gestionnaire de dictionnaires communautaires" } }, "web_accessible_resources": [ "content_scripts/panel.css", Index: gc_lang/fr/webext/panel/dictionaries.css ================================================================== --- gc_lang/fr/webext/panel/dictionaries.css +++ gc_lang/fr/webext/panel/dictionaries.css @@ -1,3 +1,131 @@ /* - CSS + CSS Document + White + Design par Olivier R. +*/ + +* { margin: 0; padding: 0; } +img { border: none; } + + +/* Generic classes */ + +.fleft { float: left; } +.fright { float: right; } +.center { text-align: center; } +.right { text-align: right; } +.left { text-align: left; } +.justify { text-align: justify; } +.hidden { display: none; } +.clearer { clear: both; font-size: 0; height: 0; } + +body { + background: hsl(0, 0%, 100%) url(../img/lines.png); + font: normal 16px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif; + color: #505050; +} + +.inbox { + width: 800px; + margin: 20px auto 10px auto; + padding: 10px 30px 30px 30px; + background: hsl(0, 0%, 100%); + border: 2px solid hsl(210, 0%, 90%); + border-radius: 20px; +} + +h1 { + margin: 5px 0 5px 0; + color: hsl(210, 50%, 50%); + font: bold 30px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif; + text-align: center; +} +h2 { + margin: 5px 0 2px 0; + color: hsl(0, 50%, 50%); + font: bold 20px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif; +} +h3 { + margin: 3px 0 2px 0; + color: hsl(210, 50%, 50%); + font: bold 16px "Trebuchet MS", "Fira Sans", "Liberation Sans", sans-serif; +} + + +/* + Main buttons +*/ + + +.columns { + display: flex; +} + + +ul { + margin-left: 30px; +} + +input[type=text].large { + display: inline-block; + width: 250px; + padding: 5px 10px; + border: 2px solid hsl(0, 0%, 80%); + border-radius: 3px; + height: 24px; + background: transparent; + font: normal 20px Tahoma, "Ubuntu Condensed"; + color: hsl(0, 0%, 20%); +} + +input[type=text].medium { + display: inline-block; + width: 175px; + padding: 2px 5px; + border: 2px solid hsl(0, 0%, 80%); + border-radius: 3px; + height: 20px; + background: transparent; + font: normal 18px Tahoma, "Ubuntu Condensed"; + color: hsl(0, 0%, 20%); +} + +input[placeholder] { + color: hsl(0, 0%, 50%); +} + + + +/* + Table */ +#wait_progress { + width: 100%; + height: 4px; +} + +table { + border: 1px solid hsl(210, 10%, 50%); + width: 100%; +} +th { + padding: 5px 10px; + border-left: 1px solid hsl(210, 10%, 90%); + text-align: left; +} +td { + padding: 0 10px; + vertical-align: top; +} +.delete_entry { + cursor: pointer; + font-weight: bold; + color: hsl(0, 100%, 50%); +} +.select_entry { + cursor: pointer; + background-color: hsl(120, 50%, 30%); + color: hsl(120, 50%, 100%); + border-radius: 3px; + text-align: center; +} Index: gc_lang/fr/webext/panel/dictionaries.html ================================================================== --- gc_lang/fr/webext/panel/dictionaries.html +++ gc_lang/fr/webext/panel/dictionaries.html @@ -10,36 +10,25 @@

Dictionnaires communautaires

-
-

Votre lexique

-
-
- Enregistrer -
-

Nombre d’entrées : 0.

-
- - - -
-
- +

Dictionnaires sélectionnés

+

[Aucun]

+ +

Dictionnaires disponibles sur le serveur de Grammalecte

+ + +
- - - - Index: gc_lang/fr/webext/panel/dictionaries.js ================================================================== --- gc_lang/fr/webext/panel/dictionaries.js +++ gc_lang/fr/webext/panel/dictionaries.js @@ -1,4 +1,177 @@ // 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; +} + + +/* + Common functions +*/ + +function showError (e) { + console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message); +} + +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); + } +} + + + +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.bDeleteButtons = bDeleteButtons; + this.bActionButtons = bActionButtons; + this._createHeader(); + this.listen(); + } + + _createHeader () { + let xRowNode = createNode("tr"); + if (this.bDeleteButtons) { + xRowNode.appendChild(createNode("th", { textContent: "·", width: "12px" })); + } + for (let sColumn of this.lColumn) { + xRowNode.appendChild(createNode("th", { textContent: sColumn })); + } + this.xTable.appendChild(xRowNode); + } + + clear () { + while (this.xTable.firstChild) { + this.xTable.removeChild(this.xTable.firstChild); + } + this.lEntry = []; + this.nEntry = 0; + this.iEntryIndex = 0; + this._createHeader(); + this.showEntryNumber(); + } + + fill (lFlex) { + this.clear(); + if (lFlex.length > 0) { + this.xProgressBar.max = lFlex.length; + this.xProgressBar.value = 1; + for (let lData of lFlex) { + this._addRow(lData); + this.xProgressBar.value += 1; + } + this.xProgressBar.value = this.xProgressBar.max; + } + this.lEntry = lFlex; + this.nEntry = lFlex.length; + this.showEntryNumber(); + } + + addEntries (lFlex) { + 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; + } + } + + _addRow (lData) { + let xRowNode = createNode("tr", { id: this.sNodeId + "_row_" + this.iEntryIndex }); + if (this.bDeleteButtons) { + xRowNode.appendChild(createNode("td", { textContent: "×", className: "delete_entry", title: "Effacer cette entrée" }, { id_entry: this.iEntryIndex })); + } + for (let data of lData) { + xRowNode.appendChild(createNode("td", { textContent: data })); + } + if (this.bActionButtons) { + xRowNode.appendChild(createNode("td", { textContent: "+", className: "select_entry", title: "Sélectionner/Désélectionner cette entrée" }, { id_entry: this.iEntryIndex })); + } + this.xTable.appendChild(xRowNode); + this.iEntryIndex += 1; + } + + listen () { + if (this.bDeleteButtons || this.bActionButtons) { + this.xTable.addEventListener("click", (xEvent) => { this.onTableClick(xEvent); }, false); + } + } + + onTableClick (xEvent) { + try { + let xElem = xEvent.target; + if (xElem.className) { + switch (xElem.className) { + case "delete_entry": this.deleteRow(xElem.dataset.id_entry); break; + case "select_entry": this.selectEntry(xElem.dataset.id_entry); break; + } + } + } + catch (e) { + showError(e); + } + } + + deleteRow (iEntry) { + this.lEntry[parseInt(iEntry)] = null; + if (document.getElementById(this.sNodeId + "_row_" + iEntry)) { + document.getElementById(this.sNodeId + "_row_" + iEntry).style.display = "none"; + } + this.nEntry -= 1; + this.showEntryNumber(); + if (this.sNodeId == "lexicon_table") { + showElement("save_button", "inline-block"); + } + } + + selectEntry (iEntry) { + let sRowId = this.sNodeId + "_row_" + iEntry; + document.getElementById(sRowId).style.backgroundColor = "hsl(120, 50%, 90%)"; + } + + getEntries () { + return this.lEntry.filter((e) => e !== null); + } +} + + +const oDicTable = new Table("dictionaries_table", ["Nom", "Créé par", "Entrées", "Description"], "wait_progress", "", false, true); + +oDicTable.fill([ + ["Ambre", "Inconnu", "240", "Univers des Princes d’Ambre (de Roger Zelazny)"], + ["Malaz", "Inconnu", "2340", "Univers du Livre des Martyrs (de Steven Erikson)"], + ["Pudlard", "Inconnu", "1440", "Univers d’Harry Potter de XXXX"], + ["Dune", "Inconnu", "2359", "Univers de Dune (de Frank Herbert)"], + ["StarWars", "Inconnu", "4359", "Univers de Star Wars (de George Lucas)"] +]); Index: gc_lang/fr/webext/panel/lex_editor.js ================================================================== --- gc_lang/fr/webext/panel/lex_editor.js +++ gc_lang/fr/webext/panel/lex_editor.js @@ -554,10 +554,11 @@ if (oJSON) { this.parseDict(oJSON); } else { oLexiconTable.clear(); this.setDictData(0, "[néant]"); + hideElement("save_button"); } }, parseDict: function (oJSON) { try { @@ -572,10 +573,11 @@ for (let aRes of this.oIBDAWG.select()) { lEntry.push(aRes); } oLexiconTable.fill(lEntry); this.setDictData(this.oIBDAWG.nEntry, this.oIBDAWG.sDate); + hideElement("save_button"); }, import: function () { let xInput = document.getElementById("import_input"); let xFile = xInput.files[0]; Index: gc_lang/fr/webext/panel/main.html ================================================================== --- gc_lang/fr/webext/panel/main.html +++ gc_lang/fr/webext/panel/main.html @@ -92,10 +92,12 @@

Conjugueur (dans un onglet)

CTRL+MAJ+7

Conjugueur (dans une fenêtre)

CTRL+MAJ+8

Éditeur lexical

+

CTRL+MAJ+9

+

Dictionnaires communautaires

OPTIONS GRAMMATICALES

@@ -114,12 +116,12 @@

Ce dictionnaire est créé et édité via l’éditeur lexical et est sauvegardé sur un serveur en ligne accessible à tous les membres.

-
Dictionnaires en ligne
Éditer
+
Dictionnaires en ligne

Ce dictionnaire est créé et édité via l’éditeur lexical et n’est pas partagé.