mirror of
https://github.com/photonstorm/phaser
synced 2024-11-14 00:47:29 +00:00
The XHRLoader
will now return a fake XHR result object containing the decoded base64 data if a base64 file is detected, skipping the creation of a real XML Http Request object.
This commit is contained in:
parent
aa0d60786f
commit
324dcfba97
1 changed files with 14 additions and 1 deletions
|
@ -17,12 +17,25 @@ var MergeXHRSettings = require('./MergeXHRSettings');
|
|||
* @param {Phaser.Loader.File} file - The File to download.
|
||||
* @param {Phaser.Types.Loader.XHRSettingsObject} globalXHRSettings - The global XHRSettings object.
|
||||
*
|
||||
* @return {XMLHttpRequest} The XHR object.
|
||||
* @return {XMLHttpRequest} The XHR object, or a FakeXHR Object in the base of base64 data.
|
||||
*/
|
||||
var XHRLoader = function (file, globalXHRSettings)
|
||||
{
|
||||
var config = MergeXHRSettings(globalXHRSettings, file.xhrSettings);
|
||||
|
||||
if (file.base64)
|
||||
{
|
||||
var base64Data = file.url.split(';base64,').pop() || file.url.split(',').pop();
|
||||
|
||||
var fakeXHR = {
|
||||
responseText: atob(base64Data)
|
||||
};
|
||||
|
||||
file.onBase64Load(fakeXHR);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open('GET', file.src, config.async, config.user, config.password);
|
||||
|
|
Loading…
Reference in a new issue