src/analytics.js
// The callback is always called.
The callback is always called.
The callback is always called .
function startGame(callback, context) {
	if (!endpoint || !playerKey) {
		callback.call(context, null);
		return;
	}
	var xhr = new XMLHttpRequest();
	xhr.open('POST', endpoint + 'game', true);
	xhr.timeout = 15 * 1000;
	xhr.onreadystatechange = function() {
		if (xhr.readyState !== 4) {
			return;
		}
		var key;
		if (xhr.status == 200) {
			var data;
			try {
				data = JSON.parse(xhr.responseText);
				key = data.Game;
			} catch (e) {
			}
		}
		if (typeof key != 'string') {
			key = null;
			fail();
		}
		callback.call(context, key);
	};
	xhr.setRequestHeader('Content-Type', 'application/json');
	xhr.send(JSON.stringify({
		Player: playerKey,
	}));
}
function startGame ( callback , context ) { if ( ! endpoint || ! playerKey ) { callback . call ( context , null ) ; return ; } var xhr = new XMLHttpRequest ( ) ; xhr . open ( 'POST' , endpoint + 'game' , true ) ; xhr . timeout = 15 * 1000 ; xhr . onreadystatechange = function ( ) { if ( xhr . readyState !== 4 ) { return ; } var key ; if ( xhr . status == 200 ) { var data ; try { data = JSON . parse ( xhr . responseText ) ; key = data . Game ; } catch ( e ) { } } if ( typeof key != 'string' ) { key = null ; fail ( ) ; } callback . call ( context , key ) ; } ; xhr . setRequestHeader ( 'Content-Type' , 'application/json' ) ; xhr . send ( JSON . stringify ( { Player : playerKey , } ) ) ; }
The callback is always called.
The callback is always called .