Index: gc_lang/fr/webext/background.js ================================================================== --- gc_lang/fr/webext/background.js +++ gc_lang/fr/webext/background.js @@ -98,10 +98,29 @@ browser.contextMenus.create({ id: "lexicographer", title: "Lexicographe", contexts: ["selection", "editable", "page"] }); + +browser.contextMenus.create({ + id: "conjugueur_panel", + title: "Conjugueur [fenêtre]", + contexts: ["all"] +}); +browser.contextMenus.create({ + id: "conjugueur_tab", + title: "Conjugueur [onglet]", + contexts: ["all"] +}); + +function onCreated(windowInfo) { + console.log(`Created window: ${windowInfo.id}`); +} + +function onError(error) { + console.log(`Error: ${error}`); +} browser.contextMenus.onClicked.addListener(function (xInfo, xTab) { // xInfo = https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/contextMenus/OnClickData // xTab = https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/tabs/Tab console.log(xInfo); @@ -115,7 +134,30 @@ case "lexicographer": if (xInfo.selectionText) { xGCEWorker.postMessage(["getListOfTokens", {sText: xInfo.selectionText}]); } break; + case "conjugueur_panel": + var xConjWindow = browser.windows.create({ + url: browser.extension.getURL("panel/conjugueur.html"), + type: "detached_panel", + width: 710, + height: 980 + }); + xConjWindow.then(onCreated, onError); + break; + case "conjugueur_tab": + var xConjTab = browser.tabs.create({ + url: browser.extension.getURL("panel/conjugueur.html"), + pinned: true + }); + xConjTab.then(onCreated, onError); + break; } + + }); + + + + + ADDED gc_lang/fr/webext/img/lines.png Index: gc_lang/fr/webext/img/lines.png ================================================================== --- /dev/null +++ gc_lang/fr/webext/img/lines.png cannot compute difference between binary files ADDED gc_lang/fr/webext/img/logo-80.png Index: gc_lang/fr/webext/img/logo-80.png ================================================================== --- /dev/null +++ gc_lang/fr/webext/img/logo-80.png cannot compute difference between binary files Index: gc_lang/fr/webext/manifest.json ================================================================== --- gc_lang/fr/webext/manifest.json +++ gc_lang/fr/webext/manifest.json @@ -24,11 +24,11 @@ "browser_action": { "default_icon": "img/logo-32.png", "default_popup": "panel/main.html", "default_title": "Grammalecte [fr]", - "browser_style": false + "browser_style": true }, "background": { "scripts": [ "background.js" ] ADDED gc_lang/fr/webext/panel/conjugueur.css Index: gc_lang/fr/webext/panel/conjugueur.css ================================================================== --- /dev/null +++ gc_lang/fr/webext/panel/conjugueur.css @@ -0,0 +1,157 @@ +/* + 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: #FFFFFF url(../img/lines.png); + font: normal 16px Tahoma, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", sans-serif; + color: #505050; + /*text-rendering: optimizeLegibility;*/ +} + +.mainflow { + width: 600px; + margin: 0 auto 0 auto; +} + +.logo { + position: absolute; + background-color: #FFFFFF; + border: 3px solid #F0F0F0; + border-radius: 96px; + padding: 4px 4px 0 4px; +} + + +/* MAIN ====================================================================== */ + +#main .inbox { + width: 600px; + margin: 20px auto 10px auto; + padding: 10px 30px 30px 30px; + background: #FFFFFF; + border: 2px solid #F0F0F0; + border-radius: 20px; +} + +#main h1 { + margin: 5px 0 2px 0; + color: hsl(210, 50%, 50%); + font: bold 30px Tahoma, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", sans-serif; +} +#main h2 { + margin: 5px 0 2px 0; + color: hsl(0, 50%, 50%); + font: bold 16px Tahoma, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", sans-serif; +} +#main h3 { + margin: 5px 0 2px 0; + color: hsl(210, 50%, 50%); + font: bold 14px Tahoma, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", sans-serif; +} + +#main .container { + display: flex; + flex-direction: row; + flex-wrap: nowrap; + justify-content: center; + align-items: flex-start; +} + +#main .colonne { + width: 280px; + padding: 0 10px; +} + +.colonne p { + font-size: 12px; +} + +/*.box { + border-left: 2px solid #8BC5EF; + border-bottom: 2px solid #8BC5EF; + border-radius: 5px; + padding: 0 0 2px 10px; +}*/ + +input#verb { + display: inline-block; + width: 230px; + margin-left: 5px; + 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%, 30%); +} +input[placeholder]#verb { + color: hsl(0, 0%, 70%); +} + +a#conjugate { + display: inline-block; + padding: 7px 10px; + font-size: 20px; + background-color: hsl(0, 30%, 30%); + color: hsl(0, 30%, 60%); + border-radius: 3px; + text-transform: uppercase; + text-align: center; + text-decoration: none; +} +a#conjugate:hover { + background-color: hsl(0, 60%, 40%); + color: hsl(0, 60%, 70%); + box-shadow: 0 0 2px hsl(0, 60%, 50%); +} + +#options { + margin: 10px 0 0 5px; + font-size: 16px; + text-align: center; +} + +#smallnote { + margin: 10px 0 10px 0; + font-size: 11px; + color: hsl(0, 0%, 60%); + text-align: center; +} ADDED gc_lang/fr/webext/panel/conjugueur.html Index: gc_lang/fr/webext/panel/conjugueur.html ================================================================== --- /dev/null +++ gc_lang/fr/webext/panel/conjugueur.html @@ -0,0 +1,175 @@ + + + + + Grammalecte · Conjugueur + + + + +
+
+ +
+
+ +
+
+ +

+ + Conjuguer +

+ +

 

+

 

+ +

+ + · + · + · + · +

+

+ +
+ + +
+
+
+

Infinitif

+

 

+
+
+

Impératif

+

Présent

+

 

+

 

+

 

+
+
+ +
+
+

Participe présent

+

 

+
+
+

Participes passés

+

 

+

 

+

 

+

 

+
+
+
+ +
+ + +
+
+
+

Indicatif

+
+

Présent

+

 

+

 

+

 

+

 

+

 

+

 

+
+
+

Imparfait

+

 

+

 

+

 

+

 

+

 

+

 

+
+
+

Passé simple

+

 

+

 

+

 

+

 

+

 

+

 

+
+
+

Futur

+

 

+

 

+

 

+

 

+

 

+

 

+
+
+
+ +
+
+

Subjonctif

+
+

Présent

+

 

+

 

+

 

+

 

+

 

+

 

+
+
+

Imparfait

+

 

+

 

+

 

+

 

+

 

+

 

+
+
+
+

Conditionnel

+
+

Présent

+

 

+

 

+

 

+

 

+

 

+

 

+
+
+

 

+

 

+

 

+

 

+

 

+

 

+

 

+
+
+
+
+ +
+ +
+ + +
+ + + + + + + ADDED gc_lang/fr/webext/panel/conjugueur.js Index: gc_lang/fr/webext/panel/conjugueur.js ================================================================== --- /dev/null +++ gc_lang/fr/webext/panel/conjugueur.js @@ -0,0 +1,255 @@ +// JavaScript + +let oVerb = null; + +// button +document.getElementById('conjugate').addEventListener("click", function (event) { + createVerbAndConjugate(document.getElementById('verb').value); +}); + +// text field +document.getElementById('verb').addEventListener("change", function (event) { + createVerbAndConjugate(document.getElementById('verb').value); +}); + +// options +document.getElementById('oneg').addEventListener("click", function (event) { + _displayResults(); +}); +document.getElementById('opro').addEventListener("click", function (event) { + _displayResults(); +}); +document.getElementById('oint').addEventListener("click", function (event) { + _displayResults(); +}); +document.getElementById('ofem').addEventListener("click", function (event) { + _displayResults(); +}); +document.getElementById('otco').addEventListener("click", function (event) { + _displayResults(); +}); + +function createVerbAndConjugate (sVerb) { + try { + document.getElementById('oneg').checked = false; + document.getElementById('opro').checked = false; + document.getElementById('oint').checked = false; + document.getElementById('otco').checked = false; + document.getElementById('ofem').checked = false; + + // request analyzing + sVerb = sVerb.trim().toLowerCase().replace(/’/g, "'").replace(/ +/g, " "); + if (sVerb) { + if (sVerb.startsWith("ne pas ")) { + document.getElementById('oneg').checked = true; + sVerb = sVerb.slice(7); + } + if (sVerb.startsWith("se ")) { + document.getElementById('opro').checked = true; + sVerb = sVerb.slice(3); + } else if (sVerb.startsWith("s'")) { + document.getElementById('opro').checked = true; + sVerb = sVerb.slice(2); + } + if (sVerb.endsWith("?")) { + document.getElementById('oint').checked = true; + sVerb = sVerb.slice(0,-1).trim(); + } + + if (!conj.isVerb(sVerb)) { + document.getElementById('verb').style = "color: #BB4411;"; + } else { + document.getElementById('verb_title').textContent = sVerb; + document.getElementById('verb').style = "color: #999999;"; + document.getElementById('verb').value = ""; + oVerb = new Verb(sVerb); + let sRawInfo = oVerb._sRawInfo; + document.getElementById('info').textContent = oVerb.sInfo; + document.getElementById('opro').textContent = "pronominal"; + if (sRawInfo.endsWith("zz")) { + document.getElementById('opro').checked = false; + document.getElementById('opro').disabled = true; + document.getElementById('opro_lbl').style = "color: #CCC;"; + document.getElementById('otco').checked = false; + document.getElementById('otco').disabled = true; + document.getElementById('otco_lbl').style = "color: #CCC;"; + 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('smallnote').textContent = "❦"; + if (sRawInfo[5] == "_") { + document.getElementById('opro').checked = false; + document.getElementById('opro').disabled = true; + document.getElementById('opro_lbl').style = "color: #CCC;"; + } else if (["q", "u", "v", "e"].includes(sRawInfo[5])) { + document.getElementById('opro').checked = false; + document.getElementById('opro').disabled = false; + document.getElementById('opro_lbl').style = "color: #000;"; + } else if (sRawInfo[5] == "p" || sRawInfo[5] == "r") { + document.getElementById('opro').checked = true; + document.getElementById('opro').disabled = true; + document.getElementById('opro_lbl').style = "color: #CCC;"; + } else if (sRawInfo[5] == "x") { + document.getElementById('opro').textContent = "cas particuliers"; + document.getElementById('opro').checked = false; + document.getElementById('opro').disabled = true; + document.getElementById('opro_lbl').style = "color: #CCC;"; + } else { + document.getElementById('opro').textContent = "# erreur #"; + document.getElementById('opro').checked = false; + document.getElementById('opro').disabled = true; + document.getElementById('opro_lbl').style = "color: #CCC;"; + } + document.getElementById('otco').disabled = false; + document.getElementById('otco_lbl').style = "color: #000;"; + } + _displayResults(); + } + } + } + catch (e) { + console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message); + } +} + +function _displayResults () { + if (oVerb === null) { + return; + } + try { + let opro = document.getElementById('opro').checked; + let oneg = document.getElementById('oneg').checked; + let otco = document.getElementById('otco').checked; + let oint = document.getElementById('oint').checked; + let ofem = document.getElementById('ofem').checked; + // titles + _setTitles() + // participes passés + document.getElementById('ppas1').textContent = oVerb.participePasse(":Q1") || " "; // something or nbsp + document.getElementById('ppas2').textContent = oVerb.participePasse(":Q2") || " "; + document.getElementById('ppas3').textContent = oVerb.participePasse(":Q3") || " "; + document.getElementById('ppas4').textContent = oVerb.participePasse(":Q4") || " "; + // infinitif + document.getElementById('infi').textContent = oVerb.infinitif(opro, oneg, otco, oint, ofem); + // participe présent + document.getElementById('ppre').textContent = oVerb.participePresent(opro, oneg, otco, oint, ofem) || " "; + // conjugaisons + document.getElementById('ipre1').textContent = oVerb.conjugue(":Ip", ":1s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('ipre2').textContent = oVerb.conjugue(":Ip", ":2s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('ipre3').textContent = oVerb.conjugue(":Ip", ":3s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('ipre4').textContent = oVerb.conjugue(":Ip", ":1p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('ipre5').textContent = oVerb.conjugue(":Ip", ":2p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('ipre6').textContent = oVerb.conjugue(":Ip", ":3p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('iimp1').textContent = oVerb.conjugue(":Iq", ":1s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('iimp2').textContent = oVerb.conjugue(":Iq", ":2s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('iimp3').textContent = oVerb.conjugue(":Iq", ":3s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('iimp4').textContent = oVerb.conjugue(":Iq", ":1p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('iimp5').textContent = oVerb.conjugue(":Iq", ":2p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('iimp6').textContent = oVerb.conjugue(":Iq", ":3p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('ipsi1').textContent = oVerb.conjugue(":Is", ":1s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('ipsi2').textContent = oVerb.conjugue(":Is", ":2s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('ipsi3').textContent = oVerb.conjugue(":Is", ":3s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('ipsi4').textContent = oVerb.conjugue(":Is", ":1p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('ipsi5').textContent = oVerb.conjugue(":Is", ":2p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('ipsi6').textContent = oVerb.conjugue(":Is", ":3p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('ifut1').textContent = oVerb.conjugue(":If", ":1s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('ifut2').textContent = oVerb.conjugue(":If", ":2s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('ifut3').textContent = oVerb.conjugue(":If", ":3s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('ifut4').textContent = oVerb.conjugue(":If", ":1p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('ifut5').textContent = oVerb.conjugue(":If", ":2p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('ifut6').textContent = oVerb.conjugue(":If", ":3p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('conda1').textContent = oVerb.conjugue(":K", ":1s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('conda2').textContent = oVerb.conjugue(":K", ":2s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('conda3').textContent = oVerb.conjugue(":K", ":3s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('conda4').textContent = oVerb.conjugue(":K", ":1p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('conda5').textContent = oVerb.conjugue(":K", ":2p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('conda6').textContent = oVerb.conjugue(":K", ":3p", opro, oneg, otco, oint, ofem) || " "; + if (!oint) { + document.getElementById('spre1').textContent = oVerb.conjugue(":Sp", ":1s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('spre2').textContent = oVerb.conjugue(":Sp", ":2s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('spre3').textContent = oVerb.conjugue(":Sp", ":3s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('spre4').textContent = oVerb.conjugue(":Sp", ":1p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('spre5').textContent = oVerb.conjugue(":Sp", ":2p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('spre6').textContent = oVerb.conjugue(":Sp", ":3p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('simp1').textContent = oVerb.conjugue(":Sq", ":1s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('simp2').textContent = oVerb.conjugue(":Sq", ":2s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('simp3').textContent = oVerb.conjugue(":Sq", ":3s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('simp4').textContent = oVerb.conjugue(":Sq", ":1p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('simp5').textContent = oVerb.conjugue(":Sq", ":2p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('simp6').textContent = oVerb.conjugue(":Sq", ":3p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('impe1').textContent = oVerb.imperatif(":2s", opro, oneg, otco, ofem) || " "; + document.getElementById('impe2').textContent = oVerb.imperatif(":1p", opro, oneg, otco, ofem) || " "; + document.getElementById('impe3').textContent = oVerb.imperatif(":2p", opro, oneg, otco, ofem) || " "; + } else { + document.getElementById('spre_temps').textContent = " "; + document.getElementById('spre1').textContent = " "; + document.getElementById('spre2').textContent = " "; + document.getElementById('spre3').textContent = " "; + document.getElementById('spre4').textContent = " "; + document.getElementById('spre5').textContent = " "; + document.getElementById('spre6').textContent = " "; + document.getElementById('simp_temps').textContent = " "; + document.getElementById('simp1').textContent = " "; + document.getElementById('simp2').textContent = " "; + document.getElementById('simp3').textContent = " "; + document.getElementById('simp4').textContent = " "; + document.getElementById('simp5').textContent = " "; + document.getElementById('simp6').textContent = " "; + document.getElementById('impe_temps').textContent = " "; + document.getElementById('impe1').textContent = " "; + document.getElementById('impe2').textContent = " "; + document.getElementById('impe3').textContent = " "; + } + if (otco) { + document.getElementById('condb1').textContent = oVerb.conjugue(":Sq", ":1s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('condb2').textContent = oVerb.conjugue(":Sq", ":2s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('condb3').textContent = oVerb.conjugue(":Sq", ":3s", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('condb4').textContent = oVerb.conjugue(":Sq", ":1p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('condb5').textContent = oVerb.conjugue(":Sq", ":2p", opro, oneg, otco, oint, ofem) || " "; + document.getElementById('condb6').textContent = oVerb.conjugue(":Sq", ":3p", opro, oneg, otco, oint, ofem) || " "; + } else { + document.getElementById('condb1').textContent = " "; + document.getElementById('condb2').textContent = " "; + document.getElementById('condb3').textContent = " "; + document.getElementById('condb4').textContent = " "; + document.getElementById('condb5').textContent = " "; + document.getElementById('condb6').textContent = " "; + } + document.getElementById('verb').Text = ""; + } + catch (e) { + console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message); + } +} + +function _setTitles () { + try { + if (!document.getElementById('otco').checked) { + document.getElementById('ipre_temps').textContent = "Présent"; + document.getElementById('ifut_temps').textContent = "Futur"; + document.getElementById('iimp_temps').textContent = "Imparfait"; + document.getElementById('ipsi_temps').textContent = "Passé simple"; + document.getElementById('spre_temps').textContent = "Présent"; + document.getElementById('simp_temps').textContent = "Imparfait"; + document.getElementById('conda_temps').textContent = "Présent"; + document.getElementById('condb_temps').textContent = " "; + document.getElementById('impe_temps').textContent = "Présent"; + } else { + document.getElementById('ipre_temps').textContent = "Passé composé"; + document.getElementById('ifut_temps').textContent = "Futur antérieur"; + document.getElementById('iimp_temps').textContent = "Plus-que-parfait"; + document.getElementById('ipsi_temps').textContent = "Passé antérieur"; + document.getElementById('spre_temps').textContent = "Passé"; + document.getElementById('simp_temps').textContent = "Plus-que-parfait"; + document.getElementById('conda_temps').textContent = "Passé (1ʳᵉ forme)"; + document.getElementById('condb_temps').textContent = "Passé (2ᵉ forme)"; + document.getElementById('impe_temps').textContent = "Passé"; + } + } + catch (e) { + console.error(e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message); + } +} + +createVerbAndConjugate("être"); + +document.getElementById("verb").focus();