Index: gc_lang/fr/webext/content_scripts/html_src.js ================================================================== --- gc_lang/fr/webext/content_scripts/html_src.js +++ gc_lang/fr/webext/content_scripts/html_src.js @@ -11,25 +11,26 @@ */ const sGrammalecteConjugueurHTML = `
- +
entrez un verbe
Conjuguer

 

 
- - · - · -
- · +
Négation
+ ·
Interrogatif
+ ·
Féminin
+
+
Pronominal
+ ·
Temps composés
Index: gc_lang/fr/webext/content_scripts/panel.js ================================================================== --- gc_lang/fr/webext/content_scripts/panel.js +++ gc_lang/fr/webext/content_scripts/panel.js @@ -193,20 +193,20 @@ if (this.xWidthButton && this.xHeightButton) { this.xWidthButton.style.opacity = (this.bHorizStrech) ? ".9" : ""; this.xHeightButton.style.opacity = (this.bVertStrech) ? ".9" : ""; } let nWidth = Math.min(this.nWidth, window.innerWidth-200); - let nHeight = Math.min(this.nHeight, window.innerHeight-100); + let nHeight = Math.min(this.nHeight, window.innerHeight-50); if (this.bFlexible) { // width if (this.bHorizStrech) { nWidth = Math.min(this.nWidth*1.33, window.innerWidth-200); } // height nHeight = ([4, 5, 6].includes(this.nPosition)) ? nHeight : Math.floor(window.innerHeight*0.45); if (this.bVertStrech) { - nHeight = ([4, 5, 6].includes(this.nPosition)) ? (window.innerHeight-100) : Math.floor(window.innerHeight*0.67); + nHeight = ([4, 5, 6].includes(this.nPosition)) ? (window.innerHeight-50) : Math.floor(window.innerHeight*0.67); } } this.xPanel.style.width = `${nWidth}px`; this.xPanel.style.height = `${nHeight}px`; // position Index: gc_lang/fr/webext/content_scripts/panel_conj.css ================================================================== --- gc_lang/fr/webext/content_scripts/panel_conj.css +++ gc_lang/fr/webext/content_scripts/panel_conj.css @@ -58,11 +58,11 @@ padding: 0 10px; font-size: 12px; } -input#grammalecte_conj_verb { +div#grammalecte_conj_verb { display: inline-block; width: 230px; margin-left: 5px; padding: 5px 10px; border: 2px solid hsl(0, 0%, 80%); @@ -70,11 +70,11 @@ height: 20px; background: transparent; font: normal 18px Tahoma, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", sans-serif; color: hsl(0, 0%, 30%); } -input[placeholder]#grammalecte_conj_verb { +div#grammalecte_conj_verb { color: hsl(0, 0%, 70%); } div#grammalecte_conj_button { display: inline-block; @@ -97,12 +97,31 @@ div#grammalecte_conj_options { margin: 10px 0 0 5px; font-size: 16px; text-align: center; } + +div.grammalecte_conj_option_off { + display: inline-block; + margin: 2px; + background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTczbp9jAAADGUlEQVQ4T2P4//8/VTFWQUowggEEQJoRiJlB/BfPn6vMbmrp6AqPOdUeGPa4Iyj8cbN/0Kn5HV0db169UoHqA6kF6UGYg8QBSYAw09SKqtoaTYMvtfLq/5t5xf+1MTD9B+FGIZl/ILEaZe2vs5pba0FqkfRhNZChzNx6RYOU0v96Nb3/tWLyH6aVlC8+vHNX8Yn9B4on5RctrpFQ/FCnZfi/hUvsf7W714q3b9/C9YIwsoEMNaERdQ1aRv9rZFX/13r7bH729KkQVA7uirdv3gjVefpsrjez+d8gLPO/PSOzDqoGjOGMnVu3qtcZWryrU9T+3x0Tv+HFy5cMZ44d99+ydm0oTM38SZNDN61e4w9il+qabGgytftfzy34bsGcOeowNXAD8/kl2hpMrP7X8wm/b6mtFQFpbGZg+NfCwPRn5cJFDlPaOxwaROX+tLAL/ls4fYb/vbt3RWo1Dd7XA4Nn87LlbRgGlptbH28QV/o/rbxy6dt37xgak1PqmwQk/zdYO/yrkZD9WCsm/bHO2PIfMJL+d+fk13/79o0hX151aYOS9v8paZnHMQysNDZ/1Cgq939KTW0ZTGxKfUN+rZTy/zoLuz9Aw/7U6Br/7y0uzQfJ/fz5kyFHWKKsUdvof4uX3yOYHkwDa+vgBq5YsNClAeiiekvbP7UGZn/q9Ez+z504yQUk9wNoYJYIHgPBXgaGx+TCkiUg/qye3sgGAalf9daO/4Cu/FOrqgMy9B9IbNnsOZE/fvwAeXlJnYoOdi+DIqXRyPI/MLw+5GdmCk5raSkFJeZmLpH/faVl+eWhkfl1ihqgxP2/JSOr9O6dO4I12kYfcEYKPNnIa/3vT0rdcOnKFYYlU6bVTCwugStuTkppm1hVXfP6zRuGIgMCyQaE4QlbWvl/Q2Dwxtu3bvFB5eAJG5hc+Bp8AzY2ABN2k4A07oQNxGANkKyn8h8YZqAc8356eeXiQzt2Fp/Yt78YlA1rFTXfA9MfLOutxJf1YK6AFw71Mir/m5AKB2C6/AcSAxUOwJKIYOEAM5RqxRdVMFZB8vF/BgAKMNpeW+niqQAAAABJRU5ErkJggg==') no-repeat; + background-color: none; + padding: 0 3px 0 22px ; + border-radius: 3px; + cursor: pointer; +} +div.grammalecte_conj_option_on { + display: inline-block; + margin: 2px; + background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwQAADsEBuJFr7QAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xNzNun2MAAAMnSURBVDhPY/j//z9VMVZBSjC6ACMQM4PYz1+8UGmaPrsjvL7rVGB1++Oguo7H/pXNpzpmz+949eaNClQ9SC1ID9wMOAOIQRIgzFQxYWqtZk7NF/ms2v+8mc3/GAra/oOwUE7jP5CYcnbN1+aps2pBapH0YTWQwTyrbIVUVsN/rdy6/9KZNe8qJk5fsOvQkeL9x04UF/RMWSAPFAPJcWW1/HcvqF7x9u1buF4QRjaQIbS0pk6rsOG/ItAVLgXVG2/duSMOlYO74v7DR+JuBTVbDPPr/wvnNvzPaGqvg6oBYzhj686d6vq59e/Uc2r/B1U1r3v69ClMjgUNg7zJ4JBbsdK8qPE/d079uznzF6iDxEAYbiB/TH6bGdB1LFnNb3smTZaDioMMgKmBuZJtwtyFZcUNLYb62VWPpHLr/y/buLkNpg6mmME8p/y4PDBssjsmLIKKsQIxcqCDY9+/sGIab07Lf9XUssP66SUbFLPq/qf1TDkBkgNhuIHGOZWPhDIa/zdMnl4O4n/89AmUNPig8mCX+hdWz1AGWmpS0PhfOLF0oWZsVo0GMBw9K1oeQ9UhDDTMrHwkmtX4v6pvYv7xkyflGMqaP/oXV6/89esXWD6gsHKmcnbtf1AY+5Q3r9+0aRODXFhaiVYe2MBHGAYaZZUdNyhu+q+ZkD2ZNb6iTqOg4b9MZv3/6KrG2S6ZBRNVgC7Tyav7b5Zdufr3nz9sv4EWySTmLwaJA718HMNA4ficNsOihv8qOVVvI5PTxFNae6eL5jX+18yt/QM06C/IMAugYe8/fAB7//bde/LAxP9WCmgp1kgBJRvDvLp38sBATmzpXbt582aGhMauuaBYBLnCOLNiPTBcQRHFAAoGrZTidXiTDQiDEzYwTMSAhkbVtW6Yt3ART3Rd63xguoTFPMPd+/clPIvrNoKSGN6EDcTgnADKejJAV4EiwCi35iXQlQuXrN9UcuTM2fyCvimLZDNr3iJlvZX4sh4svTFV9E+pBYbdF4mc+v9AL//jym3+z1Dc+l8st46kwgFmKErxFVbXcdqvpv1JQE0nycUXVTBWQfLxfwYA8YUHpiMfZa8AAAAASUVORK5CYII=') no-repeat; + background-color: hsla(120, 50%, 50%, .2); + padding: 0 3px 0 22px; + border-radius: 3px; + cursor: pointer; +} div#grammalecte_conj_note { margin: 10px 20px; font-size: 11px; color: hsl(0, 0%, 60%); text-align: center; } Index: gc_lang/fr/webext/content_scripts/panel_gc.js ================================================================== --- gc_lang/fr/webext/content_scripts/panel_gc.js +++ gc_lang/fr/webext/content_scripts/panel_gc.js @@ -474,11 +474,11 @@ navigator.clipboard.writeText(sText) .then( (res) => { window.setTimeout(() => { this.xClipboardButton.textContent = "📋"; }, 2000); } ) .catch( - (e) => { console.error(e); this._sendTextToClipboard(sText); } + (e) => { showError(e); this._sendTextToClipboard(sText); } ); } else { this._sendTextToClipboardFallback(sText); } } @@ -497,11 +497,11 @@ document.addEventListener("copy", setClipboardData, true); document.execCommand("copy"); window.setTimeout(() => { this.xClipboardButton.textContent = "📋"; }, 2000); } catch (e) { - console.error(e); + showError(e); } } // Lexicographer @@ -591,102 +591,142 @@ // button this.xParent.getElementById('grammalecte_conj_button').addEventListener("click", (e) => { this.conjugateVerb(); }); // text field this.xParent.getElementById('grammalecte_conj_verb').addEventListener("change", (e) => { this.conjugateVerb(); }); // options - this.xParent.getElementById('grammalecte_conj_oneg').addEventListener("click", (e) => { this.updateConj(); }); - this.xParent.getElementById('grammalecte_conj_opro').addEventListener("click", (e) => { this.updateConj(); }); - this.xParent.getElementById('grammalecte_conj_oint').addEventListener("click", (e) => { this.updateConj(); }); - this.xParent.getElementById('grammalecte_conj_ofem').addEventListener("click", (e) => { this.updateConj(); }); - this.xParent.getElementById('grammalecte_conj_otco').addEventListener("click", (e) => { this.updateConj(); }); + this.xParent.getElementById('grammalecte_conj_oneg').addEventListener("click", (e) => { this.switchOption('grammalecte_conj_oneg'); this.updateConj(); }); + this.xParent.getElementById('grammalecte_conj_opro').addEventListener("click", (e) => { this.switchOption('grammalecte_conj_opro'); this.updateConj(); }); + this.xParent.getElementById('grammalecte_conj_oint').addEventListener("click", (e) => { this.switchOption('grammalecte_conj_oint'); this.updateConj(); }); + this.xParent.getElementById('grammalecte_conj_ofem').addEventListener("click", (e) => { this.switchOption('grammalecte_conj_ofem'); this.updateConj(); }); + this.xParent.getElementById('grammalecte_conj_otco').addEventListener("click", (e) => { this.switchOption('grammalecte_conj_otco'); this.updateConj(); }); this.bListenConj = true; } } + + purgeInputText () { + // Thunderbird don’t accept input fields + // So we use editable node and we purge it + let sVerb = this.xParent.getElementById('grammalecte_conj_verb').innerText; + let nIndexCut = sVerb.indexOf("\n"); + if (nIndexCut != -1) { + sVerb = sVerb.slice(0, nIndexCut); + }; + this.xParent.getElementById('grammalecte_conj_verb').textContent = sVerb.trim(); + } + + switchOption (sOption) { + if (this.xParent.getElementById(sOption).dataset.disabled == "off") { + this.xParent.getElementById(sOption).dataset.selected = (this.xParent.getElementById(sOption).dataset.selected == "off") ? "on" : "off"; + this.xParent.getElementById(sOption).className = (this.xParent.getElementById(sOption).dataset.selected == "on") ? "grammalecte_conj_option_on" : "grammalecte_conj_option_off"; + } + } + + resetOption (sOption) { + this.xParent.getElementById(sOption).dataset.selected = "off"; + this.xParent.getElementById(sOption).dataset.disabled = "off"; + this.xParent.getElementById(sOption).style.color = ""; + this.xParent.getElementById(sOption).className = "grammalecte_conj_option_off"; + } + + selectOption (sOption) { + this.xParent.getElementById(sOption).dataset.selected = "on"; + this.xParent.getElementById(sOption).className = "grammalecte_conj_option_on"; + } + + unselectOption (sOption) { + this.xParent.getElementById(sOption).dataset.selected = "off"; + this.xParent.getElementById(sOption).className = "grammalecte_conj_option_off"; + } + + enableOption (sOption) { + this.xParent.getElementById(sOption).dataset.disabled = "off"; + this.xParent.getElementById(sOption).style.color = ""; + } + + disableOption (sOption) { + this.xParent.getElementById(sOption).dataset.disabled = "on"; + this.xParent.getElementById(sOption).style.color = "#CCC"; + } conjugateVerb (sVerb="") { try { if (!sVerb) { - sVerb = this.xParent.getElementById('grammalecte_conj_verb').value; + this.purgeInputText(); + sVerb = this.xParent.getElementById('grammalecte_conj_verb').textContent; } - this.xParent.getElementById('grammalecte_conj_oneg').checked = false; - this.xParent.getElementById('grammalecte_conj_opro').checked = false; - this.xParent.getElementById('grammalecte_conj_oint').checked = false; - this.xParent.getElementById('grammalecte_conj_otco').checked = false; - this.xParent.getElementById('grammalecte_conj_ofem').checked = false; + this.resetOption('grammalecte_conj_oneg'); + this.resetOption('grammalecte_conj_opro'); + this.resetOption('grammalecte_conj_oint'); + this.resetOption('grammalecte_conj_otco'); + this.resetOption('grammalecte_conj_ofem'); // request analyzing sVerb = sVerb.trim().toLowerCase().replace(/’/g, "'").replace(/ +/g, " "); if (sVerb) { if (sVerb.startsWith("ne pas ")) { - this.xParent.getElementById('grammalecte_conj_oneg').checked = true; - sVerb = sVerb.slice(7); + this.selectOption('grammalecte_conj_oneg'); + sVerb = sVerb.slice(7).trim(); } if (sVerb.startsWith("se ")) { - this.xParent.getElementById('grammalecte_conj_opro').checked = true; - sVerb = sVerb.slice(3); - } else if (sVerb.startsWith("s'")) { - this.xParent.getElementById('grammalecte_conj_opro').checked = true; - sVerb = sVerb.slice(2); + this.selectOption('grammalecte_conj_opro'); + sVerb = sVerb.slice(3).trim(); + } + else if (sVerb.startsWith("s'")) { + this.selectOption('grammalecte_conj_opro'); + sVerb = sVerb.slice(2).trim(); } if (sVerb.endsWith("?")) { - this.xParent.getElementById('grammalecte_conj_oint').checked = true; + this.selectOption('grammalecte_conj_oint'); sVerb = sVerb.slice(0,-1).trim(); } if (sVerb) { this.sVerb = sVerb; this.updateConj(true); } else { - this.xParent.getElementById('grammalecte_conj_verb').value = ""; + this.xParent.getElementById('grammalecte_conj_verb').textContent = ""; } } } catch (e) { - console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message); + showError(e); } } updateConj (bStart=false) { - let bPro = this.xParent.getElementById('grammalecte_conj_opro').checked; - let bNeg = this.xParent.getElementById('grammalecte_conj_oneg').checked; - let bTpsCo = this.xParent.getElementById('grammalecte_conj_otco').checked; - let bInt = this.xParent.getElementById('grammalecte_conj_oint').checked; - let bFem = this.xParent.getElementById('grammalecte_conj_ofem').checked; + let bPro = this.xParent.getElementById('grammalecte_conj_opro').dataset.selected == "on"; + let bNeg = this.xParent.getElementById('grammalecte_conj_oneg').dataset.selected == "on"; + let bTpsCo = this.xParent.getElementById('grammalecte_conj_otco').dataset.selected == "on"; + let bInt = this.xParent.getElementById('grammalecte_conj_oint').dataset.selected == "on"; + let bFem = this.xParent.getElementById('grammalecte_conj_ofem').dataset.selected == "on"; if (this.sVerb) { oGrammalecteBackgroundPort.getVerb(this.sVerb, bStart, bPro, bNeg, bTpsCo, bInt, bFem); } } conjugateWith (oVerb, oConjTable) { // function called when results come from the Worker if (oVerb) { this.xParent.getElementById('grammalecte_conj_verb').style.color = "#999999"; - this.xParent.getElementById('grammalecte_conj_verb').value = ""; + this.xParent.getElementById('grammalecte_conj_verb').textContent = ""; this.xParent.getElementById('grammalecte_conj_verb_title').textContent = oVerb.sVerb; this.xParent.getElementById('grammalecte_conj_verb_info').textContent = oVerb.sInfo; - this.xParent.getElementById('grammalecte_conj_opro_lbl').textContent = oVerb.sProLabel; + this.xParent.getElementById('grammalecte_conj_opro').textContent = oVerb.sProLabel; if (oVerb.bUncomplete) { - this.xParent.getElementById('grammalecte_conj_opro').checked = false; - this.xParent.getElementById('grammalecte_conj_opro').disabled = true; - this.xParent.getElementById('grammalecte_conj_opro_lbl').style.color = "#CCC"; - this.xParent.getElementById('grammalecte_conj_otco').checked = false; - this.xParent.getElementById('grammalecte_conj_otco').disabled = true; - this.xParent.getElementById('grammalecte_conj_otco_lbl').style.color = "#CCC"; + this.unselectOption('grammalecte_conj_opro'); + this.disableOption('grammalecte_conj_opro'); + this.unselectOption('grammalecte_conj_otco'); + this.disableOption('grammalecte_conj_otco'); this.xParent.getElementById('grammalecte_conj_note').textContent = "Ce verbe n’a pas encore été vérifié. C’est pourquoi les options “pronominal” et “temps composés” sont désactivées."; } else { - this.xParent.getElementById('grammalecte_conj_otco').disabled = false; - this.xParent.getElementById('grammalecte_conj_otco_lbl').style.color = "#000"; + this.enableOption('grammalecte_conj_otco'); if (oVerb.nPronominable == 0) { - this.xParent.getElementById('grammalecte_conj_opro').checked = false; - this.xParent.getElementById('grammalecte_conj_opro').disabled = false; - this.xParent.getElementById('grammalecte_conj_opro_lbl').style.color = "#000"; + this.enableOption('grammalecte_conj_opro'); } else if (oVerb.nPronominable == 1) { - this.xParent.getElementById('grammalecte_conj_opro').checked = true; - this.xParent.getElementById('grammalecte_conj_opro').disabled = true; - this.xParent.getElementById('grammalecte_conj_opro_lbl').style.color = "#CCC"; - } else { // -1 or 1 or error - this.xParent.getElementById('grammalecte_conj_opro').checked = false; - this.xParent.getElementById('grammalecte_conj_opro').disabled = true; - this.xParent.getElementById('grammalecte_conj_opro_lbl').style.color = "#CCC"; + this.selectOption('grammalecte_conj_opro'); + this.disableOption('grammalecte_conj_opro'); + } else { // -1 or error + this.unselectOption('grammalecte_conj_opro'); + this.disableOption('grammalecte_conj_opro'); } this.xParent.getElementById('grammalecte_conj_note').textContent = "❦"; } this.displayConj(oConjTable); } else { @@ -698,11 +738,11 @@ // function called when results come from the Worker if (oConjTable === null) { return; } try { - this.xParent.getElementById('grammalecte_conj_verb').Text = ""; + this.xParent.getElementById('grammalecte_conj_verb').textContent = ""; // infinitif this.xParent.getElementById('grammalecte_conj_infi').textContent = oConjTable["infi"] || " "; // something or nbsp // participe présent this.xParent.getElementById('grammalecte_conj_ppre').textContent = oConjTable["ppre"] || " "; // participes passés @@ -778,11 +818,11 @@ this.xParent.getElementById('grammalecte_conj_simp4').textContent = oConjTable["simp4"] || " "; this.xParent.getElementById('grammalecte_conj_simp5').textContent = oConjTable["simp5"] || " "; this.xParent.getElementById('grammalecte_conj_simp6').textContent = oConjTable["simp6"] || " "; } catch (e) { - console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message); + showError(e); } } } Index: gc_lang/fr/webext/panel/conjugueur.html ================================================================== --- gc_lang/fr/webext/panel/conjugueur.html +++ gc_lang/fr/webext/panel/conjugueur.html @@ -3,11 +3,11 @@ Grammalecte · Conjugueur - +
- +

Subjonctif

Présent

@@ -169,7 +169,7 @@ - + Index: gc_lang/fr/webext/panel/conjugueur.js ================================================================== --- gc_lang/fr/webext/panel/conjugueur.js +++ gc_lang/fr/webext/panel/conjugueur.js @@ -75,11 +75,10 @@ document.getElementById('smallnote').textContent = "Ce verbe n’a pas encore été vérifié. C’est pourquoi les options “pronominal” et “temps composés” sont désactivées."; } else { document.getElementById('otco').disabled = false; document.getElementById('otco_lbl').style = "color: #000;"; if (oVerb.nPronominable == 0) { - document.getElementById('opro').checked = false; document.getElementById('opro').disabled = false; document.getElementById('opro_lbl').style = "color: #000;"; } else if (oVerb.nPronominable == 1) { document.getElementById('opro').checked = true; document.getElementById('opro').disabled = true;