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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
</html>
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
|
4 |
+
<head>
|
5 |
+
<meta charset="UTF-8">
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
+
<title>GPT-4 Chat Interface</title>
|
8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.16/tailwind.min.css">
|
9 |
+
<style>
|
10 |
+
body {
|
11 |
+
font-family: 'Roboto', sans-serif;
|
12 |
+
background-color: #f3f4f6;
|
13 |
+
margin: 0;
|
14 |
+
padding: 0;
|
15 |
+
box-sizing: border-box;
|
16 |
+
display: flex;
|
17 |
+
flex-direction: column;
|
18 |
+
min-height: 100vh;
|
19 |
+
}
|
20 |
+
|
21 |
+
.container {
|
22 |
+
flex: 1;
|
23 |
+
display: flex;
|
24 |
+
flex-direction: column;
|
25 |
+
padding: 20px;
|
26 |
+
overflow-y: auto;
|
27 |
+
scroll-behavior: smooth;
|
28 |
+
}
|
29 |
+
|
30 |
+
.message-container {
|
31 |
+
display: flex;
|
32 |
+
flex-direction: column;
|
33 |
+
gap: 20px;
|
34 |
+
align-items: flex-start;
|
35 |
+
}
|
36 |
+
|
37 |
+
.message {
|
38 |
+
max-width: 80%;
|
39 |
+
padding: 15px;
|
40 |
+
border-radius: 15px;
|
41 |
+
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
|
42 |
+
line-height: 1.6;
|
43 |
+
word-wrap: break-word;
|
44 |
+
margin-top: 10px;
|
45 |
+
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
46 |
+
position: relative;
|
47 |
+
overflow: hidden;
|
48 |
+
background: #fff;
|
49 |
+
transition: all 0.3s ease-in-out;
|
50 |
+
}
|
51 |
+
|
52 |
+
.message::after {
|
53 |
+
content: '';
|
54 |
+
position: absolute;
|
55 |
+
bottom: 0;
|
56 |
+
left: 0;
|
57 |
+
width: 100%;
|
58 |
+
height: 3px;
|
59 |
+
background: linear-gradient(to right, #4c51bf, #5a67d8);
|
60 |
+
transform: scaleX(0);
|
61 |
+
transform-origin: bottom right;
|
62 |
+
transition: transform 0.3s ease-in-out;
|
63 |
+
}
|
64 |
+
|
65 |
+
.message:hover::after {
|
66 |
+
transform: scaleX(1);
|
67 |
+
transform-origin: bottom left;
|
68 |
+
}
|
69 |
+
|
70 |
+
.message:hover {
|
71 |
+
transform: translateY(-3px);
|
72 |
+
box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
|
73 |
+
}
|
74 |
+
|
75 |
+
.user-message {
|
76 |
+
background-color: #f0f0f0;
|
77 |
+
color: #333;
|
78 |
+
}
|
79 |
+
|
80 |
+
.bot-message {
|
81 |
+
background-color: #4c51bf;
|
82 |
+
color: #fff;
|
83 |
+
}
|
84 |
+
|
85 |
+
@media (max-width: 768px) {
|
86 |
+
.message {
|
87 |
+
max-width: 90%;
|
88 |
+
padding: 12px;
|
89 |
+
border-radius: 12px;
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
.input-container {
|
94 |
+
position: fixed;
|
95 |
+
bottom: 40px;
|
96 |
+
left: 40px;
|
97 |
+
right: 40px;
|
98 |
+
background: linear-gradient(135deg, #f8f8f8 0%, #e4e4e4 100%);
|
99 |
+
border-radius: 40px;
|
100 |
+
padding: 20px;
|
101 |
+
display: flex;
|
102 |
+
align-items: center;
|
103 |
+
gap: 15px;
|
104 |
+
box-shadow: 0 60px 120px rgba(0, 0, 0, 0.3);
|
105 |
+
transition: all 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
|
106 |
+
z-index: 1000;
|
107 |
+
backdrop-filter: blur(12px);
|
108 |
+
border: 2px solid rgba(255, 255, 255, 0.8);
|
109 |
+
overflow: hidden;
|
110 |
+
opacity: 0.8;
|
111 |
+
filter: blur(1px);
|
112 |
+
-webkit-filter: blur(1px);
|
113 |
+
}
|
114 |
+
|
115 |
+
.input-container:hover {
|
116 |
+
box-shadow: 0 100px 200px rgba(0, 0, 0, 0.5);
|
117 |
+
transform: translateY(-10px) scale(1.01);
|
118 |
+
opacity: 1;
|
119 |
+
filter: blur(0px);
|
120 |
+
-webkit-filter: blur(0px);
|
121 |
+
}
|
122 |
+
|
123 |
+
.input-container>textarea {
|
124 |
+
flex: 1;
|
125 |
+
border: none;
|
126 |
+
border-radius: 20px;
|
127 |
+
padding: 15px;
|
128 |
+
font-size: 18px;
|
129 |
+
font-weight: 700;
|
130 |
+
color: #333;
|
131 |
+
background-color: transparent;
|
132 |
+
transition: all 0.7s ease;
|
133 |
+
outline: none;
|
134 |
+
box-shadow: none;
|
135 |
+
resize: none;
|
136 |
+
|
137 |
+
}
|
138 |
+
|
139 |
+
.input-container>textarea:focus {
|
140 |
+
box-shadow: 0 0 0 4px rgba(0, 168, 255, 0.3);
|
141 |
+
}
|
142 |
+
|
143 |
+
.input-container>textarea::placeholder {
|
144 |
+
color: #666;
|
145 |
+
opacity: 1;
|
146 |
+
font-weight: 500;
|
147 |
+
}
|
148 |
+
|
149 |
+
.input-container::before {
|
150 |
+
content: '';
|
151 |
+
position: absolute;
|
152 |
+
top: -2px;
|
153 |
+
right: -2px;
|
154 |
+
bottom: -2px;
|
155 |
+
left: -2px;
|
156 |
+
background: linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0) 100%);
|
157 |
+
border-radius: inherit;
|
158 |
+
z-index: -1;
|
159 |
+
transition: opacity 0.8s ease, transform 0.8s ease;
|
160 |
+
pointer-events: none;
|
161 |
+
}
|
162 |
+
|
163 |
+
.input-container:hover::before {
|
164 |
+
opacity: 0;
|
165 |
+
transform: scale(1.05);
|
166 |
+
}
|
167 |
+
|
168 |
+
@keyframes pulse {
|
169 |
+
|
170 |
+
0%,
|
171 |
+
100% {
|
172 |
+
box-shadow: 0 0 0 0 rgba(0, 168, 255, 0.5);
|
173 |
+
}
|
174 |
+
|
175 |
+
50% {
|
176 |
+
box-shadow: 0 0 0 6px rgba(0, 168, 255, 0);
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
.input-container:focus-within {
|
181 |
+
animation: pulse 2s infinite ease-in-out;
|
182 |
+
}
|
183 |
+
|
184 |
+
.input-container>textarea::-webkit-scrollbar {
|
185 |
+
width: 8px;
|
186 |
+
}
|
187 |
+
|
188 |
+
.input-container>textarea::-webkit-scrollbar-track {
|
189 |
+
background: #f0f0f0;
|
190 |
+
}
|
191 |
+
|
192 |
+
.input-container>textarea::-webkit-scrollbar-thumb {
|
193 |
+
background: #bbb;
|
194 |
+
border-radius: 8px;
|
195 |
+
border: 2px solid #f0f0f0;
|
196 |
+
}
|
197 |
+
|
198 |
+
.input-container>textarea::-webkit-scrollbar-thumb:hover {
|
199 |
+
background: #999;
|
200 |
+
}
|
201 |
+
|
202 |
+
.input-container>textarea::-webkit-scrollbar-corner {
|
203 |
+
background: transparent;
|
204 |
+
}
|
205 |
+
|
206 |
+
.message-input {
|
207 |
+
flex: 1;
|
208 |
+
border: none;
|
209 |
+
outline: none;
|
210 |
+
font-size: 16px;
|
211 |
+
padding: 10px;
|
212 |
+
}
|
213 |
+
|
214 |
+
.btn-send {
|
215 |
+
background-color: #4c51bf;
|
216 |
+
color: #fff;
|
217 |
+
border: none;
|
218 |
+
border-radius: 10px;
|
219 |
+
padding: 10px 10px;
|
220 |
+
font-size: 16px;
|
221 |
+
cursor: pointer;
|
222 |
+
transition: background-color 0.3s;
|
223 |
+
}
|
224 |
+
|
225 |
+
.btn-send[disabled] {
|
226 |
+
background-color: #ccc;
|
227 |
+
cursor: not-allowed;
|
228 |
+
}
|
229 |
+
|
230 |
+
.btn-send:hover {
|
231 |
+
background-color: #3730a3;
|
232 |
+
}
|
233 |
+
|
234 |
+
/* Base styles */
|
235 |
+
:root {
|
236 |
+
--primary-color: #ffffff;
|
237 |
+
--hover-color: #2980b9;
|
238 |
+
--dropdown-bg: #ffffff;
|
239 |
+
--text-color: #2c3e50;
|
240 |
+
--hover-bg-color: #ecf0f1;
|
241 |
+
--border-radius: 16px;
|
242 |
+
--padding: 16px 32px;
|
243 |
+
--transition-duration: 0.4s;
|
244 |
+
--arrow-size: 16px;
|
245 |
+
--font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
246 |
+
}
|
247 |
+
|
248 |
+
/* Resetting default styles */
|
249 |
+
* {
|
250 |
+
box-sizing: border-box;
|
251 |
+
margin: 0;
|
252 |
+
padding: 0;
|
253 |
+
font-family: var(--font-family);
|
254 |
+
}
|
255 |
+
|
256 |
+
/* Styling the dropdown button with shadow */
|
257 |
+
.dropbtn {
|
258 |
+
background-color: var(--primary-color);
|
259 |
+
color: #2c3e50;
|
260 |
+
padding: var(--padding);
|
261 |
+
font-size: 18px;
|
262 |
+
border: none;
|
263 |
+
cursor: pointer;
|
264 |
+
border-radius: var(--border-radius);
|
265 |
+
outline: none;
|
266 |
+
position: relative;
|
267 |
+
transition: background-color var(--transition-duration), box-shadow var(--transition-duration);
|
268 |
+
padding-right: 50px;
|
269 |
+
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2);
|
270 |
+
}
|
271 |
+
|
272 |
+
.dropbtn::after {
|
273 |
+
content: '▲';
|
274 |
+
font-size: var(--arrow-size);
|
275 |
+
position: absolute;
|
276 |
+
right: 16px;
|
277 |
+
top: 50%;
|
278 |
+
transform: translateY(-50%);
|
279 |
+
transition: transform var(--transition-duration), content var(--transition-duration);
|
280 |
+
}
|
281 |
+
|
282 |
+
.dropbtn.active::after {
|
283 |
+
content: '▼';
|
284 |
+
transform: translateY(-50%);
|
285 |
+
}
|
286 |
+
|
287 |
+
.dropbtn:hover {
|
288 |
+
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.3);
|
289 |
+
}
|
290 |
+
|
291 |
+
.dropdown {
|
292 |
+
position: relative;
|
293 |
+
display: inline-block;
|
294 |
+
}
|
295 |
+
|
296 |
+
.dropdown-content {
|
297 |
+
display: none;
|
298 |
+
position: absolute;
|
299 |
+
background-color: var(--dropdown-bg);
|
300 |
+
min-width: 200px;
|
301 |
+
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
|
302 |
+
z-index: 1;
|
303 |
+
border-radius: var(--border-radius);
|
304 |
+
overflow: hidden;
|
305 |
+
transition: all var(--transition-duration);
|
306 |
+
}
|
307 |
+
|
308 |
+
.dropdown-content a {
|
309 |
+
display: flex;
|
310 |
+
align-items: center;
|
311 |
+
padding: 8px 16px;
|
312 |
+
text-decoration: none;
|
313 |
+
color: var(--text-color);
|
314 |
+
transition: background-color var(--transition-duration);
|
315 |
+
}
|
316 |
+
|
317 |
+
.dropdown-content a .icon {
|
318 |
+
margin-right: 8px;
|
319 |
+
width: 24px;
|
320 |
+
height: 24px;
|
321 |
+
}
|
322 |
+
|
323 |
+
.dropdown-content a:hover {
|
324 |
+
background-color: var(--hover-bg-color);
|
325 |
+
}
|
326 |
+
|
327 |
+
.dropdown-content a:hover {
|
328 |
+
background-color: var(--hover-bg-color);
|
329 |
+
}
|
330 |
+
|
331 |
+
.dropbtn:focus {
|
332 |
+
box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.5);
|
333 |
+
}
|
334 |
+
|
335 |
+
.dropbtn:focus:not(.active)::after {
|
336 |
+
content: '▲';
|
337 |
+
}
|
338 |
+
|
339 |
+
.dropbtn.active:focus::after {
|
340 |
+
content: '▼';
|
341 |
+
}
|
342 |
+
|
343 |
+
|
344 |
+
/* Markdown styles */
|
345 |
+
.message-container h1 {
|
346 |
+
font-size: 36px;
|
347 |
+
margin-top: 24px;
|
348 |
+
margin-bottom: 16px;
|
349 |
+
color: #fff;
|
350 |
+
/* Change text color to white */
|
351 |
+
}
|
352 |
+
|
353 |
+
.message-container h2 {
|
354 |
+
font-size: 32px;
|
355 |
+
margin-top: 20px;
|
356 |
+
margin-bottom: 12px;
|
357 |
+
color: #fff;
|
358 |
+
/* Change text color to white */
|
359 |
+
}
|
360 |
+
|
361 |
+
.message-container h3 {
|
362 |
+
font-size: 28px;
|
363 |
+
margin-top: 16px;
|
364 |
+
margin-bottom: 8px;
|
365 |
+
color: #fff;
|
366 |
+
/* Change text color to white */
|
367 |
+
}
|
368 |
+
|
369 |
+
.message-container p {
|
370 |
+
font-size: 20px;
|
371 |
+
line-height: 1.6;
|
372 |
+
margin-bottom: 12px;
|
373 |
+
color: #fff;
|
374 |
+
/* Change text color to white */
|
375 |
+
}
|
376 |
+
|
377 |
+
.message-container ul,
|
378 |
+
.message-container ol {
|
379 |
+
margin-top: 12px;
|
380 |
+
margin-bottom: 12px;
|
381 |
+
padding-left: 20px;
|
382 |
+
color: #fff;
|
383 |
+
/* Change text color to white */
|
384 |
+
}
|
385 |
+
|
386 |
+
.message-container li {
|
387 |
+
margin-bottom: 6px;
|
388 |
+
}
|
389 |
+
|
390 |
+
.message-container pre {
|
391 |
+
background-color: #333;
|
392 |
+
/* Darken the background for better contrast */
|
393 |
+
padding: 16px;
|
394 |
+
border-radius: 8px;
|
395 |
+
margin-top: 12px;
|
396 |
+
margin-bottom: 12px;
|
397 |
+
overflow-x: auto;
|
398 |
+
color: #fff;
|
399 |
+
/* Change text color to white */
|
400 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
401 |
+
}
|
402 |
+
|
403 |
+
.message-container pre code {
|
404 |
+
display: block;
|
405 |
+
padding: 0;
|
406 |
+
font-size: 18px;
|
407 |
+
color: #fff;
|
408 |
+
/* Change text color to white */
|
409 |
+
}
|
410 |
+
|
411 |
+
.message-container a {
|
412 |
+
color: #007bff;
|
413 |
+
text-decoration: none;
|
414 |
+
border-bottom: 1px solid transparent;
|
415 |
+
transition: border-bottom-color 0.3s;
|
416 |
+
}
|
417 |
+
|
418 |
+
.message-container a:hover {
|
419 |
+
border-bottom-color: #007bff;
|
420 |
+
}
|
421 |
+
|
422 |
+
/* Additional enhancements */
|
423 |
+
.message-container blockquote {
|
424 |
+
margin: 0;
|
425 |
+
padding: 16px;
|
426 |
+
background-color: #444;
|
427 |
+
/* Darken the background for better contrast */
|
428 |
+
border-left: 4px solid #007bff;
|
429 |
+
border-radius: 8px;
|
430 |
+
margin-top: 12px;
|
431 |
+
margin-bottom: 12px;
|
432 |
+
}
|
433 |
+
|
434 |
+
.message-container blockquote p {
|
435 |
+
margin: 0;
|
436 |
+
font-style: italic;
|
437 |
+
color: #fff;
|
438 |
+
/* Change text color to white */
|
439 |
+
}
|
440 |
+
|
441 |
+
/* Support for italic and bold italic */
|
442 |
+
.message-container em {
|
443 |
+
font-style: italic;
|
444 |
+
}
|
445 |
+
|
446 |
+
.message-container strong {
|
447 |
+
font-weight: bold;
|
448 |
+
}
|
449 |
+
</style>
|
450 |
+
</head>
|
451 |
+
|
452 |
+
<div class="container">
|
453 |
+
<div class="message-container"></div>
|
454 |
+
</div>
|
455 |
+
<div class="input-container">
|
456 |
+
<textarea type="text" id="user-input" class="message-input" placeholder="Type your message..."></textarea>
|
457 |
+
<button id="send-btn" class="btn-send">
|
458 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
459 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 10l7-7m0 0l7 7m-7-7v18"></path>
|
460 |
+
</svg>
|
461 |
+
</button>
|
462 |
+
|
463 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/showdown.min.js"></script>
|
464 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.25.0/prism.min.js"></script>
|
465 |
+
<script>
|
466 |
+
const userInput = document.getElementById('user-input');
|
467 |
+
const sendBtn = document.getElementById('send-btn');
|
468 |
+
const chatOutput = document.getElementById('chat-output');
|
469 |
+
let messages = [];
|
470 |
+
|
471 |
+
async function sendMessage() {
|
472 |
+
try {
|
473 |
+
sendBtn.disabled = true;
|
474 |
+
const response = await fetch('https://gpt4.discord.rocks/ask', {
|
475 |
+
method: 'POST',
|
476 |
+
headers: {
|
477 |
+
'Content-Type': 'application/json'
|
478 |
+
},
|
479 |
+
body: JSON.stringify({ "messages": messages })
|
480 |
+
});
|
481 |
+
const data = await response.json();
|
482 |
+
sendBtn.disabled = false;
|
483 |
+
return data.response;
|
484 |
+
} catch (error) {
|
485 |
+
console.error('Error sending message:', error);
|
486 |
+
sendBtn.disabled = false;
|
487 |
+
return 'Error: Failed to send message.';
|
488 |
+
}
|
489 |
+
}
|
490 |
+
|
491 |
+
// Import Prism.js for syntax highlighting
|
492 |
+
// Include Prism.js script in your HTML file
|
493 |
+
|
494 |
+
function displayMessage(message, role) {
|
495 |
+
const messageElement = document.createElement('div');
|
496 |
+
messageElement.classList.add('message', `${role}-message`);
|
497 |
+
|
498 |
+
// Regular expressions to detect code blocks and common code structures
|
499 |
+
const codeBlockRegex = /```([a-zA-Z]+)?\s*([\s\S]+?)\s*```/g;
|
500 |
+
const inlineCodeRegex = /`([^`]+?)`/g;
|
501 |
+
const htmlTagRegex = /<[^>]+>/g;
|
502 |
+
const jsCodeRegex = /\b(function|if|else|for|while|do|switch|case|break|continue|return|try|catch|finally|throw)\b/g;
|
503 |
+
const jsCommentRegex = /\/\/.*|\/\*[\s\S]*?\*\//g;
|
504 |
+
const cssCodeRegex = /[^{};]+\s*{\s*[^{}]*}/g;
|
505 |
+
const cssCommentRegex = /\/\*[\s\S]*?\*\//g;
|
506 |
+
|
507 |
+
// Function to create a code block element with syntax highlighting
|
508 |
+
function createCodeBlock(language, code) {
|
509 |
+
const codeBlock = document.createElement('code');
|
510 |
+
if (language) {
|
511 |
+
codeBlock.classList.add(`language-${language}`);
|
512 |
+
}
|
513 |
+
codeBlock.textContent = code;
|
514 |
+
|
515 |
+
// Use Prism.js to highlight syntax
|
516 |
+
Prism.highlightElement(codeBlock);
|
517 |
+
|
518 |
+
const preElement = document.createElement('pre');
|
519 |
+
preElement.appendChild(codeBlock);
|
520 |
+
|
521 |
+
return preElement;
|
522 |
+
}
|
523 |
+
|
524 |
+
// Function to process code matches and add to message element
|
525 |
+
function processCodeMatches(matches, language) {
|
526 |
+
if (matches) {
|
527 |
+
matches.forEach(match => {
|
528 |
+
const codeBlock = createCodeBlock(language, match);
|
529 |
+
messageElement.appendChild(codeBlock);
|
530 |
+
});
|
531 |
+
}
|
532 |
+
}
|
533 |
+
|
534 |
+
// Process code block matches
|
535 |
+
let lastIndex = 0;
|
536 |
+
let match;
|
537 |
+
while ((match = codeBlockRegex.exec(message)) !== null) {
|
538 |
+
if (match.index > lastIndex) {
|
539 |
+
const textBeforeCode = document.createTextNode(message.substring(lastIndex, match.index));
|
540 |
+
messageElement.appendChild(textBeforeCode);
|
541 |
+
}
|
542 |
+
|
543 |
+
const language = match[1] ? match[1].toLowerCase() : null;
|
544 |
+
const codeContent = match[2];
|
545 |
+
const codeBlock = createCodeBlock(language, codeContent);
|
546 |
+
messageElement.appendChild(codeBlock);
|
547 |
+
|
548 |
+
lastIndex = match.index + match[0].length;
|
549 |
+
}
|
550 |
+
|
551 |
+
// Process inline code matches
|
552 |
+
processCodeMatches(message.match(inlineCodeRegex), null);
|
553 |
+
|
554 |
+
// Process specific code structures
|
555 |
+
processCodeMatches(message.match(htmlTagRegex), 'html');
|
556 |
+
processCodeMatches(message.match(jsCodeRegex), 'javascript');
|
557 |
+
processCodeMatches(message.match(jsCommentRegex), 'javascript-comment');
|
558 |
+
processCodeMatches(message.match(cssCodeRegex), 'css');
|
559 |
+
processCodeMatches(message.match(cssCommentRegex), 'css-comment');
|
560 |
+
|
561 |
+
// Add any remaining text after the last code block
|
562 |
+
if (lastIndex < message.length) {
|
563 |
+
const textAfterCode = document.createTextNode(message.substring(lastIndex));
|
564 |
+
messageElement.appendChild(textAfterCode);
|
565 |
+
}
|
566 |
+
|
567 |
+
chatOutput.appendChild(messageElement);
|
568 |
+
chatOutput.scrollTop = chatOutput.scrollHeight;
|
569 |
+
}
|
570 |
+
|
571 |
+
|
572 |
+
sendBtn.addEventListener('click', async () => {
|
573 |
+
const message = userInput.value.trim();
|
574 |
+
if (message !== '') {
|
575 |
+
messages.push({ "role": "user", "content": message });
|
576 |
+
displayMessage("> " + message, 'user');
|
577 |
+
const botResponse = await sendMessage();
|
578 |
+
messages.push({ "role": "assistant", "content": botResponse });
|
579 |
+
displayMessage(botResponse, 'bot');
|
580 |
+
userInput.value = '';
|
581 |
+
}
|
582 |
+
});
|
583 |
+
|
584 |
+
userInput.addEventListener('keypress', async (event) => {
|
585 |
+
if (event.key === 'Enter') {
|
586 |
+
sendBtn.click();
|
587 |
+
}
|
588 |
+
});
|
589 |
+
</script>
|
590 |
+
|
591 |
+
</body>
|
592 |
+
|
593 |
</html>
|
594 |
+
|