diff --git a/chat.js b/chat.js index 9c17f1e..6aeeeda 100644 --- a/chat.js +++ b/chat.js @@ -1,10 +1,17 @@ -chatArr=[] - -function chat(message, peer){ - chatArr.push(peer+": "+message) - chathtml = "" - chatArr.forEach(element => { - chathtml=chathtml+element+"" - }) - document.getElementById("chat").innerHTML = chathtml +chatArr = [] + +function chat(message, peer) { + chatArr.push(peer + ": " + message) + //message=encodeURI(message) + messageDiv = document.createElement("div") + text = document.createTextNode(chatArr[chatArr.length - 1]) + messageDiv.appendChild(text) + + // chatArr.forEach(element => { + // chathtml = chathtml + element + "" + + // }) + //document.getElementById("chat" + (chatArr.length)).innerHTML = chathtml + + document.getElementById("chatWrapper").appendChild(messageDiv) } \ No newline at end of file diff --git a/inbound.js b/inbound.js index 3d1555d..b9a9647 100644 --- a/inbound.js +++ b/inbound.js @@ -3,7 +3,6 @@ peer.on('connection', function(conn) { console.log(conn.peer+" has connected to me") conn.on('open', function() { peerlist[conn.peer]=conn - console.log(peerlist) // Receive messages conn.on('data', function(data) { handleData(conn,data,"Their Connection") diff --git a/index.html b/index.html index 8930650..a8c8cb0 100644 --- a/index.html +++ b/index.html @@ -4,22 +4,30 @@ +
- Hello Dan boys - + Your ID is: