Code 2
Code 2
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Healthcare Chatbot</title>
<style>
/* Add your CSS styles here */
body {
font-family: Arial, sans-serif;
}
.chat-container {
max-width: 500px;
border: 1px solid #ccc;
border-radius: 5px;
overflow: hidden;
}
.chat-box {
height: 350px;
overflow-y: scroll;
padding: 10px;
}
.message {
margin-bottom: 10px;
padding: 5px 10px;
border-radius: 5px;
}
.user-message {
background-color: #f2f2f2;
text-align: right;
}
.bot-message {
background-color: #e5e5ff;
}
.chat-form {
display: flex;
align-items: center;
padding: 10px;
background-color: #f2f2f2;
}
.chat-form input[type="text"] {
flex: 1;
margin-right: 5px;
padding: 5px;
border-radius: 5px;
border: 1px solid #ccc;
}
.chat-form button {
padding: 5px 5px;
border-radius: 5px;
border: none;
background-color: #4CAF50;
color: white;
cursor: pointer;
}
/* Microphone button */
.mic-button {
background-color: #808080;
/* Gray background */
border: none;
padding: 10px;
border-radius: 50%;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
}
.mic-icon {
width: 24px;
height: auto;
fill: #ffffff;
/* White color for the mic icon */
}
/* Popup */
.mic-popup {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #f2f2f2;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
z-index: 1000;
display: none;
}
</style>
</head>
<body>
<div class="chat-container">
<div class="chat-box" id="chat-box"></div>
<button id="microphone-button" class="mic-button">
<img src="mic.png" alt="Mic" class="mic-icon">
</button>
<form class="chat-form" id="chat-form">
<input type="text" id="user-input" placeholder="Type your
message...">
<button type="submit">Send</button>
</form>
</div>
<script>
// Function to append a message to the chat box
function appendMessage(message, className) {
var chatBox = document.getElementById('chat-box');
var messageElement = document.createElement('div');
messageElement.className = 'message ' + className;
messageElement.innerHTML = message;
chatBox.appendChild(messageElement);
chatBox.scrollTop = chatBox.scrollHeight; // Scroll to bottom of
chat box
}
recognition.start();