diff --git a/www/common/common-util.js b/www/common/common-util.js index 2542e0a22..f5ba9a61c 100644 --- a/www/common/common-util.js +++ b/www/common/common-util.js @@ -89,5 +89,15 @@ define([], function () { return Math.floor(bytes / 1024 * 100) / 100; }; + Util.fetch = function (src, cb) { + var xhr = new XMLHttpRequest(); + xhr.open("GET", src, true); + xhr.responseType = "arraybuffer"; + xhr.onload = function () { + return void cb(void 0, new Uint8Array(xhr.response)); + }; + xhr.send(null); + }; + return Util; }); diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index b58209029..a57ae9787 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -66,6 +66,7 @@ define([ common.fixFileName = Util.fixFileName; common.bytesToMegabytes = Util.bytesToMegabytes; common.bytesToKilobytes = Util.bytesToKilobytes; + common.fetch = Util.fetch; // import hash utilities for export var createRandomHash = common.createRandomHash = Hash.createRandomHash;