-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai.html
More file actions
217 lines (205 loc) · 6.42 KB
/
ai.html
File metadata and controls
217 lines (205 loc) · 6.42 KB
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>USELESS AI</title>
<style>
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
background: #f5f9fc;
color: #2c3e50;
display: flex;
flex-direction: column;
height: 100vh;
}
header {
background: #e1e8f0;
padding: 12px 16px;
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid #d1dbe5;
}
header h1 {
margin: 0;
font-size: 1.2rem;
font-weight: 600;
color: #34495e;
}
header label {
font-size: 0.9rem;
color: #607d8b;
}
main {
flex: 1;
overflow-y: auto;
padding: 16px;
display: flex;
flex-direction: column;
gap: 12px;
background: #ffffff;
}
.msg {
max-width: 80%;
padding: 12px 16px;
border-radius: 12px;
line-height: 1.5;
word-wrap: break-word;
font-size: 1rem;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.you {
align-self: flex-end;
background: #2e86de;
color: white;
font-weight: 500;
}
.bot {
align-self: flex-start;
background: #ecf0f1;
color: #34495e;
}
footer {
display: flex;
gap: 8px;
padding: 14px 16px;
background: #e1e8f0;
border-top: 1px solid #d1dbe5;
}
input[type=text] {
flex: 1;
padding: 12px 14px;
border-radius: 8px;
border: 1px solid #b0bec5;
font-size: 1rem;
color: #2c3e50;
background: #fff;
transition: border-color 0.2s ease-in-out;
}
input[type=text]:focus {
outline: none;
border-color: #2e86de;
box-shadow: 0 0 5px rgba(46, 134, 222, 0.4);
}
button {
padding: 12px 18px;
border: none;
border-radius: 8px;
background: #2e86de;
color: white;
font-weight: 600;
cursor: pointer;
transition: background-color 0.2s ease-in-out;
}
button:hover {
background: #1b4f72;
}
@media (max-width: 600px) {
.msg {
max-width: 100%;
}
}
</style>
</head>
<body>
<header>
<h1>CUTU 🤖</h1>
<label><input id="smarter" type="checkbox" /> Be a little smarter</label>
</header>
<main id="chat"></main>
<footer>
<input id="q" type="text" placeholder="Type your message..." />
<button id="send">Send</button>
</footer>
<script>
const adjectives = [
"astonishing",
"mildly suspicious",
"completely wrong",
"shockingly average",
"undeniably dramatic",
"questionably genius",
"painfully obvious",
"absurdly bold",
"chaotically neutral"
];
const puns = [
"the moon ate my homework",
"because reasons",
"blame it on the Wi-Fi",
"asks the cat",
"it felt like a Tuesday",
"powered by sheer laziness",
"as endorsed by imaginary experts",
"because reality took a coffee break"
];
const nonsense = [
"a sandwich",
"42",
"an ancient sock",
"a potato with feelings",
"quantum unicorn",
"a sentient stapler",
"the ghost of Wi-Fi past",
"a penguin in sunglasses",
"a taco with trust issues"
];
const emojis = ["😂", "🤷", "🙃", "😵💫", "🤖", "🥴", "😜", "🫠"];
function random(arr) {
return arr[Math.floor(Math.random() * arr.length)];
}
function humorize(base, smarter) {
const addon = smarter
? ` (also, ${random(puns)})`
: ` — obviously ${random(nonsense)}`;
return base + " " + random(emojis) + addon;
}
// FAKE AI reply generator with varied longer replies
async function generateAnswerFromAI(prompt, smarter) {
const tones = [
() => `Honestly, that sounds ${random(adjectives)}, but who am I to judge? ${random(emojis)}`,
() => `You know, I've been thinking about that, and it’s kinda ${random(adjectives)}. ${random(puns)}`,
() => `If I had a brain, I'd say it's ${random(adjectives)}. Meanwhile, here’s a fun fact: ${random(nonsense)}! ${random(emojis)}`,
() => `Well, it might be ${random(adjectives)} — but hey, nobody's perfect! ${random(puns)}`,
() => `Ah, classic ${random(adjectives)} situation, wrapped up in mystery and a sprinkle of chaos. ${random(emojis)}`,
() => `You’re really stirring the pot with that one. It’s definitely ${random(adjectives)}, and probably ${random(nonsense)}. ${random(puns)}`,
() => `That’s as ${random(adjectives)} as it gets, if you ask me. Or don’t. ${random(emojis)}`,
() => `In the grand scheme of things, it’s just ${random(adjectives)} nonsense, but I like it. ${random(puns)}`
];
const base = tones[Math.floor(Math.random() * tones.length)]();
return humorize(base, smarter);
}
function appendMsg(role, text) {
const div = document.createElement("div");
div.className = "msg " + (role === "You" ? "you" : "bot");
div.textContent = text;
document.getElementById("chat").appendChild(div);
div.scrollIntoView();
}
const q = document.getElementById("q"),
send = document.getElementById("send"),
smarter = document.getElementById("smarter");
async function sendMsg() {
const val = q.value.trim();
if (!val) return;
appendMsg("You", val);
q.value = "";
appendMsg("Bot", "Thinking...");
const answer = await generateAnswerFromAI(val, smarter.checked);
const botMessages = document.querySelectorAll(".bot");
botMessages[botMessages.length - 1].textContent = answer;
}
send.onclick = sendMsg;
q.addEventListener("keydown", (e) => {
if (e.key === "Enter") sendMsg();
});
// Get username from localStorage (saved at login)
const username = localStorage.getItem('username') || 'there';
// Personalized initial greeting
appendMsg("Bot", `Hi, ${username}! I’m your Personal AI, now with actual brain cells. Ask me something.`);
</script>
</body>
</html>