199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
freeParagraph (xParagraph) {
xParagraph.contentEditable = "true";
document.getElementById("grammalecte_check"+xParagraph.dataset.para_num).textContent = "Réanalyser";
}
applySuggestion (sNodeSuggId) { // sugg
try {
console.log(sNodeSuggId);
let sErrorId = document.getElementById(sNodeSuggId).dataset.error_id;
//let sParaNum = sErrorId.slice(0, sErrorId.indexOf("-"));
console.log("grammalecte_err"+sErrorId);
let xNodeErr = document.getElementById("grammalecte_err" + sErrorId);
xNodeErr.textContent = document.getElementById(sNodeSuggId).textContent;
xNodeErr.className = "corrected";
xNodeErr.removeAttribute("style");
this.oTooltip.hide();
this.recheckParagraph(parseInt(sErrorId.slice(0, sErrorId.indexOf("-"))));
}
catch (e) {
showError(e);
}
}
ignoreError (sIgnoreButtonId) { // ignore
try {
console.log(sIgnoreButtonId);
let sErrorId = document.getElementById(sIgnoreButtonId).dataset.error_id;
console.log("grammalecte_err"+sErrorId);
let xNodeErr = document.getElementById("grammalecte_err" + sErrorId);
this.aIgnoredErrors.add(xNodeErr.dataset.ignored_key);
xNodeErr.className = "ignored";
this.oTooltip.hide();
}
catch (e) {
showError(e);
|
<
<
<
<
|
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
freeParagraph (xParagraph) {
xParagraph.contentEditable = "true";
document.getElementById("grammalecte_check"+xParagraph.dataset.para_num).textContent = "Réanalyser";
}
applySuggestion (sNodeSuggId) { // sugg
try {
let sErrorId = document.getElementById(sNodeSuggId).dataset.error_id;
//let sParaNum = sErrorId.slice(0, sErrorId.indexOf("-"));
let xNodeErr = document.getElementById("grammalecte_err" + sErrorId);
xNodeErr.textContent = document.getElementById(sNodeSuggId).textContent;
xNodeErr.className = "corrected";
xNodeErr.removeAttribute("style");
this.oTooltip.hide();
this.recheckParagraph(parseInt(sErrorId.slice(0, sErrorId.indexOf("-"))));
}
catch (e) {
showError(e);
}
}
ignoreError (sIgnoreButtonId) { // ignore
try {
let sErrorId = document.getElementById(sIgnoreButtonId).dataset.error_id;
let xNodeErr = document.getElementById("grammalecte_err" + sErrorId);
this.aIgnoredErrors.add(xNodeErr.dataset.ignored_key);
xNodeErr.className = "ignored";
this.oTooltip.hide();
}
catch (e) {
showError(e);
|
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
|
}
addMessage (sMessage) {
let xNode = createNode("div", {className: "grammalecte_gc_panel_message", textContent: sMessage});
this.xParagraphList.appendChild(xNode);
}
copyToClipboard () {
this.startWaitIcon();
try {
let xClipboardButton = document.getElementById("grammalecte_clipboard_button");
xClipboardButton.textContent = "copie en cours…";
let sText = "";
for (let xNode of document.getElementById("grammalecte_paragraph_list").getElementsByClassName("grammalecte_paragraph")) {
sText += xNode.textContent + "\n";
}
self.port.emit('copyToClipboard', sText);
xClipboardButton.textContent = "-> presse-papiers";
window.setTimeout(function() { xClipboardButton.textContent = "∑"; } , 3000);
}
catch (e) {
console.log(e.lineNumber + ": " +e.message);
}
this.stopWaitIcon();
}
}
class GrammalecteTooltip {
constructor (xContentNode) {
this.xTooltip = createNode("div", {id: "grammalecte_tooltip"});
this.xTooltipArrow = createNode("img", {
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
<
|
>
|
|
|
>
|
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
|
}
addMessage (sMessage) {
let xNode = createNode("div", {className: "grammalecte_gc_panel_message", textContent: sMessage});
this.xParagraphList.appendChild(xNode);
}
_copyToClipboard (sText) {
// recipie from https://github.com/mdn/webextensions-examples/blob/master/context-menu-copy-link-with-types/clipboard-helper.js
function setClipboardData (xEvent) {
document.removeEventListener("copy", setClipboardData, true);
xEvent.stopImmediatePropagation();
xEvent.preventDefault();
xEvent.clipboardData.setData("text/plain", sText);
};
document.addEventListener("copy", setClipboardData, true);
document.execCommand("copy");
};
copyTextToClipboard () {
this.startWaitIcon();
try {
let xClipboardButton = document.getElementById("grammalecte_clipboard_button");
xClipboardButton.textContent = "->>";
let sText = "";
for (let xNode of document.getElementsByClassName("grammalecte_paragraph")) {
sText += xNode.textContent + "\n";
}
xClipboardButton.textContent = "OK";
this._copyToClipboard(sText);
window.setTimeout(function() { xClipboardButton.textContent = "∑"; } , 2000);
}
catch (e) {
showError(e);
}
this.stopWaitIcon();
}
}
class GrammalecteTooltip {
constructor (xContentNode) {
this.xTooltip = createNode("div", {id: "grammalecte_tooltip"});
this.xTooltipArrow = createNode("img", {
|