mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Rename functions for readability
This commit is contained in:
parent
2599658321
commit
1f2ff2345d
@ -87,7 +87,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function liveSearch() {
|
function hideFilteredWords() {
|
||||||
for (let i = 0; i < lines.length; i++) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
// Reinitialise line visibility
|
// Reinitialise line visibility
|
||||||
lines[i].classList.remove("is-hidden");
|
lines[i].classList.remove("is-hidden");
|
||||||
@ -106,12 +106,12 @@
|
|||||||
return string.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, '');
|
return string.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteItem(item) {
|
function deleteWord(item) {
|
||||||
let safe_item = sanitize(item);
|
let safe_item = sanitize(item);
|
||||||
words.splice(words.indexOf(item), 1);
|
words.splice(words.indexOf(item), 1);
|
||||||
if (safe_item) $("#" + safe_item.replaceAll(" ", "-")).remove();
|
if (safe_item) $("#" + safe_item.replaceAll(" ", "-")).remove();
|
||||||
|
|
||||||
liveSearch();
|
hideFilteredWords();
|
||||||
localStorage.setItem("words", JSON.stringify(words));
|
localStorage.setItem("words", JSON.stringify(words));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +121,7 @@
|
|||||||
let searchInput = document.getElementById('searchbox');
|
let searchInput = document.getElementById('searchbox');
|
||||||
searchInput.addEventListener('keyup', (e) => {
|
searchInput.addEventListener('keyup', (e) => {
|
||||||
clearTimeout(typingTimer);
|
clearTimeout(typingTimer);
|
||||||
typingTimer = setTimeout(liveSearch, typeInterval);
|
typingTimer = setTimeout(hideFilteredWords, typeInterval);
|
||||||
|
|
||||||
// Return/Enter key press otherwise bail
|
// Return/Enter key press otherwise bail
|
||||||
if (e.keyCode !== 13) return;
|
if (e.keyCode !== 13) return;
|
||||||
@ -150,7 +150,7 @@
|
|||||||
$("#ignored-words").append(
|
$("#ignored-words").append(
|
||||||
`<li id=${safe_word.replaceAll(" ", "-")}>` +
|
`<li id=${safe_word.replaceAll(" ", "-")}>` +
|
||||||
"<div class='card-header header-sm d-flex justify-content-between align-items-center'>" +
|
"<div class='card-header header-sm d-flex justify-content-between align-items-center'>" +
|
||||||
`${word} <button class='btn btn-danger' onclick='deleteItem("${word}")' >` +
|
`${word} <button class='btn btn-danger' onclick='deleteWord("${word}")' >` +
|
||||||
"<i class='fas fa-trash'></i></button></div></li>"
|
"<i class='fas fa-trash'></i></button></div></li>"
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -165,7 +165,7 @@
|
|||||||
$("#ignored-words").append(
|
$("#ignored-words").append(
|
||||||
`<li id=${safe_word.replaceAll(" ", "-")}>` +
|
`<li id=${safe_word.replaceAll(" ", "-")}>` +
|
||||||
"<div class='card-header header-sm d-flex justify-content-between align-items-center'>" +
|
"<div class='card-header header-sm d-flex justify-content-between align-items-center'>" +
|
||||||
`${word} <button class='btn btn-danger' onclick='deleteItem("${word}")' >` +
|
`${word} <button class='btn btn-danger' onclick='deleteWord("${word}")' >` +
|
||||||
"<i class='fas fa-trash'></i></button></div></li>"
|
"<i class='fas fa-trash'></i></button></div></li>"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -199,7 +199,7 @@
|
|||||||
$('#virt_console').html(data);
|
$('#virt_console').html(data);
|
||||||
scroll();
|
scroll();
|
||||||
lines = document.querySelectorAll('.box');
|
lines = document.querySelectorAll('.box');
|
||||||
liveSearch();
|
hideFilteredWords();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user