slight refactors

This commit is contained in:
quenousimporte 2023-10-12 14:39:43 +02:00
parent 67877f74fd
commit bbb27ee274
1 changed files with 2 additions and 6 deletions

View File

@ -2137,11 +2137,8 @@ function applycolors(currentonly)
console.log("redrawing all colored div"); console.log("redrawing all colored div");
var lines = md.value.split("\n"); var lines = md.value.split("\n");
var i = 0; var i = 0;
var line = null;
for (; i < lines.length; i++) for (; i < lines.length; i++)
{ {
line = applycolorsonline(lines[i], i, options);
var linediv = document.getElementById("line" + i); var linediv = document.getElementById("line" + i);
if (!linediv) if (!linediv)
{ {
@ -2150,7 +2147,7 @@ function applycolors(currentonly)
} }
linediv.setAttribute("id", "line" + i); linediv.setAttribute("id", "line" + i);
linediv.setAttribute("tag", JSON.stringify(options)); linediv.setAttribute("tag", JSON.stringify(options));
linediv.innerHTML = line || "&nbsp;"; linediv.innerHTML = applycolorsonline(lines[i], i, options) || "&nbsp;";
}; };
// remove remanining // remove remanining
@ -2165,8 +2162,7 @@ function applycolors(currentonly)
function editorinput() function editorinput()
{ {
// criteria to improve // criteria to improve. Or redraw only after?
// or redraw only after?
var multiline = md.value.substring(md.selectionStart, md.selectionEnd).includes("\n"); var multiline = md.value.substring(md.selectionStart, md.selectionEnd).includes("\n");
applycolors(!multiline && event.data && (event.inputType == "insertText" || event.inputType == "deleteContentBackward" || event.inputType == "deleteContentForward")); applycolors(!multiline && event.data && (event.inputType == "insertText" || event.inputType == "deleteContentBackward" || event.inputType == "deleteContentForward"));
datachanged(); datachanged();