This commit is contained in:
Alon Zakai 2012-06-21 19:50:24 -07:00
Родитель 2abffbd059
Коммит 7e24c13447
1 изменённых файлов: 28 добавлений и 32 удалений

Просмотреть файл

@ -148,26 +148,24 @@ mergeInto(LibraryManager.library, {
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
xhr.onload = function() {
if (xhr.status == 200) {
onload(xhr.response);
} else {
onerror();
}
if (xhr.status == 200) {
onload(xhr.response);
} else {
onerror();
}
};
xhr.onerror = onerror;
xhr.send(null);
},
asyncLoad: function(url, callback) {
Browser.xhrLoad(url,
function(arrayBuffer) {
assert(arrayBuffer, 'Loading data file "' + url + '" failed (no arrayBuffer).');
callback(new Uint8Array(arrayBuffer));
removeRunDependency();
},
function(event) {
assert(arrayBuffer, 'Loading data file "' + url + '" failed.');
});
Browser.xhrLoad(url, function(arrayBuffer) {
assert(arrayBuffer, 'Loading data file "' + url + '" failed (no arrayBuffer).');
callback(new Uint8Array(arrayBuffer));
removeRunDependency();
}, function(event) {
throw 'Loading data file "' + url + '" failed.';
});
addRunDependency();
}
},
@ -175,25 +173,23 @@ mergeInto(LibraryManager.library, {
emscripten_async_wget: function(url, file, onload, onerror) {
url = Pointer_stringify(url);
Browser.xhrLoad(url,
function (response) {
var absolute = Pointer_stringify(file);
var index = absolute.lastIndexOf('/');
FS.createDataFile(
absolute.substr(0, index),
absolute.substr(index +1),
new Uint8Array(response),
true, true);
Browser.xhrLoad(url, function(response) {
var absolute = Pointer_stringify(file);
var index = absolute.lastIndexOf('/');
FS.createDataFile(
absolute.substr(0, index),
absolute.substr(index +1),
new Uint8Array(response),
true, true);
if (onload) {
FUNCTION_TABLE[onload](file);
}
},
function (event) {
if (onerror) {
FUNCTION_TABLE[onerror](file);
}
});
if (onload) {
FUNCTION_TABLE[onload](file);
}
}, function(event) {
if (onerror) {
FUNCTION_TABLE[onerror](file);
}
});
},
emscripten_async_run_script__deps: ['emscripten_run_script'],