Skip to content

Commit cd29add

Browse files
committed
Rework javascript to support correct preview for letter colorization selector
1 parent 27a6e0e commit cd29add

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lto.js.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
echo "\n";
2525
}
2626

27-
echo '
27+
?>
2828

2929
function getColor() {
3030
return document.getElementsByName("colorscheme")[0].value;
@@ -55,12 +55,14 @@ function updateTextlabel() {
5555
}
5656

5757
function updateColors() {
58-
l1.style.backgroundColor = eval(getColor() + " [l1.firstChild.nodeValue]");
59-
l2.style.backgroundColor = eval(getColor() + " [l2.firstChild.nodeValue]");
60-
l3.style.backgroundColor = eval(getColor() + " [l3.firstChild.nodeValue]");
61-
l4.style.backgroundColor = eval(getColor() + " [l4.firstChild.nodeValue]");
62-
l5.style.backgroundColor = eval(getColor() + " [l5.firstChild.nodeValue]");
63-
l6.style.backgroundColor = eval(getColor() + " [l6.firstChild.nodeValue]");
58+
for (var i = 1; i <= 6; i++) {
59+
let char = eval("l" + i + ".firstChild.nodeValue");
60+
if (/^[a-zA-Z]$/.test(char) && !document.querySelector('input[name="colorizeChars"]').checked) {
61+
eval("l" + i + ".style.backgroundColor = " + getColor() + " [' ']");
62+
} else {
63+
eval("l" + i + ".style.backgroundColor = " + getColor() + " [l" + i + ".firstChild.nodeValue]");
64+
}
65+
}
6466
}
6567

6668
function updateTapeGen() {
@@ -118,5 +120,3 @@ function Init() {
118120
updateTapeGen();
119121
updateTapeType();
120122
}
121-
122-
';

0 commit comments

Comments
 (0)