345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
|
_createError (sUnderlined, oErr) {
let xNodeErr = document.createElement("mark");
xNodeErr.id = "grammalecte_err" + oErr['sErrorId'];
xNodeErr.textContent = sUnderlined;
xNodeErr.dataset.error_id = oErr['sErrorId'];
xNodeErr.dataset.ignored_key = oErr['sIgnoredKey'];
xNodeErr.dataset.error_type = (oErr['sType'] === "WORD") ? "spelling" : "grammar";
if (xNodeErr.dataset.error_type === "grammar") {
xNodeErr.dataset.gc_message = oErr['sMessage'];
xNodeErr.dataset.gc_url = oErr['URL'];
if (xNodeErr.dataset.gc_message.includes(" #")) {
xNodeErr.dataset.line_id = oErr['sLineId'];
xNodeErr.dataset.rule_id = oErr['sRuleId'];
}
xNodeErr.dataset.suggestions = oErr["aSuggestions"].join("|");
}
xNodeErr.className = (this.aIgnoredErrors.has(xNodeErr.dataset.ignored_key)) ? "grammalecte_error_ignored" : "grammalecte_error";
xNodeErr.style.backgroundColor = (oErr['sType'] === "WORD") ? "hsl(0, 50%, 50%)" : oErr["aColor"];
return xNodeErr;
}
_blockParagraph (xParagraph) {
xParagraph.contentEditable = "false";
this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).textContent = "!!";
this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).style.backgroundColor = "hsl(0, 50%, 50%)";
|
>
>
>
|
>
>
>
>
>
>
>
>
|
<
>
|
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
|
_createError (sUnderlined, oErr) {
let xNodeErr = document.createElement("mark");
xNodeErr.id = "grammalecte_err" + oErr['sErrorId'];
xNodeErr.textContent = sUnderlined;
xNodeErr.dataset.error_id = oErr['sErrorId'];
xNodeErr.dataset.ignored_key = oErr['sIgnoredKey'];
xNodeErr.dataset.error_type = (oErr['sType'] === "WORD") ? "spelling" : "grammar";
if (this.aIgnoredErrors.has(xNodeErr.dataset.ignored_key)) {
xNodeErr.className = "grammalecte_error_ignored";
}
else if (xNodeErr.dataset.error_type === "grammar") {
xNodeErr.className = "grammalecte_error";
xNodeErr.dataset.gc_message = oErr['sMessage'];
xNodeErr.dataset.gc_url = oErr['URL'];
if (xNodeErr.dataset.gc_message.includes(" #")) {
xNodeErr.dataset.line_id = oErr['sLineId'];
xNodeErr.dataset.rule_id = oErr['sRuleId'];
}
xNodeErr.dataset.suggestions = oErr["aSuggestions"].join("|");
let sHue = oErr["aColor"][0].toString();
let sSat = oErr["aColor"][1].toString();
let sLum = oErr["aColor"][2].toString();
xNodeErr.style.color = `hsl(${sHue}, ${sSat}%, 15%)`;
xNodeErr.style.backgroundColor = `hsl(${sHue}, ${sSat}%, 85%)`;
xNodeErr.style.borderBottom = `solid 2px hsl(${sHue}, ${sSat}%, ${sLum}%)`;
}
else {
xNodeErr.className = "grammalecte_spellerror";
}
return xNodeErr;
}
_blockParagraph (xParagraph) {
xParagraph.contentEditable = "false";
this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).textContent = "!!";
this.xParent.getElementById("grammalecte_check"+xParagraph.dataset.para_num).style.backgroundColor = "hsl(0, 50%, 50%)";
|
402
403
404
405
406
407
408
409
410
411
412
413
414
415
|
ignoreError (sIgnoreButtonId) { // ignore
try {
let sErrorId = this.xParent.getElementById(sIgnoreButtonId).dataset.error_id;
let xNodeErr = this.xParent.getElementById("grammalecte_err" + sErrorId);
this.aIgnoredErrors.add(xNodeErr.dataset.ignored_key);
xNodeErr.className = "grammalecte_error_ignored";
this.oTooltip.hide();
}
catch (e) {
showError(e);
}
}
|
>
|
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
|
ignoreError (sIgnoreButtonId) { // ignore
try {
let sErrorId = this.xParent.getElementById(sIgnoreButtonId).dataset.error_id;
let xNodeErr = this.xParent.getElementById("grammalecte_err" + sErrorId);
this.aIgnoredErrors.add(xNodeErr.dataset.ignored_key);
xNodeErr.className = "grammalecte_error_ignored";
xNodeErr.removeAttribute("style");
this.oTooltip.hide();
}
catch (e) {
showError(e);
}
}
|