From ecb7e6f192760499c9d3c207f17d49c00daf7f15 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Sun, 18 Dec 2022 22:14:57 -0800 Subject: [PATCH] add config.html, add config.js, add getURIData function to parse URI search params --- config.html | 13 +++++++++++++ scripts/config.js | 8 ++++++++ scripts/utils.js | 5 +++++ 3 files changed, 26 insertions(+) create mode 100644 config.html create mode 100644 scripts/config.js diff --git a/config.html b/config.html new file mode 100644 index 0000000..dce86b1 --- /dev/null +++ b/config.html @@ -0,0 +1,13 @@ + + + + + + tronnet - client + + + + + + + \ No newline at end of file diff --git a/scripts/config.js b/scripts/config.js new file mode 100644 index 0000000..f52679f --- /dev/null +++ b/scripts/config.js @@ -0,0 +1,8 @@ +import {request, goToPage, getURIData} from "./utils.js"; + +window.addEventListener("DOMContentLoaded", init); + +async function init () { + let uriData = getURIData(); + console.log(uriData); +} \ No newline at end of file diff --git a/scripts/utils.js b/scripts/utils.js index dd16159..f3c0728 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -84,4 +84,9 @@ export function goToPage (page, data={}) { url.searchParams.append(k, data[k]); } window.location.href = url.toString(); +} + +export function getURIData () { + let url = new URL(window.location.href); + return Object.fromEntries(url.searchParams); } \ No newline at end of file