slight refactors
This commit is contained in:
parent
67877f74fd
commit
bbb27ee274
8
main.js
8
main.js
|
@ -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 || " ";
|
linediv.innerHTML = applycolorsonline(lines[i], i, options) || " ";
|
||||||
};
|
};
|
||||||
|
|
||||||
// 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();
|
||||||
|
|
Loading…
Reference in New Issue