diff options
| author | Terry Truong <terry06890@gmail.com> | 2022-07-06 17:29:21 +1000 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2022-07-06 17:29:21 +1000 |
| commit | 983530cffd27a6c633ea91e9ce910779043c7c6a (patch) | |
| tree | 5eadc6536c41778088ebd7757b3db1bbe0a4080e /src/components | |
| parent | 7e67af7003ece713d7823fa7d6b32749516d508a (diff) | |
Use URLSearchParams instead of plain strings
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/SearchModal.vue | 22 | ||||
| -rw-r--r-- | src/components/TileInfoModal.vue | 2 |
2 files changed, 16 insertions, 8 deletions
diff --git a/src/components/SearchModal.vue b/src/components/SearchModal.vue index f350bcb..de6bc75 100644 --- a/src/components/SearchModal.vue +++ b/src/components/SearchModal.vue @@ -55,7 +55,8 @@ export default defineComponent({ suggsInput: '', // The input that resulted in the current suggestions (used to highlight matching text) // For search-suggestion requests lastSuggReqTime: 0, // Set when a search-suggestions request is initiated - pendingSuggReqParams: '', // Used by a search-suggestion requester to request with the latest user input + pendingSuggReqParams: null as null | URLSearchParams, + // Used by a search-suggestion requester to request with the latest user input pendingDelayedSuggReq: 0, // Set via setTimeout() for a non-initial search-suggestions request pendingSuggInput: '', // Used to remember what input triggered a suggestions request // Other @@ -123,16 +124,19 @@ export default defineComponent({ return; } // Get URL params to use for querying search-suggestions - let urlParams = 'type=sugg&name=' + encodeURIComponent(input.value); - urlParams += '&limit=' + this.uiOpts.searchSuggLimit; - urlParams += '&tree=' + this.uiOpts.tree; + let urlParams = new URLSearchParams({ + type: 'sugg', + name: input.value, + limit: String(this.uiOpts.searchSuggLimit), + tree: this.uiOpts.tree, + }); // Query server, delaying/skipping if a request was recently sent this.pendingSuggReqParams = urlParams; this.pendingSuggInput = input.value; let doReq = async () => { let suggInput = this.pendingSuggInput; let responseObj: SearchSuggResponse = - await queryServer(this.pendingSuggReqParams); + await queryServer(this.pendingSuggReqParams!); if (responseObj == null){ return; } @@ -198,8 +202,12 @@ export default defineComponent({ return; } // Ask server for nodes in parent-chain, updates tolMap, then emits search event - let urlParams = 'type=node&toroot=true&name=' + encodeURIComponent(tolNodeName); - urlParams += '&tree=' + this.uiOpts.tree; + let urlParams = new URLSearchParams({ + type: 'node', + name: tolNodeName, + toroot: 'true', + tree: this.uiOpts.tree, + }); this.$emit('net-wait'); // Allows the parent component to show a loading-indicator let responseObj: {[x: string]: TolNode} = await queryServer(urlParams); this.$emit('net-get'); diff --git a/src/components/TileInfoModal.vue b/src/components/TileInfoModal.vue index 9e0f2c3..02712cd 100644 --- a/src/components/TileInfoModal.vue +++ b/src/components/TileInfoModal.vue @@ -8,7 +8,7 @@ class="absolute top-1 right-1 md:top-2 md:right-2 w-8 h-8 hover:cursor-pointer"/> <div class="absolute top-1 left-1 md:top-2 md:left-2 flex items-center"> <a :href="'/?node=' + encodeURIComponent(nodeName)" class="block w-8 h-8 p-[2px] hover:cursor-pointer" - @click.prevent="onLinkIconClick"> + @click.prevent="onLinkIconClick" title="Copy link to this node"> <link-icon/> </a> <transition name="fadeslow"> |
