Skip to content

Commit

Permalink
Save query in link parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jiegec committed Dec 14, 2023
1 parent 18f664a commit 4340b44
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion code/viewer_partial.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,26 @@

createApp({
setup() {
const search = ref("");
const urlParams = new URLSearchParams(window.location.search);
let initialSearch = urlParams.get('q');
if (initialSearch === null) {
initialSearch = "";
}
const search = ref(initialSearch);

const allGroups = {% endraw %} {{ all_groups() }} {% raw %};
const allExtensions = ["LSX", "LASX"];
const groups = ref(allGroups);
const extensions = ref(allExtensions);

const intrinsics = computed(() => {
// update search to url
// https://stackoverflow.com/questions/10970078/modifying-a-query-string-without-reloading-the-page
const url = window.location.href;
var r = new URL(url);
r.searchParams.set('q', search.value);
window.history.pushState({ path: r.href }, '', r.href);

let result = [];
for (let val of allIntrinsics) {
if (!groups.value.includes(val.group)) {
Expand Down

0 comments on commit 4340b44

Please sign in to comment.