Overview
| Comment: | [fx] code clarification |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk | fx |
| Files: | files | file ages | folders |
| SHA3-256: |
6e5eaa6e688d78144975b56651431088 |
| User & Date: | olr on 2019-05-09 10:12:13 |
| Other Links: | manifest | tags |
Context
|
2019-05-10
| ||
| 08:51 | [fr] faux positif check-in: 105cb51271 user: olr tags: trunk, fr | |
|
2019-05-09
| ||
| 10:12 | [fx] code clarification check-in: 6e5eaa6e68 user: olr tags: trunk, fx | |
| 07:38 | [fr] ajustements check-in: fda207bea2 user: olr tags: trunk, fr | |
Changes
Modified gc_lang/fr/webext/content_scripts/init.js from [fe7209c432] to [f089b29107].
| ︙ | ︙ | |||
169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
},
showMessage: function (sMessage) {
this.createMessageBox();
this.oMessageBox.show();
this.oMessageBox.setMessage(sMessage);
},
getPageText: function () {
let sPageText = document.body.innerText;
let nPos = sPageText.indexOf("__grammalecte_panel__");
if (nPos >= 0) {
sPageText = sPageText.slice(0, nPos).normalize("NFC");
}
| > > > > > > > > > > > > > > > | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
},
showMessage: function (sMessage) {
this.createMessageBox();
this.oMessageBox.show();
this.oMessageBox.setMessage(sMessage);
},
parseAndSpellcheck (xNode=null) {
this.startGCPanel(xNode);
let sText = "";
if (xNode) {
sText = (xNode.tagName == "TEXTAREA" || xNode.tagName == "INPUT") ? xNode.value.normalize("NFC") : xNode.innerText.normalize("NFC");
} else {
sText = this.getPageText();
}
xGrammalectePort.postMessage({
sCommand: "parseAndSpellcheck",
dParam: {sText: sText, sCountry: "FR", bDebug: false, bContext: false},
dInfo: (xNode) ? {sTextAreaId: xNode.id} : {}
});
},
getPageText: function () {
let sPageText = document.body.innerText;
let nPos = sPageText.indexOf("__grammalecte_panel__");
if (nPos >= 0) {
sPageText = sPageText.slice(0, nPos).normalize("NFC");
}
|
| ︙ | ︙ | |||
321 322 323 324 325 326 327 |
/*
Commands received from the context menu
(Context menu are initialized in background)
*/
// Grammar checker commands
case "grammar_checker_editable":
if (oGrammalecte.xRightClickedNode !== null) {
| | | | 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
/*
Commands received from the context menu
(Context menu are initialized in background)
*/
// Grammar checker commands
case "grammar_checker_editable":
if (oGrammalecte.xRightClickedNode !== null) {
oGrammalecte.parseAndSpellcheck(oGrammalecte.xRightClickedNode);
} else {
oGrammalecte.showMessage("Erreur. Le node sur lequel vous avez cliqué n’a pas pu être identifié. Sélectionnez le texte à corriger et relancez le correcteur via le menu contextuel.");
}
break;
case "grammar_checker_page":
oGrammalecte.parseAndSpellcheck();
break;
case "grammar_checker_selection":
oGrammalecte.startGCPanel();
// selected text is sent to the GC worker in the background script.
break;
// rescan page command
case "rescanPage":
|
| ︙ | ︙ | |||
353 354 355 356 357 358 359 |
let xActiveNode = document.activeElement;
switch (sActionRequest) {
/*
Commands received from the keyboard (shortcuts)
*/
case "shortcutGrammarChecker":
if (xActiveNode && (xActiveNode.tagName == "TEXTAREA" || xActiveNode.tagName == "INPUT" || xActiveNode.isContentEditable)) {
| | | < < < < < < < < < < < < < < < < < < < < < < < < | 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
let xActiveNode = document.activeElement;
switch (sActionRequest) {
/*
Commands received from the keyboard (shortcuts)
*/
case "shortcutGrammarChecker":
if (xActiveNode && (xActiveNode.tagName == "TEXTAREA" || xActiveNode.tagName == "INPUT" || xActiveNode.isContentEditable)) {
oGrammalecte.parseAndSpellcheck(xActiveNode);
} else {
oGrammalecte.parseAndSpellcheck();
}
break;
default:
console.log("[Content script] Unknown command: " + sActionDone);
}
});
|
Modified gc_lang/fr/webext/content_scripts/menu.js from [12c726f5e2] to [7dabc515cf].
1 2 3 4 | // JavaScript /* jshint esversion:6, -W097 */ /* jslint esversion:6 */ | | < < | < < < < < < < < < < < | < | | > > | > > > > > > | | < < < < | 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 67 |
// JavaScript
/* jshint esversion:6, -W097 */
/* jslint esversion:6 */
/* global oGrammalecte, showError, window, document */
"use strict";
class GrammalecteButton {
constructor (nMenu, xNode) {
this.xNode = xNode;
this.xButton = oGrammalecte.createNode("div", {className: "grammalecte_menu_main_button", textContent: " "});
this.xButton.onclick = () => {
oGrammalecte.parseAndSpellcheck(this.xNode);
};
this.xButton.style.zIndex = (xNode.style.zIndex.search(/^[0-9]+$/) !== -1) ? (parseInt(xNode.style.zIndex) + 1).toString() : xNode.style.zIndex;
this.bShadow = document.body.createShadowRoot || document.body.attachShadow;
if (this.bShadow) {
this.xShadowBtn = oGrammalecte.createNode("div", {style: "display:none;position:absolute;width:0;height:0;"});
this.xShadowBtnNode = this.xShadowBtn.attachShadow({mode: "open"});
oGrammalecte.createStyle("content_scripts/menu.css", null, this.xShadowBtnNode);
this.xShadowBtnNode.appendChild(this.xButton);
this._insert(this.xShadowBtn);
} else {
if (!document.getElementById("grammalecte_cssmenu")) {
oGrammalecte.createStyle("content_scripts/menu.css", "grammalecte_cssmenu", document.head);
}
this._insert(this.xButton);
}
this._listen();
}
_insert (xNewNode) {
// insertion
let xReferenceNode = this.xNode;
if (document.location.host == "twitter.com" && this.xNode.classList.contains('rich-editor')) {
xReferenceNode = this.xNode.parentNode;
}
xReferenceNode.parentNode.insertBefore(xNewNode, xReferenceNode.nextSibling);
// offset
let nNodeMarginBottom = parseInt(window.getComputedStyle(this.xNode).marginBottom.replace('px', ''), 10);
let nMarginTop = (this.bShadow) ? -1 * nNodeMarginBottom : -1 * (8 + nNodeMarginBottom);
xNewNode.style.marginTop = nMarginTop + "px";
}
_listen () {
this.xNode.addEventListener('focus', (e) => {
if (this.bShadow) {
this.xShadowBtn.style.display = "block";
}
this.xButton.style.display = "block";
});
/*this.xNode.addEventListener('blur', (e) => {
window.setTimeout(() => { this.xButton.style.display = "none"; }, 300);
});*/
}
deleteNodes () {
if (this.bShadow) {
this.xShadowBtn.parentNode.removeChild(this.xShadowBtn);
} else {
this.xButton.parentNode.removeChild(this.xButton);
}
}
|
| ︙ | ︙ |