Update URL QueryParam when Type set in Dropdown on Web Interface

- This also pushes the updated URL state to history
- Allows jumping back to the web interface after clicking on an image
  and having the type set to image search
- Previously type would get reset to the default search type on
  jumping back
This commit is contained in:
Debanjum Singh Solanky 2022-08-28 12:22:22 +03:00
parent 2eae32d743
commit d0531c3064

View file

@ -121,6 +121,12 @@
});
}
function setTypeInQueryParam(type) {
var url = new URL(window.location.href);
url.searchParams.set("t", type.value);
window.history.pushState({}, "", url.href);
}
window.onload = function () {
// Dynamically populate type dropdown based on enabled search types and type passed as URL query parameter
populate_type_dropdown();
@ -140,7 +146,7 @@
<div id="options">
<!--Add Dropdown to Select Query Type -->
<select id="type"></select>
<select id="type" onchange="setTypeInQueryParam(this)"></select>
<!--Add Button To Regenerate -->
<button id="regenerate" onclick="regenerate()">Regenerate</button>