mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Clear input field after we've grabbed the value
Reduce repetition of code
This commit is contained in:
parent
1217f93c05
commit
fd906d56e8
@ -156,33 +156,32 @@
|
||||
if (e.keyCode !== 13) return;
|
||||
|
||||
let word = document.getElementById("searchbox").value
|
||||
document.getElementById("searchbox").value = "";
|
||||
|
||||
word = word.toLowerCase();
|
||||
word = word.replace(/[`'"]/gi, " ")
|
||||
safe_word = sanitize(word)
|
||||
|
||||
if (word.includes("\\n")) {
|
||||
window.alert("Nice try...");
|
||||
document.getElementById("searchbox").value = "";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!safe_word) {
|
||||
window.alert("Illegal character detected");
|
||||
document.getElementById("searchbox").value = "";
|
||||
return;
|
||||
}
|
||||
|
||||
if (safe_word.startsWith(" ")) {
|
||||
window.alert("Illegal first character");
|
||||
document.getElementById("searchbox").value = "";
|
||||
return;
|
||||
}
|
||||
|
||||
words.push(word);
|
||||
$("#ignored-words").append("<li id=" + safe_word.replaceAll(" ", "-") + "><div class='card-header header-sm d-flex justify-content-between align-items-center'>" + word + " <button class='btn btn-danger' onclick='deleteItem(" + '"' + word + '"' + ")' ><i class='fas fa-trash'></i></button></div></li>")
|
||||
document.getElementById("searchbox").value = "";
|
||||
localStorage.setItem("words", JSON.stringify(words))
|
||||
|
||||
// Set word filters in browser cache
|
||||
localStorage.setItem("words", JSON.stringify(words))
|
||||
});
|
||||
|
||||
function deleteItem(item) {
|
||||
|
Loading…
Reference in New Issue
Block a user