-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4-hours-version.html
676 lines (574 loc) · 22.8 KB
/
4-hours-version.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Researcher Introduction Chat</title>
<!-- Responsive meta tag -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/* Reset default margins and padding, set default font and background color */
html, body {
height: 100%;
margin: 0;
}
body {
display: flex;
flex-direction: column;
font-family: Arial, sans-serif;
background-color: #f5f5f5;
}
/* Main chat container */
.chat-container {
flex-grow: 1;
display: flex;
flex-direction: column;
position: relative;
max-width: 100%;
margin: 0;
background-color: #fff;
transition: padding-top 0.5s ease;
}
/* Hero Section */
.hero-section {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 3.125em 1.25em;
background-color: #fff;
transition: all 0.5s ease;
}
.hero-content {
display: flex;
align-items: center;
justify-content: center;
transition: all 0.5s ease;
}
.hero-text {
text-align: center;
margin-right: 1.25em;
transition: all 0.5s ease;
}
.hero-text h2,
.hero-text h1 {
margin: 0;
opacity: 0;
animation: fadeInUp 1s ease forwards;
}
.hero-text h2 {
font-size: 1.5em;
color: #333;
animation-delay: 0.5s;
}
.hero-text h1 {
font-size: 2.5em;
color: #007bff;
animation-delay: 1s;
}
.hero-image {
opacity: 0;
animation: fadeInUp 1s ease forwards;
animation-delay: 1.5s;
}
.hero-image img {
border-radius: 50%;
width: 30ch;
height: 30ch;
transition: all 0.5s ease;
}
/* Adjust hero section when chat is active */
.chat-container.active .hero-section {
position: fixed;
top: 0;
left: 0;
width: 100%;
padding: 0.625em 1.25em;
background-color: #007bff;
color: #fff;
z-index: 1000;
}
.chat-container.active .hero-content {
justify-content: flex-start;
}
.chat-container.active .hero-text {
text-align: left;
margin-right: 0.625em;
}
.chat-container.active .hero-text h2,
.chat-container.active .hero-text h1 {
color: #fff;
font-size: 1em;
}
.chat-container.active .hero-image img {
width: 5ch;
height: 5ch;
}
.chat-container.active {
padding-top: 70px; /* Adjust to match the height of the fixed hero-section */
}
/* Messages container */
.messages {
display: none;
flex-grow: 1;
padding: 1.25em;
overflow-y: auto;
}
.chat-container.active .messages {
display: block;
}
/* Individual message styling */
.message {
display: none; /* Hide messages initially */
display: flex;
margin-bottom: 0.9375em;
}
/* Sent messages align to the right */
.message.sent {
justify-content: flex-end;
}
/* Message content styling */
.message .content {
max-width: 60ch;
width: auto;
padding: 0.625em 0.9375em;
border-radius: 1.25em;
background-color: #e9e9eb;
position: relative;
}
/* Styling for sent messages */
.message.sent .content {
background-color: #007bff;
color: #fff;
}
/* Message tail styling */
.message .content::after {
content: '';
position: absolute;
bottom: 0;
width: 0;
height: 0;
}
/* Tail for received messages */
.message.received .content::after {
left: -0.625em;
border: 0.625em solid transparent;
border-top-color: #e9e9eb;
border-bottom: 0;
border-right: 0;
margin-left: -0.625em;
margin-bottom: -0.625em;
}
/* Tail for sent messages */
.message.sent .content::after {
right: -0.625em;
border: 0.625em solid transparent;
border-top-color: #007bff;
border-bottom: 0;
border-left: 0;
margin-right: -0.625em;
margin-bottom: -0.625em;
}
/* Tags container styling */
.tags-container {
display: flex;
flex-wrap: wrap;
justify-content: center;
padding: 0.625em 1.25em;
background-color: #fff;
/* Removed the border lines */
/* border-top: 1px solid #ddd; */
/* border-bottom: 1px solid #ddd; */
}
/* Tag buttons styling */
.tag-button {
background-color: #e9e9eb;
border: none;
border-radius: 1em;
padding: 0.5em 1em;
margin: 0.3em;
cursor: pointer;
font-size: 0.9em;
color: #333;
outline: none;
}
.tag-button:hover {
background-color: #d4d4d6;
}
.tag-button:active {
background-color: #bcbcc0;
}
/* Input container styling */
.input-container {
display: flex;
align-items: center;
padding: 0.625em 1.25em;
background-color: #f5f5f5;
border-top: 1px solid #ddd;
/* Limited the maximum width and centered */
max-width: 800px;
margin: 0 auto;
width: 100%;
}
/* Input container when chat is active */
.chat-container.active .input-container {
max-width: none;
margin: 0;
}
/* Input field styling */
.input-container input[type="text"] {
flex: 1;
padding: 0.75em 1.25em;
border: none;
border-radius: 1.5em;
background-color: #e9e9eb;
font-size: 1em;
outline: none;
}
/* Placeholder text color */
.input-container input[type="text"]::placeholder {
color: #999;
}
/* Send button styling */
.input-container button {
margin-left: 0.625em;
padding: 0.75em;
border: none;
background-color: #007bff;
color: #fff;
border-radius: 50%;
cursor: pointer;
outline: none;
}
/* Hover effect for send button */
.input-container button:hover {
background-color: #0056b3;
}
/* Active effect for send button */
.input-container button:active {
background-color: #004085;
}
/* Animation for message appearance */
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(1.25em);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.message.sent.appear,
.message.received.appear {
animation: fadeInUp 0.3s ease forwards;
}
/* Styling for social links message */
.message .content.social-links {
/* Inherit the same styling as other messages */
display: flex;
flex-direction: column;
align-items: center;
background-color: #e9e9eb;
padding: 0.625em 0.9375em;
border-radius: 1.25em;
position: relative;
}
/* Adjust the tail for the social links bubble */
.message .content.social-links::after {
content: '';
position: absolute;
left: -0.625em;
bottom: 0;
width: 0;
height: 0;
border: 0.625em solid transparent;
border-top-color: #e9e9eb;
border-bottom: 0;
border-right: 0;
margin-left: -0.625em;
margin-bottom: -0.625em;
}
.message .content.social-links .header {
font-size: 1em;
margin-bottom: 0.625em;
width: 100%;
text-align: center;
}
.message .content.social-links .icons {
display: flex;
justify-content: center;
opacity: 0;
/* Fade-in animation */
animation: fadeInIcons 0.5s ease forwards;
animation-delay: 0.5s;
}
.message .content.social-links a {
margin: 0 1em;
}
.message .content.social-links svg {
width: 5ch;
height: 5ch;
cursor: pointer;
}
/* Fade-in animation for icons */
@keyframes fadeInIcons {
from { opacity: 0; transform: translateY(0.625em); }
to { opacity: 1; transform: translateY(0); }
}
/* Responsive adjustments */
@media (max-width: 600px) {
.hero-text h2 {
font-size: 1.2em;
}
.hero-text h1 {
font-size: 2em;
}
.hero-image img {
width: 20ch;
height: 20ch;
}
.hero-section {
padding: 2em 1em;
}
}
</style>
</head>
<body>
<!-- Main chat container -->
<div class="chat-container">
<!-- Hero Section -->
<div class="hero-section">
<div class="hero-content">
<div class="hero-text">
<h2>Meet the Researcher</h2>
<h1>John Doe</h1>
</div>
<div class="hero-image">
<img src="https://eu.ui-avatars.com/api/?name=John+Doe&size=250" alt="John Doe">
</div>
</div>
</div>
<!-- Messages area -->
<div class="messages">
<!-- Messages will be dynamically added here -->
</div>
<!-- Tags container -->
<div class="tags-container">
<!-- Clickable tags -->
<button class="tag-button" data-message="introduction">Introduction</button>
<button class="tag-button" data-message="research">Research Interests</button>
<button class="tag-button" data-message="projects">Recent Projects</button>
<button class="tag-button" data-message="contact">Contact Information</button>
</div>
<!-- Input area -->
<div class="input-container">
<!-- Text input for user's message -->
<input type="text" id="message-input" placeholder="Type your message here...">
<!-- Send button with onclick event -->
<button id="send-button" onclick="sendMessage()">
<!-- Send icon -->
➤
</button>
</div>
</div>
<!-- JavaScript for handling message sending and tag clicks -->
<script>
// Predefined messages corresponding to each tag
const predefinedMessages = {
introduction: "Hello! I'm Dr. Emily Smith, a neuroscientist at ABC University. I'd love to share more about my research with you.",
research: "Certainly! My primary research focuses on neuroplasticity and how the brain adapts after injury. I'm also interested in cognitive rehabilitation techniques.",
projects: "Recently, my team has been working on developing non-invasive brain stimulation methods to enhance recovery in stroke patients.",
contact: "You're welcome! Feel free to visit my lab's website at <a href='http://www.emilysmithlab.com'>www.emilysmithlab.com</a> or email me at emily.smith@abcuniversity.edu."
};
// Function to display a message with typing animation
function displayMessage(messageText) {
// Create a new message element
const message = document.createElement('div');
message.classList.add('message', 'received', 'appear'); // Received message with animation
const content = document.createElement('div');
content.classList.add('content');
// Append content to message
message.appendChild(content);
const messagesContainer = document.querySelector('.messages');
messagesContainer.appendChild(message);
// Show the message element
message.style.display = 'flex';
// Initialize typing effect
const speed = 50; // milliseconds per character
typeHtml(content, messageText, speed);
// Scroll to the bottom
messagesContainer.scrollTop = messagesContainer.scrollHeight;
}
// Typing function that handles HTML content
function typeHtml(element, html, speed) {
let cursorPosition = 0,
tag = '',
writingTag = false,
tagOpen = false,
tempTypeSpeed = speed;
function type() {
if (writingTag) {
tag += html[cursorPosition];
}
if (html[cursorPosition] === '<') {
tempTypeSpeed = 0;
writingTag = true;
tag += html[cursorPosition];
} else if (html[cursorPosition] === '>') {
tag += html[cursorPosition];
writingTag = false;
// Append the tag to the element
element.innerHTML += tag;
tag = '';
} else if (writingTag) {
tag += html[cursorPosition];
} else {
element.innerHTML += html[cursorPosition];
}
cursorPosition++;
if (cursorPosition < html.length) {
setTimeout(type, tempTypeSpeed);
}
}
type();
}
// Function to display the user's message
function displayUserMessage(messageText) {
// Create a new message element
const message = document.createElement('div');
message.classList.add('message', 'sent', 'appear'); // Sent message with animation
// Create the content div and set its text
const content = document.createElement('div');
content.classList.add('content');
content.textContent = messageText;
// Append the content to the message element
message.appendChild(content);
// Append the message to the messages container
const messagesContainer = document.querySelector('.messages');
messagesContainer.appendChild(message);
// Scroll to the bottom to show the new message
messagesContainer.scrollTop = messagesContainer.scrollHeight;
}
// Function to display social links after contact information
function displaySocialLinks() {
// Create a new message element
const message = document.createElement('div');
message.classList.add('message', 'received', 'appear'); // Received message with animation
const content = document.createElement('div');
content.classList.add('content', 'social-links'); // Add 'social-links' class for styling
// Create header element
const header = document.createElement('div');
header.classList.add('header');
content.appendChild(header);
// Append content to message
message.appendChild(content);
const messagesContainer = document.querySelector('.messages');
messagesContainer.appendChild(message);
// Show the message element
message.style.display = 'flex';
// Initialize typing effect for header
const headerText = "Connect with me on:";
const speed = 50; // milliseconds per character
typeHtml(header, headerText, speed);
// SVG code for GitHub and LinkedIn icons
const githubSVG = `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="m0 0h24v24h-24z" fill="#fff" opacity="0" transform="matrix(-1 0 0 -1 24 24)"/><path d="m12 1a10.89 10.89 0 0 0 -11 10.77 10.79 10.79 0 0 0 7.52 10.23c.55.1.75-.23.75-.52s0-.93 0-1.83c-3.06.65-3.71-1.44-3.71-1.44a2.86 2.86 0 0 0 -1.22-1.58c-1-.66.08-.65.08-.65a2.31 2.31 0 0 1 1.68 1.11 2.37 2.37 0 0 0 3.2.89 2.33 2.33 0 0 1 .7-1.44c-2.44-.27-5-1.19-5-5.32a4.15 4.15 0 0 1 1.11-2.91 3.78 3.78 0 0 1 .11-2.84s.93-.29 3 1.1a10.68 10.68 0 0 1 5.5 0c2.1-1.39 3-1.1 3-1.1a3.78 3.78 0 0 1 .11 2.84 4.15 4.15 0 0 1 1.17 2.89c0 4.14-2.58 5.05-5 5.32a2.5 2.5 0 0 1 .75 2v2.95s.2.63.75.52a10.8 10.8 0 0 0 7.5-10.22 10.89 10.89 0 0 0 -11-10.77" fill="#231f20"/></svg>`;
const linkedinSVG = `<svg enable-background="new 0 0 112.196 112.196" viewBox="0 0 112.196 112.196" xmlns="http://www.w3.org/2000/svg"><circle cx="56.098" cy="56.097" fill="#007ab9" r="56.098"/><path d="m89.616 60.611v23.128h-13.409v-21.578c0-5.418-1.936-9.118-6.791-9.118-3.705 0-5.906 2.491-6.878 4.903-.353.862-.444 2.059-.444 3.268v22.524h-13.41s.18-36.546 0-40.329h13.411v5.715c-.027.045-.065.089-.089.132h.089v-.132c1.782-2.742 4.96-6.662 12.085-6.662 8.822 0 15.436 5.764 15.436 18.149zm-54.96-36.642c-4.587 0-7.588 3.011-7.588 6.967 0 3.872 2.914 6.97 7.412 6.97h.087c4.677 0 7.585-3.098 7.585-6.97-.089-3.956-2.908-6.967-7.496-6.967zm-6.791 59.77h13.405v-40.33h-13.405z" fill="#f1f2f2"/></svg>`;
// Create the SVG links
const githubLink = document.createElement('a');
githubLink.href = 'https://github.com';
githubLink.target = '_blank';
githubLink.innerHTML = githubSVG;
const linkedinLink = document.createElement('a');
linkedinLink.href = 'https://linkedin.com';
linkedinLink.target = '_blank';
linkedinLink.innerHTML = linkedinSVG;
// Create a container for the icons
const iconsContainer = document.createElement('div');
iconsContainer.classList.add('icons');
iconsContainer.appendChild(githubLink);
iconsContainer.appendChild(linkedinLink);
// Append the icons after the header typing effect
setTimeout(() => {
content.appendChild(iconsContainer);
// Scroll to the bottom
messagesContainer.scrollTop = messagesContainer.scrollHeight;
}, headerText.length * speed + 500);
// Scroll to the bottom
messagesContainer.scrollTop = messagesContainer.scrollHeight;
}
// Function to remove a tag button
function removeTagButton(messageKey) {
const button = document.querySelector(`.tag-button[data-message="${messageKey}"]`);
if (button) {
button.parentNode.removeChild(button);
}
}
// Function to activate chat view
function activateChat() {
const chatContainer = document.querySelector('.chat-container');
if (!chatContainer.classList.contains('active')) {
chatContainer.classList.add('active');
}
}
// Add event listeners to the tag buttons
const tagButtons = document.querySelectorAll('.tag-button');
tagButtons.forEach(button => {
button.addEventListener('click', function handleClick() {
const messageKey = button.getAttribute('data-message');
const messageText = predefinedMessages[messageKey];
// Get the label of the tag button to display in the user's message bubble
const userMessageText = button.textContent;
// Display the user's message bubble
displayUserMessage(userMessageText);
// Display the assistant's message with typing effect
displayMessage(messageText);
// If the 'contact' tag is clicked, display the second message with SVGs
if (messageKey === 'contact') {
// Delay the display of social links until after typing animation
setTimeout(displaySocialLinks, messageText.length * 50 + 500);
}
// Remove the clicked tag from the tag list
removeTagButton(messageKey);
// Activate the chat view with transition
activateChat();
});
});
function sendMessage() {
// Get the input field and its value
const input = document.getElementById('message-input');
const messageText = input.value.trim();
// If the input is empty, do nothing
if (messageText === '') {
return;
}
// Display the user's message
displayUserMessage(messageText);
// Clear the input field
input.value = '';
// Activate the chat view with transition
activateChat();
// Process the message
const lowerCaseMessage = messageText.toLowerCase();
// Check for keywords and display corresponding messages
if (lowerCaseMessage.includes('intro')) {
displayMessage(predefinedMessages['introduction']);
removeTagButton('introduction');
} else if (lowerCaseMessage.includes('research')) {
displayMessage(predefinedMessages['research']);
removeTagButton('research');
} else if (lowerCaseMessage.includes('project')) {
displayMessage(predefinedMessages['projects']);
removeTagButton('projects');
} else if (lowerCaseMessage.includes('contact')) {
displayMessage(predefinedMessages['contact']);
removeTagButton('contact');
// Display social links after typing effect
setTimeout(displaySocialLinks, predefinedMessages['contact'].length * 50 + 500);
} else {
// Handle unrecognized input
displayMessage("I'm sorry, I didn't understand that. Could you please choose a topic or type 'intro', 'research', 'project', or 'contact'?");
}
}
</script>
</body>
</html>