From 4340b44e03bf5fd6472c16f637760e1ce6548eed Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Thu, 14 Dec 2023 14:24:12 +0800 Subject: [PATCH] Save query in link parameter --- code/viewer_partial.html | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/code/viewer_partial.html b/code/viewer_partial.html index ea4d682a..93049d17 100644 --- a/code/viewer_partial.html +++ b/code/viewer_partial.html @@ -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)) {