mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-26 22:01:50 +00:00
d97a163011
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4371 fc73d0e0-1445-4013-8a0c-d673dee63da5
43 lines
883 B
JavaScript
43 lines
883 B
JavaScript
|
|
mergeInto(LibraryManager.library,
|
|
{
|
|
emscriptenfte_async_wget_data2 : function(url, ctx, onload, onerror, onprogress)
|
|
{
|
|
var _url = Pointer_stringify(url);
|
|
|
|
var http = new XMLHttpRequest();
|
|
http.open('GET', _url, true);
|
|
http.responseType = 'arraybuffer';
|
|
|
|
http.onload = function(e)
|
|
{
|
|
if (http.status == 200)
|
|
{
|
|
var bar = new Uint8Array(http.response);
|
|
var buf = _malloc(bar.length);
|
|
HEAPU8.set(bar, buf);
|
|
if (onload)
|
|
Runtime.dynCall('viii', onload, [ctx, buf, bar.length]);
|
|
}
|
|
else
|
|
{
|
|
if (onerror)
|
|
Runtime.dynCall('vii', onerror, [ctx, http.status]);
|
|
}
|
|
};
|
|
|
|
http.onerror = function(e)
|
|
{
|
|
if (onerror)
|
|
Runtime.dynCall('vii', onerror, [ctx, http.status]);
|
|
};
|
|
|
|
http.onprogress = function(e)
|
|
{
|
|
if (onprogress)
|
|
Runtime.dynCall('viii', onprogress, [ctx, e.loaded, e.total]);
|
|
};
|
|
|
|
http.send(null);
|
|
}
|
|
});
|