Handle managing the search query smarter
This commit is contained in:
parent
5cc04863ac
commit
8e0385e809
|
@ -8,17 +8,23 @@
|
|||
var present = true;
|
||||
if (present == true) {
|
||||
var toAppend = ` AND ${field}: "${value}"`;
|
||||
var toRemove = `${field}: "${value}"`;
|
||||
} else {
|
||||
var toAppend = ` AND NOT ${field}: "${value}"`;
|
||||
var toRemove = `NOT ${field}: "${value}"`;
|
||||
}
|
||||
if (!queryElement.value.includes(toAppend)) {
|
||||
if (!queryElement.value.includes(toAppend) && !queryElement.value.includes(toRemove)) {
|
||||
queryElement.value+=toAppend;
|
||||
} else {
|
||||
queryElement.value = queryElement.value.replace(toAppend, "");
|
||||
queryElement.value = queryElement.value.replaceAll(toAppend, "");
|
||||
queryElement.value = queryElement.value.replaceAll(toRemove, "");
|
||||
}
|
||||
if (field == "src") {
|
||||
document.getElementById("source").selectedIndex = 0;
|
||||
}
|
||||
if (queryElement.value.startsWith(" AND ")) {
|
||||
queryElement.value = queryElement.value.replace(" AND ", "");
|
||||
}
|
||||
htmx.trigger("#search", "click");
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue