FumesAI
commited on
Commit
•
73e13d9
1
Parent(s):
df4aaf4
Update index.html
Browse files- index.html +37 -4
index.html
CHANGED
@@ -86,7 +86,16 @@
|
|
86 |
min-width: 95%;
|
87 |
max-width: 95%;
|
88 |
}
|
|
|
|
|
|
|
|
|
89 |
}
|
|
|
|
|
|
|
|
|
|
|
90 |
</style>
|
91 |
|
92 |
|
@@ -109,7 +118,7 @@
|
|
109 |
|
110 |
<div class="bg-gray-200 px-4 py-3 flex items-center" id="ic">
|
111 |
<input id="user-input" type="text" autocomplete="off" placeholder="Type your message..." class="flex-1 py-2 px-2 rounded-lg focus:outline-none focus:ring focus:ring-cyan-400 bg-gray-200 text-gray-300">
|
112 |
-
<button onclick="sendMessage()" class="ml-4 bg-blue-600 text-white px-4 py-2 rounded-lg"
|
113 |
</div>
|
114 |
|
115 |
|
@@ -138,7 +147,7 @@
|
|
138 |
document.getElementById('userCount').innerText = `Online Users: ${onlineUsersCount}`
|
139 |
});
|
140 |
function sendMessage() {
|
141 |
-
|
142 |
var message = userInput.value;
|
143 |
if(message.length>1200){
|
144 |
alert('messsage lenght exceeds 1200 chracters!!')
|
@@ -155,8 +164,9 @@
|
|
155 |
userInput.addEventListener("keypress", function(event) {
|
156 |
if (event.keyCode === 13) {
|
157 |
if(!document.getElementById('btn').disabled){
|
158 |
-
|
159 |
}
|
|
|
160 |
}
|
161 |
});
|
162 |
|
@@ -180,10 +190,17 @@
|
|
180 |
});
|
181 |
|
182 |
socket.on('response', function(data) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
var currentMessage = messages.lastChild;
|
184 |
if (data.response === 'complete') {
|
185 |
currentMessage = null;
|
186 |
-
document.getElementById('btn').disabled = false
|
187 |
} else {
|
188 |
if (!currentMessage || !currentMessage.classList.contains('ai-response')) {
|
189 |
currentMessage = document.createElement('p');
|
@@ -205,7 +222,23 @@ socket.on('response', function(data) {
|
|
205 |
currentMessage.appendChild(responseText);
|
206 |
|
207 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
});
|
|
|
|
|
|
|
209 |
</script>
|
210 |
</body>
|
211 |
|
|
|
86 |
min-width: 95%;
|
87 |
max-width: 95%;
|
88 |
}
|
89 |
+
#chat-messages img{
|
90 |
+
min-width: 80%;
|
91 |
+
width: 80%;
|
92 |
+
}
|
93 |
}
|
94 |
+
#chat-messages img{
|
95 |
+
width: 40%;
|
96 |
+
margin-left: 7px;
|
97 |
+
|
98 |
+
}
|
99 |
</style>
|
100 |
|
101 |
|
|
|
118 |
|
119 |
<div class="bg-gray-200 px-4 py-3 flex items-center" id="ic">
|
120 |
<input id="user-input" type="text" autocomplete="off" placeholder="Type your message..." class="flex-1 py-2 px-2 rounded-lg focus:outline-none focus:ring focus:ring-cyan-400 bg-gray-200 text-gray-300">
|
121 |
+
<button id='btn' onclick="sendMessage()" class="ml-4 bg-blue-600 text-white px-4 py-2 rounded-lg">Send</button>
|
122 |
</div>
|
123 |
|
124 |
|
|
|
147 |
document.getElementById('userCount').innerText = `Online Users: ${onlineUsersCount}`
|
148 |
});
|
149 |
function sendMessage() {
|
150 |
+
document.getElementById('btn').disabled = true
|
151 |
var message = userInput.value;
|
152 |
if(message.length>1200){
|
153 |
alert('messsage lenght exceeds 1200 chracters!!')
|
|
|
164 |
userInput.addEventListener("keypress", function(event) {
|
165 |
if (event.keyCode === 13) {
|
166 |
if(!document.getElementById('btn').disabled){
|
167 |
+
sendMessage();
|
168 |
}
|
169 |
+
|
170 |
}
|
171 |
});
|
172 |
|
|
|
190 |
});
|
191 |
|
192 |
socket.on('response', function(data) {
|
193 |
+
if(data.img!=null || data.img!=undefined){
|
194 |
+
var img = document.createElement('img');
|
195 |
+
img.src = 'data:image/jpeg;base64,' + data.img;
|
196 |
+
messages.appendChild(img);
|
197 |
+
}
|
198 |
+
else{
|
199 |
+
|
200 |
+
console.log(data.response);
|
201 |
var currentMessage = messages.lastChild;
|
202 |
if (data.response === 'complete') {
|
203 |
currentMessage = null;
|
|
|
204 |
} else {
|
205 |
if (!currentMessage || !currentMessage.classList.contains('ai-response')) {
|
206 |
currentMessage = document.createElement('p');
|
|
|
222 |
currentMessage.appendChild(responseText);
|
223 |
|
224 |
}
|
225 |
+
|
226 |
+
}
|
227 |
+
});
|
228 |
+
|
229 |
+
|
230 |
+
|
231 |
+
|
232 |
+
socket.on('image', function(data) {
|
233 |
+
if (data.image) {
|
234 |
+
var img = document.createElement('img');
|
235 |
+
img.src = 'data:image/jpeg;base64,' + data.image;
|
236 |
+
document.body.appendChild(img); // Or append to a specific container
|
237 |
+
}
|
238 |
});
|
239 |
+
|
240 |
+
|
241 |
+
|
242 |
</script>
|
243 |
</body>
|
244 |
|