Change variable naming to make more sense

This commit is contained in:
Andrew 2022-10-20 10:01:20 -07:00
parent 3b813a6849
commit cbe7ad9a39

View File

@ -76,7 +76,7 @@
{% block js %} {% block js %}
<script> <script>
var cards = [] var lines = []
if (localStorage.getItem("words")) { if (localStorage.getItem("words")) {
try { try {
var words = JSON.parse(localStorage.getItem("words")); var words = JSON.parse(localStorage.getItem("words"));
@ -98,7 +98,7 @@
console.log('Got Log From Server') console.log('Got Log From Server')
$('#virt_console').html(data); $('#virt_console').html(data);
scroll(); scroll();
cards = document.querySelectorAll('.box'); lines = document.querySelectorAll('.box');
liveSearch(); liveSearch();
}, },
}); });
@ -130,21 +130,21 @@
//Use innerText if all contents are visible //Use innerText if all contents are visible
//Use textContent for including hidden elements //Use textContent for including hidden elements
for (var i = 0; i < cards.length; i++) { for (var i = 0; i < lines.length; i++) {
if (words.length > 0) { if (words.length > 0) {
let flag = false; let flag = false;
for (var k = 0; k < words.length; k++) { for (var k = 0; k < words.length; k++) {
if (cards[i].textContent.toLowerCase().includes(words[k])) { if (lines[i].textContent.toLowerCase().includes(words[k])) {
flag = true; flag = true;
} }
} }
if (!flag) { if (!flag) {
cards[i].classList.remove("is-hidden"); lines[i].classList.remove("is-hidden");
} else { } else {
cards[i].classList.add("is-hidden"); lines[i].classList.add("is-hidden");
} }
} else { } else {
cards[i].classList.remove("is-hidden"); lines[i].classList.remove("is-hidden");
} }
} }
} }