diff options
| author | rr- | 2017-01-07 11:07:51 +0100 |
|---|---|---|
| committer | rr- | 2017-01-08 02:26:26 +0100 |
| commit | f00cc5f3fa3a16a1f7055c772c3008d030f41fef (patch) | |
| tree | f4d9b3b63900c087425f5952c6f2f58098b7c2f6 /client/js/util | |
| parent | d1bb33ecf0e82689ecbca747a8ac7b038d6cf173 (diff) | |
client/posts: search for similar posts on upload
Diffstat (limited to 'client/js/util')
| -rw-r--r-- | client/js/util/misc.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/client/js/util/misc.js b/client/js/util/misc.js index 56eb66e..3037b10 100644 --- a/client/js/util/misc.js +++ b/client/js/util/misc.js @@ -217,6 +217,19 @@ function escapeSearchTerm(text) { return text.replace(/([a-z_-]):/g, '$1\\:'); } +function dataURItoBlob(dataURI) { + const chunks = dataURI.split(','); + const byteString = chunks[0].indexOf('base64') >= 0 ? + window.atob(chunks[1]) : + unescape(chunks[1]); + const mimeString = chunks[0].split(':')[1].split(';')[0]; + const data = new Uint8Array(byteString.length); + for (var i = 0; i < byteString.length; i++) { + data[i] = byteString.charCodeAt(i); + } + return new Blob([data], {type: mimeString}); +} + module.exports = { range: range, formatUrlParameters: formatUrlParameters, @@ -236,4 +249,5 @@ module.exports = { arraysDiffer: arraysDiffer, decamelize: decamelize, escapeSearchTerm: escapeSearchTerm, + dataURItoBlob: dataURItoBlob, }; |