<commit_before><DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title> Chat </title>
	<link href="css/styledoc.css" rel="stylesheet" type="text/css"/>
	<script language="JavaScript" type="text/javascript" src="js/jquery-3.1.1.js"></script>

</head>

<body>
	<div>
		<h1> Chat App </h1>
	</div>
	<div style="position: absolute; bottom: 30px; width: 90%; height: 400px; ">
		<div align="center" width="350px" height="100%">
			<table>
				<tr >
					<td width="350px"; height="400px"; >
						<div id="log"></div>
						<input type="text" placeholder="Type your msg here .." id="msgtext" width="100%"/>
						<br />
						<button>Send</button>
					</td>
				</tr>
			</table>
		</div>
	</div>
	
	
	<script>
		function sleepMillis(miliseconds) {
		   var currentTime = new Date().getTime();
		   while (currentTime + miliseconds >= new Date().getTime()) {
		   }
		}

		var AccountName = "";
		
		function getSessionName() {
			getRequest(
				'conf.php', // URL for the PHP file
				drawOutput,  // handle successful request
				drawError    // handle error
			);
			return false;
		}
		
		// handles drawing an error message
		function drawError() {
			log.innerHTML += ("<div style=\"display: inline;  width: 180px; overflow-y: auto; border-radius: 15px; float: left;  background: yellow; padding: 7px; border: solid 1px black;\"> <span style=\"color: red;\">"+ "Warning" +": "+ "<span style=\"color: blue;\"> "+ "You must login first" + "</span></div><br/><br/>");
		}
		
		// handles the response, adds the html
		function drawOutput(responseText) {
			//log.innerHTML += ("<div style=\"display: inline;  width: 180px; overflow-y: auto; border-radius: 15px; float: left;  background: yellow; padding: 7px; border: solid 1px black;\"> <span style=\"color: red;\">"+ "Self" +": "+ "<span style=\"color: blue;\"> "+ responseText + "</span></div><br/><br/>");
			AccountName = responseText;
		}
		
		// helper function for cross-browser request object
		function getRequest(url, success, error) {
			var req = false;
			try{
				// most browsers
				req = new XMLHttpRequest();
			} catch (e){
				// IE
				try{
					req = new ActiveXObject("Msxml2.XMLHTTP");
				} catch(e) {
					// try an older version
					try{
						req = new ActiveXObject("Microsoft.XMLHTTP");
					} catch(e) {
						return false;
					}
				}
			}
			if (!req) return false;
			if (typeof success != 'function') success = function () {};
			if (typeof error!= 'function') error = function () {};
			req.onreadystatechange = function(){
				if(req.readyState == 4) {
					return req.status === 200 ? 
						success(req.responseText) : error(req.status);
				}
			}
			req.open("GET", url, true);
			req.send(null);
			return req;
		}

		getSessionName();
		var sock;
		var log = document.getElementById('log');
		var friendname = "";
		sleepMillis(100);
		var UserName = "X";
		sock = new WebSocket("ws://192.168.1.6:5001");
		
		sock.onopen = function(){
			if(AccountName != ""){
				UserName = AccountName;
				friendname = prompt('what is your friend username ?');
				sock.send(JSON.stringify({
					type: "open_chat",
					fromname: AccountName.trim(),
					toname: friendname
				}));
			}else{
				window.location.replace("../home/login.php");
			}
		}
		
		sock.onmessage = function(event){
			console.log(event);
			var json = JSON.parse(event.data);
			if(json.name=="You"){
				log.innerHTML += ("<div style=\"display: inline; word-wrap: break-word; width: 180px; overflow-y: auto; border-radius: 15px; float: right; background: white; padding: 7px; border: solid 1px black;\"> <span style=\"color: red;\">"+ json.name +": "+ "<span style=\"color: blue;\"> "+json.data + "</span></div><br/><br/>");
			}else{
				log.innerHTML += ("<div style=\"display: inline; word-wrap: break-word; width: 180px; overflow-y: auto; border-radius: 15px; float: left;  background: yellow; padding: 7px; border: solid 1px black;\"> <span style=\"color: red;\">"+ json.name +": "+ "<span style=\"color: blue;\"> "+json.data + "</span></div><br/><br/>");
			}<commit_msg>updating ip address<commit_after><DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title> Chat </title>
	<link href="css/styledoc.css" rel="stylesheet" type="text/css"/>
	<script language="JavaScript" type="text/javascript" src="js/jquery-3.1.1.js"></script>

</head>

<body>
	<div>
		<h1> Chat App </h1>
	</div>
	<div style="position: absolute; bottom: 30px; width: 90%; height: 400px; ">
		<div align="center" width="350px" height="100%">
			<table>
				<tr >
					<td width="350px"; height="400px"; >
						<div id="log"></div>
						<input type="text" placeholder="Type your msg here .." id="msgtext" width="100%"/>
						<br />
						<button>Send</button>
					</td>
				</tr>
			</table>
		</div>
	</div>
	
	
	<script>
		function sleepMillis(miliseconds) {
		   var currentTime = new Date().getTime();
		   while (currentTime + miliseconds >= new Date().getTime()) {
		   }
		}

		var AccountName = "";
		
		function getSessionName() {
			getRequest(
				'conf.php', // URL for the PHP file
				drawOutput,  // handle successful request
				drawError    // handle error
			);
			return false;
		}
		
		// handles drawing an error message
		function drawError() {
			log.innerHTML += ("<div style=\"display: inline;  width: 180px; overflow-y: auto; border-radius: 15px; float: left;  background: yellow; padding: 7px; border: solid 1px black;\"> <span style=\"color: red;\">"+ "Warning" +": "+ "<span style=\"color: blue;\"> "+ "You must login first" + "</span></div><br/><br/>");
		}
		
		// handles the response, adds the html
		function drawOutput(responseText) {
			//log.innerHTML += ("<div style=\"display: inline;  width: 180px; overflow-y: auto; border-radius: 15px; float: left;  background: yellow; padding: 7px; border: solid 1px black;\"> <span style=\"color: red;\">"+ "Self" +": "+ "<span style=\"color: blue;\"> "+ responseText + "</span></div><br/><br/>");
			AccountName = responseText;
		}
		
		// helper function for cross-browser request object
		function getRequest(url, success, error) {
			var req = false;
			try{
				// most browsers
				req = new XMLHttpRequest();
			} catch (e){
				// IE
				try{
					req = new ActiveXObject("Msxml2.XMLHTTP");
				} catch(e) {
					// try an older version
					try{
						req = new ActiveXObject("Microsoft.XMLHTTP");
					} catch(e) {
						return false;
					}
				}
			}
			if (!req) return false;
			if (typeof success != 'function') success = function () {};
			if (typeof error!= 'function') error = function () {};
			req.onreadystatechange = function(){
				if(req.readyState == 4) {
					return req.status === 200 ? 
						success(req.responseText) : error(req.status);
				}
			}
			req.open("GET", url, true);
			req.send(null);
			return req;
		}

		getSessionName();
		var sock;
		var log = document.getElementById('log');
		var friendname = "";
		sleepMillis(100);
		var UserName = "X";
		sock = new WebSocket("ws://192.168.43.169:5001");
		
		sock.onopen = function(){
			if(AccountName != ""){
				UserName = AccountName;
				friendname = prompt('what is your friend username ?');
				sock.send(JSON.stringify({
					type: "open_chat",
					fromname: AccountName.trim(),
					toname: friendname
				}));
			}else{
				window.location.replace("../home/login.php");
			}
		}
		
		sock.onmessage = function(event){
			console.log(event);
			var json = JSON.parse(event.data);
			if(json.name=="You"){
				log.innerHTML += ("<div style=\"display: inline; word-wrap: break-word; width: 180px; overflow-y: auto; border-radius: 15px; float: right; background: white; padding: 7px; border: solid 1px black;\"> <span style=\"color: red;\">"+ json.name +": "+ "<span style=\"color: blue;\"> "+json.data + "</span></div><br/><br/>");
			}else{
				log.innerHTML += ("<div style=\"display: inline; word-wrap: break-word; width: 180px; overflow-y: auto; border-radius: 15px; float: left;  background: yellow; padding: 7px; border: solid 1px black;\"> <span style=\"color: red;\">"+ json.name +": "+ "<span style=\"color: blue;\"> "+json.data + "</span></div><br/><br/>");
			}
{'fraction_non_alphanumeric': 0.19292842183072564, 'fraction_numerical': 0.01909572502155969, 'mean_word_length': 3.2391644908616186, 'pattern_counts': {'":': 8, '<': 123, '<?xml version=': 0, '>': 125, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 2, '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': '1840168', 'n_tokens_mistral': 3271, 'n_tokens_neox': 2638, 'n_words': 692}