146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
let nPos = sPageText.indexOf("__grammalecte_panel__");
if (nPos >= 0) {
sPageText = sPageText.slice(0, nPos).normalize("NFC");
}
return sPageText;
},
purgeText: function (sText) {
return sText.replace(/ /g, " ").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&");
},
createNode: function (sType, oAttr, oDataset=null) {
try {
let xNode = document.createElement(sType);
Object.assign(xNode, oAttr);
if (oDataset) {
Object.assign(xNode.dataset, oDataset);
}
|
<
<
<
<
|
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
let nPos = sPageText.indexOf("__grammalecte_panel__");
if (nPos >= 0) {
sPageText = sPageText.slice(0, nPos).normalize("NFC");
}
return sPageText;
},
createNode: function (sType, oAttr, oDataset=null) {
try {
let xNode = document.createElement(sType);
Object.assign(xNode, oAttr);
if (oDataset) {
Object.assign(xNode.dataset, oDataset);
}
|
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
|
let {sActionRequest} = oMessage;
let xActiveNode = oGrammalecte.findOriginEditableNode(document.activeElement);
switch (sActionRequest) {
/*
Commands received from the keyboard (shortcuts)
*/
case "shortcutGrammarChecker":
if (xActiveNode && (xActiveNode.tagName == "TEXTAREA" || xActiveNode.tagName == "INPUT" || xActiveNode.isContentEditable)) {
oGrammalecte.startGCPanel(xActiveNode);
} else {
oGrammalecte.startGCPanel(oGrammalecte.getPageText());
}
break;
default:
console.log("[Grammalecte] Content-script. Unknown command: ", sActionRequest);
|
|
|
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
|
let {sActionRequest} = oMessage;
let xActiveNode = oGrammalecte.findOriginEditableNode(document.activeElement);
switch (sActionRequest) {
/*
Commands received from the keyboard (shortcuts)
*/
case "shortcutGrammarChecker":
if (xActiveNode && (xActiveNode.tagName == "TEXTAREA" || xActiveNode.tagName == "INPUT" || xActiveNode.tagName == "IFRAME" || xActiveNode.isContentEditable)) {
oGrammalecte.startGCPanel(xActiveNode);
} else {
oGrammalecte.startGCPanel(oGrammalecte.getPageText());
}
break;
default:
console.log("[Grammalecte] Content-script. Unknown command: ", sActionRequest);
|