diff options
Diffstat (limited to 'plugin_loader/static/library.js')
| -rw-r--r-- | plugin_loader/static/library.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/plugin_loader/static/library.js b/plugin_loader/static/library.js index abd4453f..744cc77f 100644 --- a/plugin_loader/static/library.js +++ b/plugin_loader/static/library.js @@ -8,7 +8,7 @@ window.addEventListener("message", function(evt) { }, false); async function call_server_method(method_name, arg_object={}) { - let id = `${new Date().getTime()}`; + let id = `${uuidv4()}`; console.debug(JSON.stringify({ "id": id, "method": method_name, @@ -22,6 +22,13 @@ async function call_server_method(method_name, arg_object={}) { }); } +// Source: https://stackoverflow.com/a/2117523 Thanks! +function uuidv4() { + return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c => + (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16) + ); +} + async function fetch_nocors(url, request={}) { let args = { method: "POST", headers: {}, body: "" }; request = {...args, ...request}; |
