Skip to content

Commit

Permalink
Merge pull request dsrao711#6 from YogeshUpdhyay/main
Browse files Browse the repository at this point in the history
js updated
  • Loading branch information
YogeshUpdhyay authored May 29, 2021
2 parents 84d3ef3 + 4c1a368 commit 28c8c31
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,16 @@ function onMessageSend() {
msg: msg
}
console.log(data);

var ele = document.getElementById("messages")
if (ele.innerHTML == "") {
ele.innerHTML = `<div class="flex justify-end">
${data.msg}
</div>`
} else {
ele.innerHTML = `${ele.innerHTML}<div class="flex justify-end">
${data.msg}
</div>`
}
socket.emit("message", data)
}
7 changes: 6 additions & 1 deletion app/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
<tbody>
{% for friend in friends -%}
<tr>
<th scope="row" onclick=chatapp("{{ friend.username }}")>{{friend.username}}</th>
<th scope="row" onclick=chatapp("{{friend.username}}")>
{{ friend.username | string }}
</th>
</tr>
{% endfor %}
</tbody>
Expand All @@ -43,6 +45,9 @@
<div class="card border-primary mb-3" style="max-width: 100% ; height : 80vh">
<div class="card-header" id="chat-header">Friend</div>
<div class="card-body" style="position: absolute ; bottom : 10px ;width : 100%">
<div class="mb-3" id="messages">

</div>
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="Type.." id="message" style="max-width : 100%">
<div class="input-group-append">
Expand Down

0 comments on commit 28c8c31

Please sign in to comment.