blob: 19c4f46be5a1eb0fa99fe662339dbadec2516abc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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")
}
|