From ed3853c5eac1eadedbcaa086b36d8a6c9ab486ea Mon Sep 17 00:00:00 2001 From: Rohan Sircar Date: Wed, 6 Nov 2019 10:31:48 +0530 Subject: [PATCH] changed to queryselector to extract username and date and last message fields in userbox --- chatto/src/main/resources/static/js/chat.js | 11 ++++++++++- chatto/src/main/resources/templates/chat.html | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/chatto/src/main/resources/static/js/chat.js b/chatto/src/main/resources/static/js/chat.js index d6cdaec..e1f3d9e 100644 --- a/chatto/src/main/resources/static/js/chat.js +++ b/chatto/src/main/resources/static/js/chat.js @@ -66,11 +66,20 @@ for (let i = 0; i < userBoxes.length; i++) { } let words = this.innerText.split("\n"); // console.log(words); - document.getElementById('user-name-span').innerText = 'Chat with ' + words[1]; + // let children = this.children; + // let userName = children[0].innerText; + let userName = this.querySelectorAll('span')[1].innerText; + document.getElementById('user-name-span').innerText = userName; + populateMessages(userName); this.className += " active"; }) } +function populateMessages(userName) +{ + console.log(userName); +} + // var lastMessageTimeStamp; // console.log(authToken); diff --git a/chatto/src/main/resources/templates/chat.html b/chatto/src/main/resources/templates/chat.html index a6cb09e..3d1c176 100644 --- a/chatto/src/main/resources/templates/chat.html +++ b/chatto/src/main/resources/templates/chat.html @@ -82,7 +82,12 @@ Khalid

Kalid is online

+
+
Dec 25
+
Hello how are you
+
+