2013-12-19 18:41:57 +00:00
mergeInto ( LibraryManager . library ,
{
//generic handles array
//yeah, I hope you don't use-after-free. hopefully that sort of thing will be detected on systems with easier non-mangled debuggers.
$FTEH _ _deps : [ ] ,
$FTEH : {
h : [ ] ,
f : { }
} ,
2014-09-02 02:44:43 +00:00
//FIXME: split+merge by \n
emscriptenfte _print : function ( msg )
{
FTEC . linebuffer += Pointer _stringify ( msg ) ;
for ( ; ; )
{
nl = FTEC . linebuffer . indexOf ( "\n" ) ;
if ( nl == - 1 )
break ;
console . log ( FTEC . linebuffer . substring ( 0 , nl ) ) ;
FTEC . linebuffer = FTEC . linebuffer . substring ( nl + 1 ) ;
}
} ,
emscriptenfte _alert : function ( msg )
{
msg = Pointer _stringify ( msg ) ;
console . log ( msg ) ;
alert ( msg ) ;
} ,
2014-09-08 23:47:19 +00:00
emscriptenfte _handle _alloc _ _deps : [ '$FTEH' ] ,
emscriptenfte _handle _alloc : function ( h )
{
for ( var i = 0 ; FTEH . h . length ; i += 1 )
{
if ( FTEH . h [ i ] == null )
{
FTEH . h [ i ] = h ;
return i ;
}
}
i = FTEH . h . length ;
FTEH . h [ i ] = h ;
return i ;
} ,
//temp files
emscriptenfte _buf _createfromarraybuf _ _deps : [ 'emscriptenfte_handle_alloc' ] ,
emscriptenfte _buf _createfromarraybuf : function ( buf )
{
var len = buf . length ;
var b = { h : - 1 , r : 1 , l : len , m : len , d : new Uint8Array ( buf ) , n : null } ;
b . h = _emscriptenfte _handle _alloc ( b ) ;
return b . h ;
} ,
$FTEC _ _deps : [ 'emscriptenfte_buf_createfromarraybuf' ] ,
2013-12-19 18:41:57 +00:00
$FTEC :
{
2014-09-02 02:44:43 +00:00
ctxwarned : 0 ,
2014-08-27 08:41:31 +00:00
linebuffer : '' ,
2013-12-19 18:41:57 +00:00
w : - 1 ,
h : - 1 ,
donecb : 0 ,
evcb : {
resize : 0 ,
mouse : 0 ,
2014-08-27 08:41:31 +00:00
key : 0
2013-12-19 18:41:57 +00:00
} ,
2014-09-08 23:47:19 +00:00
loadurl : function ( url , arraybuf )
{
if ( FTEC . evcb . loadfile != 0 )
{
var handle = - 1 ;
if ( arraybuf !== undefined )
handle = _emscriptenfte _buf _createfromarraybuf ( arraybuf ) ;
var ptr = _malloc ( url . length ) ;
writeStringToMemory ( url , ptr ) ;
Runtime . dynCall ( 'vii' , FTEC . evcb . loadfile , [ ptr , handle ] ) ;
_free ( ptr ) ;
}
} ,
2013-12-19 18:41:57 +00:00
handleevent : function ( event )
{
switch ( event . type )
{
case 'resize' :
if ( FTEC . evcb . resize != 0 )
Runtime . dynCall ( 'vii' , FTEC . evcb . resize , [ Module [ 'canvas' ] . width , Module [ 'canvas' ] . height ] ) ;
break ;
case 'mousemove' :
if ( FTEC . evcb . mouse != 0 )
{
if ( Browser . pointerLock )
{
if ( typeof event . movementX === 'undefined' )
{
event . movementX = event . mozMovementX ;
event . movementY = event . mozMovementY ;
}
if ( typeof event . movementX === 'undefined' )
{
event . movementX = event . webkitMovementX ;
event . movementY = event . webkitMovementY ;
}
2014-08-25 07:35:41 +00:00
Runtime . dynCall ( 'viidddd' , FTEC . evcb . mouse , [ 0 , false , event . movementX , event . movementY , 0 , 0 ] ) ;
2013-12-19 18:41:57 +00:00
}
else
2014-08-25 07:35:41 +00:00
Runtime . dynCall ( 'viidddd' , FTEC . evcb . mouse , [ 0 , true , event . pageX , event . pageY , 0 , 0 ] ) ;
2013-12-19 18:41:57 +00:00
}
break ;
case 'mousedown' :
2014-08-25 07:35:41 +00:00
if ( Browser . isFullScreen == 0 )
{
Browser . requestFullScreen ( true , true ) ;
Module [ 'canvas' ] . requestPointerLock ( ) ;
}
2013-12-19 18:41:57 +00:00
case 'mouseup' :
if ( FTEC . evcb . button != 0 )
{
Runtime . dynCall ( 'viii' , FTEC . evcb . button , [ 0 , event . type == 'mousedown' , event . button ] ) ;
event . preventDefault ( ) ;
}
break ;
case 'mousewheel' :
case 'wheel' :
if ( FTEC . evcb . button != 0 )
{
2014-08-25 07:35:41 +00:00
Runtime . dynCall ( 'viii' , FTEC . evcb . button , [ 0 , 2 , event . deltaY ] ) ;
2013-12-19 18:41:57 +00:00
event . preventDefault ( ) ;
}
break ;
case 'mouseout' :
if ( FTEC . evcb . button != 0 )
{
for ( var i = 0 ; i < 8 ; i ++ )
Runtime . dynCall ( 'viii' , FTEC . evcb . button , [ 0 , false , i ] ) ;
}
break ;
case 'keypress' :
if ( FTEC . evcb . key != 0 )
{
Runtime . dynCall ( 'viiii' , FTEC . evcb . key , [ 0 , 1 , 0 , event . charCode ] ) ;
Runtime . dynCall ( 'viiii' , FTEC . evcb . key , [ 0 , 0 , 0 , event . charCode ] ) ;
event . preventDefault ( ) ;
}
break ;
case 'keydown' :
case 'keyup' :
//122 is 'toggle fullscreen'.
//we don't steal that because its impossible to leave it again once used.
if ( FTEC . evcb . key != 0 && event . keyCode != 122 )
{
if ( Runtime . dynCall ( 'iiiii' , FTEC . evcb . key , [ 0 , event . type == 'keydown' , event . keyCode , 0 ] ) )
event . preventDefault ( ) ;
}
break ;
2014-09-02 06:01:03 +00:00
case 'touchstart' :
case 'touchend' :
case 'touchcancel' :
case 'touchleave' :
case 'touchmove' :
var touches = event . changedTouches ;
for ( var i = 0 ; i < touches . length ; i ++ )
{
var t = touches [ i ] ;
if ( FTEC . evcb . mouse )
Runtime . dynCall ( 'viidddd' , FTEC . evcb . mouse , [ t . identifier + 1 , true , t . pageX , t . pageY , 0 , Math . sqrt ( t . radiusX * t . radiusX + t . radiusY * t . radiusY ) ] ) ;
if ( FTEC . evcb . button )
{
if ( event . type == 'touchstart' )
Runtime . dynCall ( 'viii' , FTEC . evcb . button , [ t . identifier + 1 , 1 , 0 ] ) ;
else if ( event . type != 'touchmove' )
Runtime . dynCall ( 'viii' , FTEC . evcb . button , [ t . identifier + 1 , 0 , 0 ] ) ;
}
}
event . preventDefault ( ) ;
break ;
2014-09-08 23:47:19 +00:00
case 'dragenter' :
case 'dragover' :
event . stopPropagation ( ) ;
event . preventDefault ( ) ;
break ;
case 'drop' :
event . stopPropagation ( ) ;
event . preventDefault ( ) ;
var files = event . dataTransfer . files ;
for ( var i = 0 ; i < files . length ; i ++ )
{
var file = files [ i ] ;
var reader = new FileReader ( ) ;
reader . onload = function ( evt )
{
FTEC . loadurl ( file . name , evt . target . result ) ;
} ;
reader . readAsArrayBuffer ( file ) ;
}
break ;
2014-10-11 19:39:45 +00:00
case 'gamepadconnected' :
var gp = e . gamepad ;
if ( FTEH . gamepads === undefined )
FTEH . gamepads = [ ] ;
FTEH . gamepads [ gp . index ] = gp ;
console . log ( "Gamepad connected at index %d: %s. %d buttons, %d axes." , gp . index , gp . id , gp . buttons . length , gp . axes . length ) ;
break ;
case 'gamepaddisconnected' :
var gp = e . gamepad ;
delete FTEH . gamepads [ gp . index ] ;
if ( FTEC . evcb . jaxis ) //try and clear out the axis when released.
for ( var j = 0 ; j < 6 ; j += 1 )
Runtime . dynCall ( 'viid' , FTEC . evcb . jaxis , [ gp . index , j , 0 ] ) ;
if ( FTEC . evcb . jbutton ) //try and clear out the axis when released.
for ( var j = 0 ; j < 32 + 4 ; j += 1 )
Runtime . dynCall ( 'viid' , FTEC . evcb . jbutton , [ gp . index , j , 0 ] ) ;
console . log ( "Gamepad disconnected from index %d: %s" , gp . index , gp . id ) ;
break ;
2013-12-19 18:41:57 +00:00
default :
console . log ( event ) ;
2014-09-02 06:01:03 +00:00
break ;
2013-12-19 18:41:57 +00:00
}
}
} ,
2014-10-11 19:39:45 +00:00
emscriptenfte _polljoyevents : function ( be , ae )
{
//with events, we can do unplug stuff properly.
//otherwise hot unplug might be buggy.
var gamepads ;
if ( FTEH . gamepads !== undefined )
gamepads = FTEH . gamepads ;
else
gamepads = navigator . getGamepads ? navigator . getGamepads ( ) : ( navigator . webkitGetGamepads ? navigator . webkitGetGamepads : [ ] ) ;
if ( gamepads !== undefined )
for ( var i = 0 ; i < gamepads . length ; i += 1 )
{
var gp = gamepads [ i ] ;
if ( gp === undefined )
continue ;
for ( var j = 0 ; j < gp . buttons . length ; j += 1 )
{
var b = gp . buttons [ j ] ;
var p ;
if ( typeof ( b ) == "object" )
{
p = b . pressed ;
if ( b . lastframe != p )
{ //cache it to avoid spam
b . lastframe = p ;
Runtime . dynCall ( 'viii' , FTEC . evcb . jbutton , [ gp . index , j , p ] ) ;
}
}
else
{ //old chrome bug
p = b == 1.0 ;
//warning: no cache. this is going to be spammy.
Runtime . dynCall ( 'viii' , FTEC . evcb . jbutton , [ gp . index , j , p ] ) ;
}
}
for ( var j = 0 ; j < gp . axes . length ; j += 1 )
Runtime . dynCall ( 'viid' , FTEC . evcb . jaxis , [ gp . index , j , gp . axes [ j ] ] ) ;
}
} ,
2014-09-08 23:47:19 +00:00
emscriptenfte _setupcanvas _ _deps : [ '$FTEC' , '$Browser' , 'emscriptenfte_buf_createfromarraybuf' ] ,
2014-10-11 19:39:45 +00:00
emscriptenfte _setupcanvas : function ( nw , nh , evresize , evmouse , evmbutton , evkey , evfile , evjbutton , evjaxis )
2013-12-19 18:41:57 +00:00
{
2014-10-11 19:39:45 +00:00
FTEC . evcb . resize = evresize ;
FTEC . evcb . mouse = evmouse ;
FTEC . evcb . button = evmbutton ;
FTEC . evcb . key = evkey ;
FTEC . evcb . loadfile = evfile ;
FTEC . evcb . jbutton = evjbutton ;
FTEC . evcb . jaxis = evjaxis ;
if ( 'GamepadEvent' in window )
FTEH . gamepads = [ ] ; //don't bother ever trying to poll if we can use gamepad events. this will hopefully avoid weirdness.
2013-12-19 18:41:57 +00:00
if ( ! FTEC . donecb )
{
FTEC . donecb = 1 ;
2014-10-11 19:39:45 +00:00
var events = [ 'mousedown' , 'mouseup' , 'mousemove' , 'wheel' , 'mousewheel' , 'mouseout' , 'keypress' , 'keydown' , 'keyup' , 'touchstart' , 'touchend' , 'touchcancel' , 'touchleave' , 'touchmove' , 'dragenter' , 'dragover' , 'drop' , 'gamepadconnected' , 'gamepaddisconnected' ] ;
2014-09-08 23:47:19 +00:00
events . forEach ( function ( event )
2013-12-19 18:41:57 +00:00
{
Module [ 'canvas' ] . addEventListener ( event , FTEC . handleevent , true ) ;
} ) ;
2014-09-08 23:47:19 +00:00
events . forEach ( function ( event )
2013-12-19 18:41:57 +00:00
{
document . addEventListener ( event , FTEC . handleevent , true ) ;
} ) ;
Browser . resizeListeners . push ( function ( w , h ) {
FTEC . handleevent ( {
type : 'resize' ,
} ) ;
} ) ;
}
2014-09-02 02:44:43 +00:00
if ( Module . print === undefined )
Module . print = function ( msg ) { console . log ( msg ) ; } ;
2014-09-08 23:47:19 +00:00
var ctx = Browser . createContext ( Module [ 'canvas' ] , true , true ) ;
2014-09-02 02:44:43 +00:00
if ( ctx == null )
{
var msg = "Unable to set up webgl context.\n\nPlease use a browser that supports it and has it enabled\nYour graphics drivers may also be blacklisted, so try updating those too. woo, might as well update your entire operating system while you're at it.\nIt'll be expensive, but hey, its YOUR money, not mine.\nYou can probably just disable the blacklist, but please don't moan at me when your computer blows up, seriously, make sure those drivers are not too buggy.\nI knew a guy once. True story. Boring, but true.\nYou're probably missing out on something right now. Don't you just hate it when that happens?\nMeh, its probably just tinkertoys, right?\n\nYou know, you could always try Internet Explorer, you never know, hell might have frozen over.\nDon't worry, I wasn't serious.\n\nTum te tum. Did you get it working yet?\nDude, fix it already.\n\nThis message was brought to you by Sleep Deprivation, sponsoring quake since I don't know when" ;
if ( FTEC . ctxwarned == 0 )
{
FTEC . ctxwarned = 1 ;
console . log ( msg ) ;
alert ( msg ) ;
}
2013-12-19 18:41:57 +00:00
return 0 ;
2014-09-02 02:44:43 +00:00
}
2014-08-27 08:41:31 +00:00
// Browser.setCanvasSize(nw, nh, false);
2013-12-19 18:41:57 +00:00
window . onresize = function ( )
{
//emscripten's browser library will revert sizes wrongly or something when we're fullscreen, so make sure that doesn't happen.
2014-08-27 08:41:31 +00:00
// if (Browser.isFullScreen)
// {
// Browser.windowedWidth = window.innerWidth;
// Browser.windowedHeight = window.innerHeight;
// }
// else
2013-12-19 18:41:57 +00:00
Browser . setCanvasSize ( window . innerWidth , window . innerHeight , false ) ;
2014-08-27 08:41:31 +00:00
if ( FTEC . evcb . resize != 0 )
Runtime . dynCall ( 'vii' , FTEC . evcb . resize , [ Module [ 'canvas' ] . width , Module [ 'canvas' ] . height ] ) ;
2013-12-19 18:41:57 +00:00
} ;
window . onresize ( ) ;
2014-08-27 08:41:31 +00:00
if ( FTEC . evcb . hashchange )
{
2014-09-08 23:47:19 +00:00
window . onhashchange = function ( )
2014-08-27 08:41:31 +00:00
{
2014-09-08 23:47:19 +00:00
FTEC . loadurl ( location . hash . substring ( 1 ) ) ;
} ;
}
2014-08-27 08:41:31 +00:00
2013-12-19 18:41:57 +00:00
return 1 ;
} ,
2014-10-11 19:39:45 +00:00
emscriptenfte _settitle : function ( txt )
{
document . title = Pointer _stringify ( txt ) ;
} ,
2013-12-19 18:41:57 +00:00
emscriptenfte _abortmainloop : function ( msg )
{
msg = Pointer _stringify ( msg ) ;
throw 'oh noes! something bad happened in ' + msg + '!' ;
} ,
emscriptenfte _ticks _ms : function ( )
{
return Date . now ( ) ;
} ,
emscriptenfte _buf _create _ _deps : [ 'emscriptenfte_handle_alloc' ] ,
emscriptenfte _buf _create : function ( )
{
var b = { h : - 1 , r : 1 , l : 0 , m : 4096 , d : new Uint8Array ( 4096 ) , n : null } ;
b . h = _emscriptenfte _handle _alloc ( b ) ;
return b . h ;
} ,
2014-08-27 08:41:31 +00:00
//filesystem emulation
2013-12-19 18:41:57 +00:00
emscriptenfte _buf _open _ _deps : [ 'emscriptenfte_buf_create' ] ,
emscriptenfte _buf _open : function ( name , createifneeded )
{
name = Pointer _stringify ( name ) ;
var f = FTEH . f [ name ] ;
var r = - 1 ;
if ( f == null )
{
2014-08-27 08:41:31 +00:00
if ( window . localStorage && createifneeded != 2 )
{
var str = window . localStorage . getItem ( name ) ;
if ( str != null )
{
2014-09-02 02:44:43 +00:00
// console.log('read file '+name+': ' + str);
2014-08-27 08:41:31 +00:00
var len = str . length ;
var buf = new Uint8Array ( len ) ;
for ( var i = 0 ; i < len ; i ++ )
buf [ i ] = str . charCodeAt ( i ) ;
var b = { h : - 1 , r : 2 , l : len , m : len , d : buf , n : name } ;
r = b . h = _emscriptenfte _handle _alloc ( b ) ;
FTEH . f [ name ] = b ;
return b . h ;
}
}
2013-12-19 18:41:57 +00:00
if ( createifneeded )
r = _emscriptenfte _buf _create ( ) ;
if ( r != - 1 )
{
f = FTEH . h [ r ] ;
f . r += 1 ;
f . n = name ;
FTEH . f [ name ] = f ;
if ( FTEH . f [ name ] != f || f . n != name )
console . log ( 'error creating file ' + name ) ;
}
}
else
{
f . r += 1 ;
r = f . h ;
}
2014-08-27 08:41:31 +00:00
if ( f != null && createifneeded == 2 )
f . l = 0 ; //truncate it.
2013-12-19 18:41:57 +00:00
return r ;
} ,
emscriptenfte _buf _rename : function ( oldname , newname )
{
oldname = Pointer _stringify ( oldname ) ;
newname = Pointer _stringify ( newname ) ;
var f = FTEH . f [ oldname ] ;
if ( f == null )
return 0 ;
if ( FTEH . f [ newname ] != null )
return 0 ;
FTEH . f [ newname ] = f ;
delete FTEH . f [ oldname ] ;
f . n = newname ;
return 1 ;
} ,
emscriptenfte _buf _delete : function ( name )
{
name = Pointer _stringify ( name ) ;
var f = FTEH . f [ name ] ;
if ( f )
{
delete FTEH . f [ name ] ;
f . n = null ;
emscriptenfte _buf _release ( f . h ) ;
return 1 ;
}
return 0 ;
} ,
2014-08-27 08:41:31 +00:00
emscriptenfte _buf _pushtolocalstore : function ( handle )
{
var b = FTEH . h [ handle ] ;
if ( b == null )
{
Module . printError ( 'emscriptenfte_buf_pushtolocalstore with invalid handle' ) ;
return ;
}
if ( b . n == null )
return ;
var data = b . d ;
var len = b . l ;
if ( window . localStorage )
{
var foo = "" ;
//use a divide and conquer implementation instead for speed?
for ( var i = 0 ; i < len ; i ++ )
foo += String . fromCharCode ( data [ i ] ) ;
window . localStorage . setItem ( b . n , foo ) ;
}
else
console . log ( 'local storage not supported' ) ;
} ,
2013-12-19 18:41:57 +00:00
emscriptenfte _buf _release : function ( handle )
{
var b = FTEH . h [ handle ] ;
if ( b == null )
{
Module . printError ( 'emscriptenfte_buf_release with invalid handle' ) ;
return ;
}
b . r -= 1 ;
if ( b . r == 0 )
{
if ( b . n != null )
delete FTEH . f [ b . n ] ;
delete FTEH . h [ handle ] ;
b . d = null ;
}
} ,
emscriptenfte _buf _getsize : function ( handle )
{
var b = FTEH . h [ handle ] ;
return b . l ;
} ,
emscriptenfte _buf _read : function ( handle , offset , data , len )
{
var b = FTEH . h [ handle ] ;
if ( offset + len > b . l ) //clamp the read
len = b . l - offset ;
if ( len < 0 )
{
len = 0 ;
if ( offset + len >= b . l )
return - 1 ;
}
HEAPU8 . set ( b . d . subarray ( offset , offset + len ) , data ) ;
return len ;
} ,
emscriptenfte _buf _write : function ( handle , offset , data , len )
{
var b = FTEH . h [ handle ] ;
2014-08-25 07:35:41 +00:00
if ( len < 0 )
len = 0 ;
2013-12-19 18:41:57 +00:00
if ( offset + len > b . m )
{ //extend it if needed.
b . m = offset + len + 4095 ;
b . m = b . m & ~ 4095 ;
var nd = new Uint8Array ( b . m ) ;
nd . set ( b . d , 0 ) ;
b . d = nd ;
}
b . d . set ( HEAPU8 . subarray ( data , data + len ) , offset ) ;
if ( offset + len > b . l )
b . l = offset + len ;
return len ;
} ,
emscriptenfte _ws _connect _ _deps : [ 'emscriptenfte_handle_alloc' ] ,
emscriptenfte _ws _connect : function ( url )
{
var _url = Pointer _stringify ( url ) ;
var s = { ws : null , inq : [ ] , err : 0 } ;
s . ws = new WebSocket ( _url , 'binary' ) ;
if ( ! s . ws )
return - 1 ;
s . ws . onerror = function ( event ) { s . err = 1 ; } ;
s . ws . onclose = function ( event ) { s . err = 1 ; } ;
// s.ws.onopen = function(event) {};
s . ws . onmessage = function ( event )
{
assert ( typeof event . data !== 'string' && event . data . byteLength ) ;
s . inq . push ( new Uint8Array ( event . data ) ) ;
} ;
return _emscriptenfte _handle _alloc ( s ) ;
} ,
emscriptenfte _ws _close : function ( sockid )
{
var s = FTEH . h [ sockid ] ;
if ( ! s )
return - 1 ;
s . ws . close ( ) ;
s . ws = null ; //make sure to avoid circular references
delete FTEH . h [ sockid ] ; //socked is no longer accessible.
return 0 ;
} ,
//separate call allows for more sane flood control when fragmentation is involved.
emscriptenfte _ws _cansend : function ( sockid , extra , maxpending )
{
var s = FTEH . h [ sockid ] ;
if ( ! s )
return 1 ; //go on punk, make my day.
return ( ( s . ws . bufferedAmount + extra ) < maxpending ) ;
} ,
emscriptenfte _ws _send : function ( sockid , data , len )
{
var s = FTEH . h [ sockid ] ;
if ( ! s )
return - 1 ;
s . s . send ( HEAPU8 . subarray ( data , data + len ) . buffer ) ;
return len ;
} ,
emscriptenfte _ws _recv : function ( sockid , data , len )
{
var s = FTEH . h [ sockid ] ;
if ( ! s )
return - 1 ;
var inp = s . inq . shift ( ) ;
if ( inp )
{
if ( inp . length > len )
inp . length = len ;
HEAPU8 . set ( inp , data ) ;
return inp . length ;
}
if ( s . err )
return 0 ;
return - 1 ;
} ,
emscriptenfte _async _wget _data2 : function ( url , ctx , onload , onerror , onprogress )
{
var _url = Pointer _stringify ( url ) ;
console . log ( "Attempting download of " + _url ) ;
var http = new XMLHttpRequest ( ) ;
http . open ( 'GET' , _url , true ) ;
http . responseType = 'arraybuffer' ;
http . onload = function ( e )
{
2014-09-08 23:47:19 +00:00
console . log ( "onload: " + _url + " status " + http . status ) ;
2013-12-19 18:41:57 +00:00
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 )
{
2014-09-08 23:47:19 +00:00
console . log ( "onerror: " + _url + " status " + http . status ) ;
2013-12-19 18:41:57 +00:00
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 ) ;
}
} ) ;