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