<commit_before>var api = {};


function findGames (latitude, longitude) { 
	var data = [];
	
	var xhr = Titanium.Network.createHTTPClient();
	xhr.open('POST','http://ctf.playamericalive.com/form.php');
	
	xhr.send({
		action:'findGames',
		latitude: latitude,
		longitude: longitude
	});
	
	xhr.onload = function(e) {
		var xml = this.responseXML;
		var games = xml.documentElement.getElementsByTagName("game");
			
		for (var i = 0; i < games.length; i++) {
	    	data.push({
	    		gameID: games.item(i).getElementsByTagName("gameID").item(0).text,
	    		accessCode: games.item(i).getElementsByTagName("accessCode").item(0).text,
	    		initiatorID: games.item(i).getElementsByTagName("initiatorID").item(0).text,
	    		gameName: games.item(i).getElementsByTagName("gameName").item(0).text,
	    		gameLatitude: games.item(i).getElementsByTagName("gameLatitude").item(0).text,
	    		gameLongitude: games.item(i).getElementsByTagName("gameLongitude").item(0).text,
	    		flagsPlaced: games.item(i).getElementsByTagName("flagsPlaced").item(0).text,
	    		gameStatus: games.item(i).getElementsByTagName("gameStatus").item(0).text,
	    	}); 	
		}
	 	Ti.App.fireEvent('findGames', {data:data});
	}
}


/*------------------------------------------------------------------------------------------*/


function gamePlayers (gameID) { 
	var data = [];
	
	var xhr = Titanium.Network.createHTTPClient();
	xhr.open('POST','http://ctf.playamericalive.com/form.php');
	
	xhr.send({
		action:'gamePlayers',
		gameID:gameID
	});
	
	xhr.onload = function(e) {
		var xml = this.responseXML;
	  		
		var games = xml.documentElement.getElementsByTagName("player");
			
		for (var i = 0; i < player.length; i++) {	
	    	data.push({
	    		userName: games.item(i).getElementsByTagName("userName").item(0).text,
	    		playerID: games.item(i).getElementsByTagName("playerID").item(0).text,
	    	}); 	
		}	
	 	Ti.App.fireEvent('gamePlayers', {data:data});
	}
}

/*------------------------------------------------------------------------------------------*/

// returns "true" or "false"
function joinGame (gameID, userID, userName) { 
	var data = [];
	
	var xhr = Titanium.Network.createHTTPClient();
	xhr.open('POST','http://ctf.playamericalive.com/form.php');
	
	xhr.send({
		action:'joinGame',
		userID: userID,
		userName: userName
	});
	
	xhr.onload = function(e) {
	 	Ti.App.fireEvent('joinGame', {data:this.responseText});
	}
}


/*------------------------------------------------------------------------------------------*/

function gameInitiator (gameID) { 
	var data = [];
	
	var xhr = Titanium.Network.createHTTPClient();
	xhr.open('POST','http://ctf.playamericalive.com/form.php');
	
	xhr.send({
		action:'gameInitiator',
		gameID:gameID
	});
	xhr.onload = function(e) {	
	 	Ti.App.fireEvent('gameInitiator', {data:this.responseText});
	}
}

/*------------------------------------------------------------------------------------------*/

function gameStatus (gameID) { 
	var data = [];
	
	var xhr = Titanium.Network.createHTTPClient();
	xhr.open('POST','http://ctf.playamericalive.com/form.php');
	
	xhr.send({
		action: 'gameStatus',
		gameID: gameID
	});
	xhr.onload = function(e) {	
	 	Ti.App.fireEvent('gameStatus', {data:this.responseText});
	}
}

/*------------------------------------------------------------------------------------------*/


function startGame (gameID) { 
	var data = [];
	
	var xhr = Titanium.Network.createHTTPClient();
	xhr.open('POST','http://ctf.playamericalive.com/form.php');
	
	xhr.send({
		action: 'startGame',
		gameID: gameID
	});
	
	xhr.onload = function(e) {
		var xml = this.responseXML;
	  		
		var games = xml.documentElement.getElementsByTagName("player");
			
		for (var i = 0; i < player.length; i++) {	
	    	data.push({
	    		userName: games.item(i).getElementsByTagName("userName").item(0).text,
	    		playerID: games.item(i).getElementsByTagName("playerID").item(0).text,
	    		teamID: games.item(i).getElementsByTagName("teamID").item(0).text,
	    	}); 	
		}	
	 	Ti.App.fireEvent('gamePlayers', {data:data});
	}
}


/*------------------------------------------------------------------------------------------*/






/*------------------------------------------------------------------------------------------*/

// add methods
api.gamePlayers = gamePlayers;
api.findGames = findGames;
api.joinGame = joinGame;
api.gameStatus = gameStatus;
api.startGame = startGame;

//public interface
exports.api = api;

<commit_msg>new functions and comments<commit_after>var api = {};

/*------------------------------------------------------------------------------------------*/

// Return Value:
// array of information about all games within 10 mile radius
function findGames (latitude, longitude) { 
	var data = [];
	
	var xhr = Titanium.Network.createHTTPClient();
	xhr.open('POST','http://ctf.playamericalive.com/form.php');
	
	xhr.send({
		action:'findGames',
		latitude: latitude,
		longitude: longitude
	});
	
	xhr.onload = function(e) {
		var xml = this.responseXML;
		var games = xml.documentElement.getElementsByTagName("game");
			
		for (var i = 0; i < games.length; i++) {
	    	data.push({
	    		gameID: games.item(i).getElementsByTagName("gameID").item(0).text,
	    		accessCode: games.item(i).getElementsByTagName("accessCode").item(0).text,
	    		initiatorID: games.item(i).getElementsByTagName("initiatorID").item(0).text,
	    		gameName: games.item(i).getElementsByTagName("gameName").item(0).text,
	    		gameLatitude: games.item(i).getElementsByTagName("gameLatitude").item(0).text,
	    		gameLongitude: games.item(i).getElementsByTagName("gameLongitude").item(0).text,
	    		flagsPlaced: games.item(i).getElementsByTagName("flagsPlaced").item(0).text,
	    		gameStatus: games.item(i).getElementsByTagName("gameStatus").item(0).text,
	    	}); 	
		}
	 	Ti.App.fireEvent('findGames', {data:data});
	}
}


/*------------------------------------------------------------------------------------------*/

// Return Value:
// xml data of player’s name and ID number
function gamePlayers (gameID) { 
	var data = [];
	
	var xhr = Titanium.Network.createHTTPClient();
	xhr.open('POST','http://ctf.playamericalive.com/form.php');
	
	xhr.send({
		action:'gamePlayers',
		gameID:gameID
	});
	
	xhr.onload = function(e) {
		var xml = this.responseXML;
	  		
		var games = xml.documentElement.getElementsByTagName("player");
			
		for (var i = 0; i < player.length; i++) {	
	    	data.push({
	    		userName: games.item(i).getElementsByTagName("userName").item(0).text,
	    		playerID: games.item(i).getElementsByTagName("playerID").item(0).text,
	    	}); 	
		}	
	 	Ti.App.fireEvent('gamePlayers', {data:data});
	}
}

/*------------------------------------------------------------------------------------------*/

// Return Value
// "true" or "false" depending on if the operation occurred successfully
function joinGame (gameID, userID, userName) { 
	var data = [];
	
	var xhr = Titanium.Network.createHTTPClient();
	xhr.open('POST','http://ctf.playamericalive.com/form.php');
	
	xhr.send({
		action:'joinGame',
		userID: userID,
		userName: userName
	});
	
	xhr.onload = function(e) {
	 	Ti.App.fireEvent('joinGame', {data:this.responseText});
	}
}


/*------------------------------------------------------------------------------------------*/

// Return Value:
// The ID of the Player who initiated the Game if Game exists, and 'false' if Game does not exist
function gameInitiator (gameID) { 
	var data = [];
	
	var xhr = Titanium.Network.createHTTPClient();
	xhr.open('POST','http://ctf.playamericalive.com/form.php');
	
	xhr.send({
		action:'gameInitiator',
		gameID:gameID
	});
	xhr.onload = function(e) {	
	 	Ti.App.fireEvent('gameInitiator', {data:this.responseText});
	}
}

/*------------------------------------------------------------------------------------------*/

// Return Value:
// An integer that denotes the current game status, 0 if not started, 1 if started
function gameStatus (gameID) { 
	var data = [];
	
	var xhr = Titanium.Network.createHTTPClient();
	xhr.open('POST','http://ctf.playamericalive.com/form.php');
	
	xhr.send({
		action: 'gameStatus',
		gameID: gameID
	});
	xhr.onload = function(e) {	
	 	Ti.App.fireEvent('gameStatus', {data:this.responseText});
	}
}

/*------------------------------------------------------------------------------------------*/

// Return Value:
// array of information about all the players in the Game
function startGame (gameID) { 
	var data = [];
	
	var xhr = Titanium.Network.createHTTPClient();
	xhr.open('POST','http://ctf.playamericalive.com/form.php');
	
	xhr.send({
		action: 'startGame',
		gameID: gameID
	});
	
	xhr.onload = function(e) {
		var xml = this.responseXML;
	  		
		var games = xml.documentElement.getElementsByTagName("player");
			
		for (var i = 0; i < player.length; i++) {	
	    	data.push({
	    		userName: games.item(i).getElementsByTagName("userName").item(0).text,
	    		playerID: games.item(i).getElementsByTagName("playerID").item(0).text,
	    		teamID: games.item(i).getElementsByTagName("teamID").item(0).text,
	    	}); 	
		}	
	 	Ti.App.fireEvent('gamePlayers', {data:data});
	}
}


/*------------------------------------------------------------------------------------------*/

// Return Value:
// the gameID of the newly created Game
function createGame (playerID, gameName, userName, latitude, longitude) { 
	var data = [];
	
	var xhr = Titanium.Network.createHTTPClient();
	xhr.open('POST','http://ctf.playamericalive.com/form.php');
	
	xhr.send({
		action: 'createGame',
		playerID: playerID,
		gameName: gameName,
		userName: userName,
		latitude: latitude,
		longitude: longitude
	});
	xhr.onload = function(e) {	
	 	Ti.App.fireEvent('createGame', {data:this.responseText});
	}
}

/*------------------------------------------------------------------------------------------*/

// Return Value:
// The ID of the Player who initiated the Game if Game exists, and 'false' if Game does not exist
function gameInitator (gameID) {
	
	var xhr = Titanium.Network.createHTTPClient();
	xhr.open('POST','http://ctf.playamericalive.com/form.php');
	
	xhr.send({
		action: 'gameInitiator'
	});
	xhr.onload = function(e) {	
	 	Ti.App.fireEvent('gameInitiator', {data:this.responseText});
	}
}


/*------------------------------------------------------------------------------------------*/

// Return Value:
// An integer that denotes the current game status, 0 if not started, 1 if started
function flagsPlaced (gameID) {
	
	var xhr = Titanium.Network.createHTTPClient();
	xhr.open('POST','http://ctf.playamericalive.com/form.php');
	
	xhr.send({
		action: 'flagsPlaced'
	});
	xhr.onload = function(e) {	
	 	Ti.App.fireEvent('flagsPlaced', {data:this.responseText});
	}
}

/*------------------------------------------------------------------------------------------*/

// Return Value:
// xml array of locations if other players found or “false” if no results found
function getLocations (gameID, playerID, latitude, longitude) { 
	var data = [];
	
	var xhr = Titanium.Network.createHTTPClient();
	xhr.open('POST','http://ctf.playamericalive.com/form.php');
	
	xhr.send({
		action: 'startGame',
		gameID: gameID,
		playerID: playerID,
		latitude: latitude,
		longitude: longitude,
	});
	
	xhr.onload = function(e) {
		var xml = this.responseXML;
	  		
		var games = xml.documentElement.getElementsByTagName("player");
			
		for (var i = 0; i < player.length; i++) {	
	    	data.push({
	    		userName: games.item(i).getElementsByTagName("userName").item(0).text,
	    		playerID: games.item(i).getElementsByTagName("playerID").item(0).text,
	    		teamID: games.item(i).getElementsByTagName("teamID").item(0).text,
	    	}); 	
		}	
	 	Ti.App.fireEvent('gamePlayers', {data:data});
	}
}

/*------------------------------------------------------------------------------------------*/



/*------------------------------------------------------------------------------------------*/



/*------------------------------------------------------------------------------------------*/



/*------------------------------------------------------------------------------------------*/






/*------------------------------------------------------------------------------------------*/

// add methods
api.gamePlayers = gamePlayers;
api.findGames = findGames;
api.joinGame = joinGame;
api.gameStatus = gameStatus;
api.startGame = startGame;
api.createGame = createGame;


//public interface
exports.api = api;


{'fraction_non_alphanumeric': 0.3021109238301629, 'fraction_numerical': 0.0033710570671803513, 'mean_word_length': 1.968787228973076, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 16}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3678571', 'n_tokens_mistral': 4169, 'n_tokens_neox': 3780, 'n_words': 651}