summaryrefslogtreecommitdiffstats
path: root/web_src/js/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'web_src/js/utils.js')
-rw-r--r--web_src/js/utils.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/web_src/js/utils.js b/web_src/js/utils.js
index 229f4d6304..d5f921f8dc 100644
--- a/web_src/js/utils.js
+++ b/web_src/js/utils.js
@@ -23,3 +23,14 @@ export function isDarkTheme() {
export function uniq(arr) {
return Array.from(new Set(arr));
}
+
+const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
+
+// generate a random string
+export function random(length) {
+ let str = '';
+ for (let i = 0; i < length; i++) {
+ str += chars.charAt(Math.floor(Math.random() * chars.length));
+ }
+ return str;
+}