Index: gc_lang/fr/webext/content_scripts/panel.css ================================================================== --- gc_lang/fr/webext/content_scripts/panel.css +++ gc_lang/fr/webext/content_scripts/panel.css @@ -146,11 +146,11 @@ div.grammalecte_menu_button:hover { background-color: hsl(210, 80%, 40%); } div.grammalecte_autorefresh_button { display: inline-block; - padding: 1px 5px; + padding: 0 5px; margin-left: 5px; border-radius: 3px; background-color: hsl(0, 50%, 50%); color: hsl(0, 50%, 96%); opacity: .7; 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 @@ -13,17 +13,17 @@ if (xElem.id.startsWith("grammalecte_sugg")) { oGrammalecte.oGCPanel.applySuggestion(xElem.id); } else if (xElem.id === "grammalecte_tooltip_ignore") { oGrammalecte.oGCPanel.ignoreError(xElem.id); } else if (xElem.id.startsWith("grammalecte_check")) { - oGrammalecte.oGCPanel.recheckParagraph(parseInt(xElem.dataset.para_num)); + oGrammalecte.oGCPanel.recheckParagraph(parseInt(xElem.dataset.para_num, 10)); } else if (xElem.id.startsWith("grammalecte_hide")) { xElem.parentNode.parentNode.style.display = "none"; } else if (xElem.id.startsWith("grammalecte_err") && xElem.className !== "grammalecte_error_corrected" && xElem.className !== "grammalecte_error_ignored") { - oGrammalecte.oGCPanel.oTooltip.show(xElem.id); + oGrammalecte.oGCPanel.oTooltip.show(xElem.parentNode, xElem.id); } else if (xElem.id === "grammalecte_tooltip_url" || xElem.id === "grammalecte_tooltip_db_search") { oGrammalecte.oGCPanel.openURL(xElem.dataset.url); } else { oGrammalecte.oGCPanel.oTooltip.hide(); } @@ -79,11 +79,11 @@ this.xTFButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Formateur de texte"}); this.xEditorButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Éditeur"}); this.xLxgButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Lexicographe"}); this.xConjButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "Conjugueur"}); this.xLEButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_button", textContent: "•Éditeur lexical•"}); - this.xAutoRefresh = oGrammalecte.createNode("div", {className: "grammalecte_autorefresh_button", textContent: "AR", title: "Auto-rafraîchissement de la correction grammaticale"}) + this.xAutoRefresh = oGrammalecte.createNode("div", {className: "grammalecte_autorefresh_button", textContent: "AR", title: "Auto-rafraîchissement de la correction grammaticale (3 s après la dernière frappe)"}) this.xEditorButton.appendChild(this.xAutoRefresh); this.xTFButton.onclick = () => { if (!this.bWorking) { oGrammalecte.createTFPanel(); oGrammalecte.oTFPanel.start(); @@ -94,16 +94,14 @@ if (!this.bWorking) { this.showEditor(); } }; this.xAutoRefresh.onclick = () => { - console.log("autor"); this.bAutoRefresh = !this.bAutoRefresh; this.xAutoRefresh.style.backgroundColor = (this.bAutoRefresh) ? "hsl(150, 50%, 50%)" : ""; this.xAutoRefresh.style.color = (this.bAutoRefresh) ? "hsl(150, 50%, 96%)" : ""; this.xAutoRefresh.style.opacity = (this.bAutoRefresh) ? "1" : ""; - console.log("on"); } this.xLxgButton.onclick = () => { if (!this.bWorking) { this.showLexicographer(); this.clearLexicographer(); @@ -228,19 +226,19 @@ xParagraph.setAttribute("spellcheck", "false"); // doesn’t seem possible to use “spellcheck” as a common attribute. xParagraph.dataset.timer_id = "0"; xParagraph.addEventListener("input", function (xEvent) { if (this.bAutoRefresh) { // timer for refreshing analysis - window.clearTimeout(parseInt(xParagraph.dataset.timer_id)); + window.clearTimeout(parseInt(xParagraph.dataset.timer_id, 10)); xParagraph.dataset.timer_id = window.setTimeout(this.recheckParagraph.bind(this), 3000, oResult.iParaNum); // save caret position let [nStart, nEnd] = oGrammalecte.getCaretPosition(xParagraph); xParagraph.dataset.caret_position_start = nStart; xParagraph.dataset.caret_position_end = nEnd; } // write text - this.oTextControl.setParagraph(parseInt(xEvent.target.dataset.para_num), this.purgeText(xEvent.target.textContent)); + this.oTextControl.setParagraph(parseInt(xEvent.target.dataset.para_num, 10), this.purgeText(xEvent.target.textContent)); this.oTextControl.write(); }.bind(this) , true); /*xParagraph.addEventListener("blur", function (xEvent) { // remove timer for refreshing analysis @@ -277,10 +275,11 @@ this.oTextControl.setParagraph(iParaNum, sText); this.oTextControl.write(); } refreshParagraph (sParagraphId, oResult) { + // function called when results are sent by the Worker try { let xParagraph = this.xParent.getElementById(sParagraphId); xParagraph.className = (oResult.aGrammErr.length || oResult.aSpellErr.length) ? "grammalecte_paragraph softred" : "grammalecte_paragraph"; xParagraph.textContent = ""; this._tagParagraph(xParagraph, oResult.sParagraph, sParagraphId.slice(21), oResult.aGrammErr, oResult.aSpellErr); @@ -360,12 +359,12 @@ } freeParagraph (xParagraph) { xParagraph.contentEditable = "true"; if (xParagraph.dataset.caret_position_start !== "-1") { - let nStart = parseInt(xParagraph.dataset.caret_position_start); - let nEnd = parseInt(xParagraph.dataset.caret_position_end); + let nStart = parseInt(xParagraph.dataset.caret_position_start, 10); + let nEnd = parseInt(xParagraph.dataset.caret_position_end, 10); oGrammalecte.setCaretPosition(xParagraph, nStart, nEnd); } this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).textContent = "↻"; this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).style.backgroundColor = ""; this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).style.animation = ""; @@ -379,11 +378,11 @@ let xNodeErr = this.xParent.getElementById("grammalecte_err" + sErrorId); xNodeErr.textContent = this.xParent.getElementById(sNodeSuggId).textContent; xNodeErr.className = "grammalecte_error_corrected"; xNodeErr.removeAttribute("style"); this.oTooltip.hide(); - this.recheckParagraph(parseInt(sErrorId.slice(0, sErrorId.indexOf("-")))); + this.recheckParagraph(parseInt(sErrorId.slice(0, sErrorId.indexOf("-")), 10)); } catch (e) { showError(e); } } @@ -784,12 +783,15 @@ // add tooltip to the page xGCPanelContent.appendChild(this.xTooltip); xGCPanelContent.appendChild(this.xTooltipArrow); } - show (sNodeErrorId) { // err + show (xParagraph, sNodeErrorId) { // err try { + // we kill autorefresh for safety + window.clearTimeout(parseInt(xParagraph.dataset.timer_id, 10)); + // let xNodeErr = this.xParent.getElementById(sNodeErrorId); this.sErrorId = xNodeErr.dataset.error_id; // we store error_id here to know if spell_suggestions are given to the right word. let nTooltipLeftLimit = oGrammalecte.oGCPanel.getWidth() - 330; // paragraph width - tooltip width let nArrowLimit = oGrammalecte.oGCPanel.getWidth() - 20; this.xTooltipArrow.style.top = (xNodeErr.offsetTop + 16) + "px";