Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions projects/intellichat/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IntelliChat</title>
<link rel="stylesheet" href="style.css">
</head>
<body>

<div class="chat-container">

<header>
<h1>IntelliChat</h1>
</header>

<div id="chatBox" class="chat-box"></div>

<div class="input-area">
<input type="text" id="userInput" placeholder="Type your message...">
<button id="sendBtn">Send</button>
</div>

</div>

<script src="script.js"></script>
</body>
</html>
59 changes: 59 additions & 0 deletions projects/intellichat/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const chatBox = document.getElementById("chatBox");
const userInput = document.getElementById("userInput");
const sendBtn = document.getElementById("sendBtn");

let messages = [];

sendBtn.addEventListener("click", sendMessage);
userInput.addEventListener("keypress", e=>{
if(e.key==="Enter") sendMessage();
});

function sendMessage(){
const text = userInput.value.trim();
if(!text) return;

addMessage(text,"user");
userInput.value="";

setTimeout(()=>{
botReply(text);
},500);
}

function addMessage(text,type){
const msg = document.createElement("div");
msg.classList.add("message",type);
msg.textContent=text;
chatBox.appendChild(msg);
chatBox.scrollTop=chatBox.scrollHeight;

messages.push({type,text});
}

function botReply(userText){
const response = generateFakeResponse(userText);
typeEffect(response);
}

function generateFakeResponse(input){
return "AI Response: I understand your message about \""+input+"\". This is a simulated intelligent reply.";
}

function typeEffect(text){
let index=0;
const msg = document.createElement("div");
msg.classList.add("message","bot");
chatBox.appendChild(msg);

const interval = setInterval(()=>{
msg.textContent += text[index];
index++;
chatBox.scrollTop=chatBox.scrollHeight;

if(index>=text.length){
clearInterval(interval);
messages.push({type:"bot",text});
}
},20);
}
83 changes: 83 additions & 0 deletions projects/intellichat/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
*{
margin:0;
padding:0;
box-sizing:border-box;
font-family:Arial, sans-serif;
}

body{
background:#0f172a;
display:flex;
justify-content:center;
align-items:center;
height:100vh;
color:white;
}

.chat-container{
width:90%;
max-width:600px;
height:80vh;
background:#1e293b;
display:flex;
flex-direction:column;
border-radius:12px;
overflow:hidden;
}

header{
padding:15px;
background:#111827;
text-align:center;
font-weight:bold;
}

.chat-box{
flex:1;
padding:15px;
overflow-y:auto;
display:flex;
flex-direction:column;
gap:10px;
}

.message{
padding:10px 15px;
border-radius:12px;
max-width:75%;
}

.user{
align-self:flex-end;
background:#38bdf8;
color:black;
}

.bot{
align-self:flex-start;
background:#334155;
}

.input-area{
display:flex;
padding:10px;
background:#111827;
}

input{
flex:1;
padding:10px;
border:none;
border-radius:6px;
outline:none;
}

button{
margin-left:10px;
padding:10px 15px;
border:none;
border-radius:6px;
background:#38bdf8;
cursor:pointer;
font-weight:bold;
}