From a8f89036b5788a3f6ddb053824650b913a0c98a3 Mon Sep 17 00:00:00 2001 From: MetaMuffin Date: Fri, 6 Aug 2021 13:20:35 +0200 Subject: idk --- source/client/helper.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 source/client/helper.ts (limited to 'source/client/helper.ts') 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") +} + -- cgit v1.2.3-70-g09d2