mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-14 13:50:25 +08:00
38 lines
954 B
JavaScript
38 lines
954 B
JavaScript
// correct fetch for desktop application
|
|
|
|
var printErr = undefined;
|
|
var print = undefined;
|
|
|
|
var fetch = self.fetch;
|
|
var getBinaryPromise = null;
|
|
if (self.AscDesktopEditor && document.currentScript && 0 == document.currentScript.src.indexOf("file:///"))
|
|
{
|
|
fetch = undefined; // fetch not support file:/// scheme
|
|
getBinaryPromise = function()
|
|
{
|
|
var wasmPath = "ascdesktop://zlib/" + wasmBinaryFile.substr(8);
|
|
return new Promise(function (resolve, reject)
|
|
{
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open('GET', wasmPath, true);
|
|
xhr.responseType = 'arraybuffer';
|
|
|
|
if (xhr.overrideMimeType)
|
|
xhr.overrideMimeType('text/plain; charset=x-user-defined');
|
|
else
|
|
xhr.setRequestHeader('Accept-Charset', 'x-user-defined');
|
|
|
|
xhr.onload = function ()
|
|
{
|
|
if (this.status == 200)
|
|
resolve(new Uint8Array(this.response));
|
|
};
|
|
xhr.send(null);
|
|
});
|
|
}
|
|
}
|
|
else
|
|
{
|
|
getBinaryPromise = function() { return getBinaryPromise2(); }
|
|
}
|