Advay-Singh commited on
Commit
8b51a78
·
verified ·
1 Parent(s): 63ddb39

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +298 -0
templates/index.html CHANGED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>TaskBot v1</title>
7
+ <script src="https://kit.fontawesome.com/cda0e70b18.js" crossorigin="anonymous"></script>
8
+ <link rel="Icon" href="TaskBot logo.png">
9
+ </head>
10
+ <style>
11
+ body {
12
+ background-color: #2f2f2f;
13
+ font-family: Arial, sans-serif;
14
+ color: white;
15
+ margin: 0;
16
+ padding: 20px;
17
+ }
18
+
19
+ nav {
20
+ background-color: #444;
21
+ padding: 5px;
22
+ border-radius: 5px;
23
+ width: 100%;
24
+ height: auto;
25
+ top: 0;
26
+ }
27
+
28
+ .sticky {
29
+ position: absolute;
30
+ top: 20px;
31
+ right: 20px;
32
+ z-index: 1000;
33
+ }
34
+ .sticky2 {
35
+ position: absolute;
36
+ top: 20px;
37
+ right: 80px;
38
+ z-index: 1000;
39
+ }
40
+ /* Dropdown Styles */
41
+ .dropdown {
42
+ position: relative;
43
+ display: inline-block;
44
+ }
45
+ .btn {
46
+ background-color: transparent;
47
+ color: white;
48
+ border: none;
49
+ cursor: pointer;
50
+ }
51
+ .btn:hover {
52
+ background-color: #494949;
53
+ }
54
+ .dropdown-content {
55
+ display: none;
56
+ position: absolute;
57
+ right: 0;
58
+ background-color: #343232;
59
+ border: 1px solid black;
60
+ min-width: 160px;
61
+ box-shadow: 0px 8px 16px rgba(0, 0, 0, 0.2);
62
+ z-index: 1;
63
+ }
64
+ .dropdown-content h3 {
65
+ margin: 5px 0;
66
+ color: white;
67
+ text-align: center;
68
+ }
69
+ .dropdown-content a {
70
+ color: blue;
71
+ padding: 12px 16px;
72
+ text-decoration: none;
73
+ display: block;
74
+ border-top: 1px solid transparent;
75
+ }
76
+ .dropdown-content a:hover {
77
+ background-color: #494949;
78
+ }
79
+ .dropdown:hover .dropdown-content {
80
+ display: block;
81
+ }
82
+
83
+ main {
84
+ display: flex;
85
+ flex-direction: column;
86
+ align-items: center;
87
+ justify-content: center;
88
+ height: calc(100vh - 100px); /* adjust if header height changes */
89
+ text-align: center;
90
+ }
91
+ /* Input and Button Styles */
92
+ #question {
93
+ padding: 10px;
94
+ font-size: 16px;
95
+ border-radius: 5px;
96
+ border: 1px solid #ccc;
97
+ margin-right: 10px;
98
+ }
99
+
100
+ #userInput {
101
+ width: 50%;
102
+ padding: 10px;
103
+ border-radius: 5px;
104
+ border: 1px solid #ccc;
105
+ margin-right: 10px;
106
+ width: 200px;
107
+ color: black;
108
+ background-color: #fff;
109
+ color: white;
110
+ }
111
+
112
+ .ai,.user{
113
+ background-color: #444;
114
+ padding: 10px;
115
+ padding-right: 10px;
116
+ border-radius: 5px;
117
+ border: solid #ccc;
118
+ margin: 10px;
119
+ text-align: center;
120
+ justify-content: right;
121
+ width: 40%;
122
+ color: rgb(227, 227, 227)
123
+ }
124
+ .text1{
125
+ display: flex;
126
+ justify-content: right;
127
+ align-items: center;
128
+ margin: 10px;
129
+ }
130
+ .text2{
131
+ display: flex;
132
+ justify-content: left;
133
+ align-items: center;
134
+ margin: 10px;
135
+ }
136
+
137
+ .chat-input-container {
138
+ display: flex;
139
+ align-items: center;
140
+ justify-content: center;
141
+ margin-top: 20px;
142
+ }
143
+
144
+ #sendButton {
145
+ margin-left: 10px;
146
+ padding: 10px 20px;
147
+ border: none;
148
+ border-radius: 5px;
149
+ background-color: #fff;
150
+ cursor: pointer;
151
+ transition: background-color 0.3s;
152
+ }
153
+
154
+ #sendButton:hover {
155
+ background-color: #e0e0e0;
156
+ }
157
+
158
+ .inputWrapper {
159
+ position: fixed;
160
+ bottom: 20px;
161
+ left: 50%;
162
+ transform: translateX(-50%);
163
+ display: flex;
164
+ gap: 10px;
165
+ z-index: 1000;
166
+ align-items: center;
167
+ }
168
+
169
+ .inputWrapper input {
170
+ width: 300px;
171
+ padding: 10px;
172
+ }
173
+
174
+ .inputWrapper button {
175
+ font-size: 18px;
176
+ padding: 10px 20px;
177
+ border-radius: 50px;
178
+ cursor: pointer;
179
+ }
180
+
181
+ #welcomeMessage{
182
+ text-align: center;
183
+ margin-top: 20%;
184
+ }
185
+ </style>
186
+ <body>
187
+ <header>
188
+ <h2>TaskBot v1</h2>
189
+ <hr color="white">
190
+ <div class="sticky">
191
+ <div class="dropdown">
192
+ <button class="btn">
193
+ <i class="fa-solid fa-bars fa-2xl"></i>
194
+ </button>
195
+ <div class="dropdown-content">
196
+ <h3><u>Menu</u></h3>
197
+ <hr>
198
+ <a href="https://taskbot-ai-astrumix.netlify.app/">Home</a>
199
+ <a href="https://taskbot-suggest.netlify.app/">Suggest</a>
200
+ <a href="https://taskbot-complain.netlify.app/">Complain</a>
201
+ <a href="https://taskbot-ai-astrumix.netlify.app#contact">Contact</a>
202
+ <a href="https://taskbot-ai-astrumix.netlify.app#versions">More Versions</a>
203
+ <a href="">Explore(Available soon)</a>
204
+ </div>
205
+ </div>
206
+ </div>
207
+ <div class="sticky2">
208
+ <div class="dropdown">
209
+ <button class="btn">
210
+ <i class="fa-solid fa-exclamation fa-2xl"></i>
211
+ </button>
212
+ <div class="dropdown-content">
213
+ <h3><u>Warnings</u></h3>
214
+ <hr>
215
+ <p>1. Don't share personal info, chats may be reviewed and reused to train our models.</p>
216
+ <hr>
217
+ <p>2. TaskBot can make mistakes, double check the answers for more accuracy.</p>
218
+ </div>
219
+ </div>
220
+ </div>
221
+ </header>
222
+ <H1 id="welcomeMessage">Hello 👋, what can I help with?</H1>
223
+ <div id="chatArea">
224
+ <div class="text1">
225
+ <div class="user" style="display: none;"></div>
226
+ </div>
227
+ <div class="text2">
228
+ <div class="ai" style="display: none;"></div>
229
+ </div>
230
+ </div>
231
+
232
+ <main>
233
+ <div class="inputWrapper">
234
+ <input type="text" id="userInput" placeholder="Type your message here..." style="border-radius: 50px; color: black;"><br>
235
+ <button id="sendButton" onclick=answer()>&#8593</button>
236
+ </div>
237
+ </main>
238
+
239
+ <script>
240
+ async function answer() {
241
+ const welcomeMessage = document.getElementById('welcomeMessage');
242
+ welcomeMessage.style.display = 'none'; // Hide the welcome message
243
+ const userInput = document.getElementById('userInput').value;
244
+ if (userInput.trim() === '') return;
245
+
246
+ // Create wrapper for text1 (User message)
247
+ const text1 = document.createElement('div');
248
+ text1.className = 'text1';
249
+
250
+ const userMessage = document.createElement('div');
251
+ userMessage.className = 'user';
252
+ userMessage.textContent = userInput;
253
+
254
+ text1.appendChild(userMessage);
255
+
256
+ // Append user message to the chat area
257
+ document.getElementById('chatArea').appendChild(text1);
258
+
259
+ // Clear input
260
+ document.getElementById('userInput').value = '';
261
+
262
+ const question = userInput; // Use the already retrieved value
263
+ // Send a POST request to the /ask route
264
+ const response = await fetch("/ask", {
265
+ method: "POST",
266
+ headers: {
267
+ "Content-Type": "application/x-www-form-urlencoded"
268
+ },
269
+ body: new URLSearchParams({ question: question })
270
+ });
271
+
272
+ const data = await response.json();
273
+
274
+ // Create wrapper for text2 (AI response)
275
+ const text2 = document.createElement('div');
276
+ text2.className = 'text2';
277
+
278
+ const aiResponse = document.createElement('div');
279
+ aiResponse.className = 'ai';
280
+
281
+ if (data.answer) {
282
+ aiResponse.textContent = data.answer;
283
+ } else if (data.error) {
284
+ aiResponse.textContent = "Error: " + data.error;
285
+ }
286
+
287
+ text2.appendChild(aiResponse);
288
+
289
+ // Append AI response to the chat area
290
+ document.getElementById('chatArea').appendChild(text2);
291
+ }
292
+ </script>
293
+ </script>
294
+
295
+ </script>
296
+
297
+ </body>
298
+ </html>