summaryrefslogtreecommitdiff
path: root/ext/mixed/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-16 11:59:17 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-02-16 12:00:56 -0500
commit42f1c2463c8051d9cbbcacd43f06922c2f11ec71 (patch)
treedfd3f2096bbd84704b52c942b231b5f19895f0f1 /ext/mixed/js
parent912d59d3dfefde5738b4244d74d944795edcc02c (diff)
Move generateId function
Diffstat (limited to 'ext/mixed/js')
-rw-r--r--ext/mixed/js/core.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js
index 2dd9cf40..b6ecb48b 100644
--- a/ext/mixed/js/core.js
+++ b/ext/mixed/js/core.js
@@ -257,6 +257,16 @@ const yomichan = (() => {
// Public
+ generateId(length) {
+ const array = new Uint8Array(length);
+ window.crypto.getRandomValues(array);
+ let id = '';
+ for (const value of array) {
+ id += value.toString(16).padStart(2, '0');
+ }
+ return id;
+ }
+
triggerOrphaned(error) {
this.trigger('orphaned', {error});
}