assetflow/static/js/searchBox.js

29 lines
1.1 KiB
JavaScript
Raw Normal View History

document.getElementById("SearchBox").addEventListener("keyup", handleSearchChange);
2023-05-04 20:21:10 +02:00
const autocompleteBox = document.getElementById("autocomplete-items");
autocompleteBox.style.display = "none";
function handleSearchChange(e) {
console.log(e.target.value);
2023-06-06 23:49:16 +02:00
// document.getElementById("SearchBox").setAttribute("data-bs-content", "Search results will show up here soon")
2023-05-23 22:04:56 +02:00
return; // No you won't. I'm not done yet.
// Check if known prefix is used (either > or #)
2023-05-04 20:21:10 +02:00
if(e.target.value != "" ) {
autocompleteBox.style.display = "block";
autocompleteBox.innerHTML = "Search results will show up here soon <br> Trust me <br> Results";
} else {
autocompleteBox.style.display = "none";
}
if (e.target.value[0] == ">") {
2023-05-04 20:21:10 +02:00
autocompleteBox.innerHTML = "Start typing to search for commands <br> >goto items";
if(e.target.value == ">goto items") {
autocompleteBox.innerHTML = "<a href='/allItems'>Goto Items</a>";
}
} else if (e.target.value[0] == "#") {
// Search for SKU
2023-05-04 20:21:10 +02:00
autocompleteBox.innerHTML = "Start typing to search for items by SKU";
} else {
// Search for name
}
}