summaryrefslogtreecommitdiff
path: root/source/client/helper.ts
diff options
context:
space:
mode:
Diffstat (limited to 'source/client/helper.ts')
-rw-r--r--source/client/helper.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/source/client/helper.ts b/source/client/helper.ts
new file mode 100644
index 0000000..19c4f46
--- /dev/null
+++ b/source/client/helper.ts
@@ -0,0 +1,14 @@
+export function get_query_params(): { [key: string]: string } {
+ const q: { [key: string]: string } = {}
+ for (const kv of window.location.search.substr(1).split("&")) {
+ const [key, value] = kv.split("=")
+ q[decodeURIComponent(key)] = decodeURIComponent(value)
+ }
+ return q
+}
+
+export function hex_id(len: number = 8): string {
+ if (len > 8) return hex_id() + hex_id(len - 8)
+ return Math.floor(Math.random() * 16 ** len).toString(16).padStart(len, "0")
+}
+