mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'feature/log-filter' of gitlab.com:crafty-controller/crafty-4 into feature/log-filter
This commit is contained in:
commit
e576a69d39
@ -76,15 +76,14 @@
|
|||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
<script>
|
<script>
|
||||||
var lines = []
|
var lines = [];
|
||||||
|
var words = [];
|
||||||
if (localStorage.getItem("words")) {
|
if (localStorage.getItem("words")) {
|
||||||
try {
|
try {
|
||||||
var words = JSON.parse(localStorage.getItem("words"));
|
words = JSON.parse(localStorage.getItem("words"));
|
||||||
} catch {
|
} catch {
|
||||||
var words = []
|
words = [];
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
var words = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const serverId = new URLSearchParams(document.location.search).get('id')
|
const serverId = new URLSearchParams(document.location.search).get('id')
|
||||||
@ -126,25 +125,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function liveSearch() {
|
function liveSearch() {
|
||||||
let search_query = document.getElementById("searchbox").value;
|
for (let i = 0; i < lines.length; i++) {
|
||||||
|
// Reinitialise line visibility
|
||||||
|
lines[i].classList.remove("is-hidden");
|
||||||
|
|
||||||
//Use innerText if all contents are visible
|
// If we have no words to filter, continue.
|
||||||
//Use textContent for including hidden elements
|
if (!words.length) continue;
|
||||||
for (var i = 0; i < lines.length; i++) {
|
|
||||||
if (words.length > 0) {
|
// If we find our target word hide the line
|
||||||
let flag = false;
|
if (words.some(ai => lines[i].textContent.toLowerCase().includes(ai))) {
|
||||||
for (var k = 0; k < words.length; k++) {
|
lines[i].classList.add("is-hidden");
|
||||||
if (lines[i].textContent.toLowerCase().includes(words[k])) {
|
|
||||||
flag = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!flag) {
|
|
||||||
lines[i].classList.remove("is-hidden");
|
|
||||||
} else {
|
|
||||||
lines[i].classList.add("is-hidden");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
lines[i].classList.remove("is-hidden");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,8 +147,8 @@
|
|||||||
searchInput.addEventListener('keyup', (e) => {
|
searchInput.addEventListener('keyup', (e) => {
|
||||||
clearTimeout(typingTimer);
|
clearTimeout(typingTimer);
|
||||||
typingTimer = setTimeout(liveSearch, typeInterval);
|
typingTimer = setTimeout(liveSearch, typeInterval);
|
||||||
let key = e.keyCode;
|
// On Return/Enter key press
|
||||||
if (key === 13) {
|
if (e.keyCode === 13) {
|
||||||
let word = document.getElementById("searchbox").value
|
let word = document.getElementById("searchbox").value
|
||||||
word = word.toLowerCase();
|
word = word.toLowerCase();
|
||||||
if (word === "\\n") {
|
if (word === "\\n") {
|
||||||
@ -190,7 +180,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function deleteItem(item) {
|
function deleteItem(item) {
|
||||||
safe_item = sanitize(item);
|
let safe_item = sanitize(item);
|
||||||
console.log(item)
|
console.log(item)
|
||||||
words.splice(words.indexOf(item), 1);
|
words.splice(words.indexOf(item), 1);
|
||||||
$("#" + safe_item.replaceAll(" ", "-")).remove();
|
$("#" + safe_item.replaceAll(" ", "-")).remove();
|
||||||
@ -199,7 +189,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function populateWords() {
|
function populateWords() {
|
||||||
for (var i = 0; i < words.length; i++) {
|
for (let i = 0; i < words.length; i++) {
|
||||||
let safe_word = sanitize(words[i]);
|
let safe_word = sanitize(words[i]);
|
||||||
$("#ignored-words").append("<li id=" + safe_word.replaceAll(" ", "-") + "><div class='card-header header-sm d-flex justify-content-between align-items-center'>" + words[i] + " <button class='btn btn-danger' onclick='deleteItem(" + '"' + words[i] + '"' + ")' ><i class='fas fa-trash'></i></button></div></li>")
|
$("#ignored-words").append("<li id=" + safe_word.replaceAll(" ", "-") + "><div class='card-header header-sm d-flex justify-content-between align-items-center'>" + words[i] + " <button class='btn btn-danger' onclick='deleteItem(" + '"' + words[i] + '"' + ")' ><i class='fas fa-trash'></i></button></div></li>")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user