Archive Search
-
For me the search function in the Archive is frustrating. Simply entering one character it launches into a search -- not accepting another character until the results are in -- then the same with each additional character.
-
@s-leon That sounds irritating. I'll see if I can adjust the code to only run if you click a button x
-
@lia We can also add a delay, so it delays a second or two between filter passes, allowing you time to type multiple characters. This should help for slower computers.
-
@s-leon What browser do you use?
-
-
@Lia This is one, very simple change as an option. I add a little bit to the top of the
<script>
element to detect modern browsers and do the cool, filter as you go for them (these should all have working asynchronous javascript, so should let you keep typing while searching.Essentially, this keeps everything the same for "fast browsers" and for everyone else, waits until enter is pressed to filter.
<script> var fast_browser = false; var fast_browsers = ["Chrome", "Firefox", "Edge", "Safari", "Opera"]; fast_browsers.forEach(function(browser) { if(navigator.userAgent.indexOf(browser) != -1) { fast_browser = true; } }); function filter_topics(event) { if(!fast_browser && event.keyCode != 13) { return; } var filter=new RegExp(document.getElementById("filter").value, 'i'); var topics=document.getElementById("topics").children;
If we go this route, we also have to change one more line, we need to add
event
into thefilter_topics
function call:<input id="filter" class="filter-input" width=32 onkeyup="filter_topics(event)">
Edit: We would want to test this on phones and tables, I don't know if they send over an enter or possibly some other keycode.
-
@biell I'll setup a cloned test page to try this on so we can fiddle, thanks for making that :)
Hadn't even gotten around to planning what to do yet. I'm still covered in glue >.> -
Test page setup with @biell s suggestion :)
https://archive.owforum.co.uk/test.htmlAny joy with that? Seems to behave the same on my iPhone (clunky at first as it filters the initial massive block.
If not I assume we can just have it so there is a search button that only allows the filter to run once clicked thus removing that initial lag on entry and also prevents the search running as you type.
-