diff options
author | Christopher Speller <crspeller@gmail.com> | 2015-08-11 12:08:08 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2015-08-11 12:08:08 -0400 |
commit | 4c7cdb20f074e2c06a08cd64a57060b8e8b64d2e (patch) | |
tree | fd5e1948bc5f24cd8711a7a6681b142745228025 /web/react/utils/utils.jsx | |
parent | d72d356cbcb027df8b2fcd3c84e26b64119e6b5c (diff) | |
parent | 17b05f705f910429ece1ca6c64ec56bf89dd014b (diff) | |
download | chat-4c7cdb20f074e2c06a08cd64a57060b8e8b64d2e.tar.gz chat-4c7cdb20f074e2c06a08cd64a57060b8e8b64d2e.tar.bz2 chat-4c7cdb20f074e2c06a08cd64a57060b8e8b64d2e.zip |
Merge pull request #359 from hmhealey/mm1770
MM-1770 Add the ability to cancel in-progress file uploads
Diffstat (limited to 'web/react/utils/utils.jsx')
-rw-r--r-- | web/react/utils/utils.jsx | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index a759cc579..2214b6239 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -913,3 +913,24 @@ module.exports.getFileName = function(path) { var split = path.split('/'); return split[split.length - 1]; }; + +// Generates a RFC-4122 version 4 compliant globally unique identifier. +module.exports.generateId = function() { + // implementation taken from http://stackoverflow.com/a/2117523 + var id = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'; + + id = id.replace(/[xy]/g, function(c) { + var r = Math.floor(Math.random() * 16); + + var v; + if (c === 'x') { + v = r; + } else { + v = r & 0x3 | 0x8; + } + + return v.toString(16); + }); + + return id; +}; |