Adieee5 commited on
Commit
d43574d
·
verified ·
1 Parent(s): 0372630
Files changed (1) hide show
  1. templates/chat.html +165 -260
templates/chat.html CHANGED
@@ -5,10 +5,13 @@
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
  <title>JUIT AI Assist</title>
8
- <link rel="shortcut icon" href="#" />
9
- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
10
- integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
11
- crossorigin="anonymous">
 
 
 
12
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css"
13
  integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU"
14
  crossorigin="anonymous">
@@ -20,90 +23,7 @@
20
  <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}" />
21
 
22
  <style>
23
- body, html {
24
- height: 100%;
25
- margin: 0;
26
- background: rgb(44, 47, 59);
27
- background: -webkit-linear-gradient(to right, rgb(40, 59, 34), rgb(54, 60, 70), rgb(32, 32, 43));
28
- background: linear-gradient(to right, rgb(38, 51, 61), rgb(50, 55, 65), rgb(33, 33, 78));
29
- }
30
-
31
- .chat {
32
- margin-top: auto;
33
- margin-bottom: auto;
34
- height: 80%;
35
- }
36
-
37
- .card {
38
- height: calc(100% - 40px);
39
- max-height: calc(100% - 40px);
40
- overflow: hidden;
41
- position: relative;
42
- }
43
-
44
- .msg_card_body {
45
- overflow-y: auto;
46
- max-height: calc(100% - 120px);
47
- }
48
-
49
- .predefined-text {
50
- background-color: #1f2937;
51
- color: #f3f4f6;
52
- padding: 15px;
53
- margin-bottom: 20px;
54
- border-radius: 10px;
55
- font-size: 18px;
56
- text-align: center;
57
- font-weight: bold;
58
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
59
- }
60
-
61
- .predictive-text {
62
- position: absolute;
63
- background-color: rgba(0, 0, 0, 0.7);
64
- border: 1px solid #333;
65
- border-radius: 10px;
66
- padding: 5px;
67
- z-index: 999;
68
- cursor: pointer;
69
- max-height: 150px;
70
- overflow-y: auto;
71
- width: calc(100% - 22px);
72
- bottom: 65px;
73
- left: 10px;
74
- color: #fff;
75
- }
76
-
77
- .predictive-text p {
78
- margin: 5px 0;
79
- padding: 5px;
80
- cursor: pointer;
81
- transition: background-color 0.3s;
82
- border-radius: 5px;
83
- }
84
-
85
- .predictive-text p:hover {
86
- background-color: rgba(255, 255, 255, 0.2);
87
- }
88
-
89
- .predictive-text p:not(:last-child) {
90
- border-bottom: 1px solid #555;
91
- }
92
-
93
- input[type="text"] {
94
- white-space: normal;
95
- overflow-wrap: break-word;
96
- word-wrap: break-word;
97
- width: 100%;
98
- padding: 10px;
99
- height: auto;
100
- }
101
-
102
- ::placeholder {
103
- white-space: normal;
104
- overflow-wrap: break-word;
105
- word-wrap: break-word;
106
- }
107
  </style>
108
 
109
  </head>
@@ -116,15 +36,35 @@
116
  <div class="card-header msg_head">
117
  <div class="d-flex bd-highlight">
118
  <div class="img_cont">
119
- <img src="https://i.ibb.co/jRMcPVs/snjb.jpg" class="rounded-circle user_img">
120
  <span class="online_icon"></span>
121
  </div>
 
122
  <div class="user_info">
123
  <span>JUIT AI Assist</span>
124
  <p>Explore College and Beyond: Ask Anything! 🎓</p>
125
  <div class="predefined-text">
126
- Use keywords instead of full sentences. For example, if you want to ask about placement, type 'placement' for the best answers.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  </div>
 
 
 
 
128
  </div>
129
  </div>
130
  </div>
@@ -133,16 +73,22 @@
133
  <!-- Chat messages will be displayed here -->
134
  </div>
135
  <div class="card-footer" style="position: relative;">
136
- <form id="messageArea" class="input-group">
 
 
 
137
  <input type="text" id="text" name="msg" placeholder="Type your message..." autocomplete="off"
138
  class="form-control type_msg" required />
139
  <div class="input-group-append">
140
- <button type="submit" id="send" class="input-group-text send_btn"><i
141
- class="fas fa-location-arrow"></i></button>
 
142
  </div>
143
  </form>
144
- <div class="predictive-text"></div>
145
- </div>
 
 
146
  </div>
147
  </div>
148
  </div>
@@ -170,160 +116,8 @@
170
  var predictions = [];
171
  var patterns = {
172
  "greeting": ["Hi", "Hey", "How are you", "what's up", "Is anyone there?", "Hello", "Good day"],
173
- "name": ["what is your name", "name", "what's your name", "who are you", "what should I call you"],
174
- "tour":["virtual tour",
175
- "campus tour","juit tour",
176
- "how to see the campus",
177
- "online campus tour",
178
- "can I see the campus virtually",
179
- "how to access the virtual tour",
180
- "virtual campus tour","university virtual tour",
181
- "college virtual tour",
182
- "campus walkthrough",
183
- "campus 3D tour",
184
- "campus view online",
185
- "JUIT virtual tour","JUIT virtual trip",
186
- "virtual visit to JUIT",
187
- "how to explore campus online",
188
- "tour of JUIT campus"],
189
- "Chandigarh Shimla Information": ["Chandigarh Shimla", "chandigarh", "shimla", "kalka",
190
- "location of JUIT",
191
- "JUIT Waknaghat location",
192
- "distance from Chandigarh to JUIT",
193
- "distance from Shimla to JUIT",
194
- "how to reach JUIT from Chandigarh",
195
- "how to reach JUIT from Shimla","JUIT distance from Kalka",
196
- "JUIT road map",
197
- "JUIT location details",
198
- "JUIT distance from Waknaghat",
199
- "nearest railway station to JUIT",
200
- "nearest bus station to JUIT",
201
- "JUIT directions",
202
- "how to go to JUIT from Chandigarh",
203
- "how to go to JUIT from Shimla", "chandigarh to juit","Kalka to juit","shimla to juit",
204
- "how to go to JUIT from kalka", "juit to chandigarh","juit to kalka","juit to shimla",
205
- "transport to JUIT from Chandigarh",
206
- "JUIT from Shimla distance",
207
- "how to reach JUIT by road", "location","Juit location","location of juit",
208
- "where is it located","where is juit", "where is the university",
209
- "what is the location of the college","where is college"
210
- ],
211
- "btech_admission": [ "what is the process of admission",
212
- "what is the admission process",
213
- "How to take admission in your college",
214
- "What is the process for admission",
215
- "admission", "btech admission", "bachelors admission",
216
- "how to get admission","btech admission",
217
- "admission process","admission","juit admission"],
218
-
219
- "phd_admission":["PhD",
220
- "PhD admission", "admission for PhD",
221
- "PhD admission rules", "rules for admission for PhD",
222
- "PhD admission eligibility", "PhD", "apply for PhD", "apply to PhD",
223
- "PhD fellowship","fellowship for PhD", "PhD stipend","stipend for PhD",
224
- "PhD eligibility", "admission PhD","Doctor of Philosophy",
225
- "How can I apply for a PhD at JUIT?",
226
- "What are the rules for PhD admission?",
227
- "What is the eligibility for a PhD program?",
228
- "Is there an entrance exam for PhD at JUIT?",
229
- "What is the duration of the PhD program?","PhD duration",
230
- "What is open defence in a PhD program?","PhD open defence",
231
- "What are the classifications of PhD scholars?",
232
- "Tell me about full-time PhD admission.",
233
- "Can I pursue a part-time PhD at JUIT?",
234
- "What is a sponsored research scholar?","part-time PhD","full-time PhD",
235
- "Where can I find the PhD entrance exam syllabus?", "PhD admission process",
236
- "PhD entrance exam",
237
- "PhD eligibility",
238
- "Apply for PhD",
239
- "PhD program duration",
240
- "What is the PhD fee structure?",
241
- "How much is the PhD stipend?",
242
- "Eligibility criteria for PhD",
243
- "What is the format of the PhD entrance test?",
244
- "Can I do a PhD part-time?",
245
- "PhD rules", "PhD in data science",
246
- "Admission for PhD", "PhD in data science admission",
247
- "PhD in machine learning admission",
248
- "PhD in computer science admission",
249
- "PhD in civil engineering admission",
250
- "PhD in information technology admission",
251
- "PhD in electrical engineering admission",
252
- "PhD in electronics admission",
253
- "PhD in ECE admission",
254
- "PhD in biotechnology admission",
255
- "PhD in bioinformatics admission",
256
- "What is the eligibility for PhD in data science?",
257
- "How to apply for PhD in machine learning?",
258
- "What is the process for PhD in computer science?",
259
- "Eligibility for PhD in civil engineering",
260
- "Requirements for PhD in IT",
261
- "What is the PhD admission process for electrical engineering?",
262
- "Can I apply for PhD in ECE at JUIT?",
263
- "Is there a specialization in biotechnology for PhD?",
264
- "Are there PhD programs for bioinformatics?",
265
- "PhD in data science eligibility",
266
- "PhD in machine learning eligibility",
267
- "PhD in civil engineering rules",
268
- "How to apply for PhD in electronics?",
269
- "PhD in CSE at JUIT",
270
- "PhD in computer science at JUIT",
271
- "PhD in information technology at JUIT",
272
- "What is the fee structure for PhD in data science?",
273
- "PhD in ECE duration",
274
- "Is there a stipend for PhD in electrical engineering?",
275
- "Can I get a fellowship for PhD in biotechnology?",
276
- "What is the admission deadline for PhD in bioinformatics?",
277
- "Where can I find the syllabus for PhD in machine learning?",
278
- "What is the format of the PhD entrance test for computer science?",
279
- "Eligibility for PhD in electronics and communication",
280
- "Duration of PhD in CSE at JUIT",
281
- "Can I apply for a part-time PhD in civil engineering?",
282
- "PhD program details for biotechnology",
283
- "What are the research opportunities for PhD in data science?",
284
- "Specializations for PhD in machine learning",
285
- "What is the workload for PhD in computer science?",
286
- "How to download the admission brochure for PhD in IT?",
287
- "PhD in electrical engineering admission details",
288
- "Research topics for PhD in bioinformatics",
289
- "What are the classifications of PhD in electronics?",
290
- "What are the steps for PhD admission?",
291
- "PhD application form","PhD application",
292
- "How can I apply for a PhD in (data science|machine learning|CSE|ml|ai|bt|bi|civil engineering|computer science|IT|information technology|bioinformatics|biotechnology|artificial intelligence|ECE|electronics|electrical engineering) at JUIT?",
293
- "What are the rules for PhD admission in (data science|machine learning|CSE|ml|ai|bt|bi|civil engineering|computer science|IT|information technology|bioinformatics|biotechnology|artificial intelligence|ECE|electronics|electrical engineering)?",
294
- "rules for PhD admission in (data science|machine learning|CSE|civil engineering|ml|ai|bt|bi|computer science|IT|information technology|bioinformatics|biotechnology|artificial intelligence|ECE|electronics|electrical engineering)?","PhD admission in (data science|machine learning|CSE|civil engineering|computer science|IT|information technology|bioinformatics|biotechnology|artificial intelligence|ECE|electronics|electrical engineering) rules",
295
- "What is the eligibility for a PhD in (data science|machine learning|CSE|ml|ai|bt|bi|civil engineering|computer science|IT|information technology|bioinformatics|biotechnology|artificial intelligence|ECE|electronics|electrical engineering)?","eligibility for a PhD in (data science|machine learning|CSE|civil engineering|computer science|IT|information technology|bioinformatics|biotechnology|artificial intelligence|ECE|electronics|electrical engineering)?",
296
- "PhD in (data science|machine learning|CSE|civil engineering|computer science|IT|bt|bi|ml|ai|information technology|bioinformatics|biotechnology|artificial intelligence|ECE|electronics|electrical engineering) eligibility",
297
- "What is the duration of a PhD in (data science|machine learning|CSE|ml|ai|bt|bi|civil engineering|computer science|IT|information technology|bioinformatics|biotechnology|artificial intelligence|ECE|electronics|electrical engineering)?","PhD in (data science|machine learning|CSE|civil engineering|computer science|IT|information technology|bioinformatics|biotechnology|artificial intelligence|ECE|electronics|electrical engineering)","duration of a PhD in (data science|machine learning|CSE|civil engineering|computer science|IT|information technology|bioinformatics|biotechnology|artificial intelligence|ECE|electronics|electrical engineering) duration",
298
- "What is the process for a PhD in (data science|machine learning|CSE|ml|ai|bt|bi|civil engineering|computer science|IT|information technology|bioinformatics|biotechnology|artificial intelligence|ECE|electronics|electrical engineering)","PhD in (data science|machine learning|CSE|civil engineering|computer science|IT|information technology|bioinformatics|biotechnology|artificial intelligence|ECE|electronics|electrical engineering)","process for a PhD in (data science|machine learning|CSE|civil engineering|computer science|IT|information technology|bioinformatics|biotechnology|artificial intelligence|ECE|electronics|electrical engineering) process",
299
- "PhD admission process in (data science|machine learning|CSE|ml|ai|bt|bi|civil engineering|computer science|IT|information technology|bioinformatics|biotechnology|artificial intelligence|ECE|electronics|electrical engineering)",
300
- "PhD eligibility for (data science|machine learning|CSE|ml|bt|bi|ai|civil engineering|computer science|IT|information technology|bioinformatics|biotechnology|artificial intelligence|ECE|electronics|electrical engineering)",
301
- "Apply for PhD in (data science|machine learning|CSE|ml|ai|bt|bi|civil engineering|computer science|IT|information technology|bioinformatics|biotechnology|artificial intelligence|ECE|electronics|electrical engineering)",
302
- "Is there an entrance exam for a PhD in (data science|ml|ai|bt|bi|machine learning|CSE|civil engineering|computer science|IT|information technology|bioinformatics|biotechnology|artificial intelligence|ECE|electronics|electrical engineering)?",
303
- "What is the syllabus for the PhD entrance exam in (data science|machine learning|CSE|ml|bt|bi|ai|civil engineering|computer science|IT|information technology|bioinformatics|biotechnology|artificial intelligence|ECE|electronics|electrical engineering)?",
304
- "PhD entrance exam in (data science|machine learning|CSE|civil engineering|computer science|bt|bi|IT|ml|ai|information technology|bioinformatics|biotechnology|artificial intelligence|ECE|electronics|electrical engineering) syllabus",
305
- "Are international students eligible for PhD?",
306
- "What is the process for PhD admission?",
307
- "PhD program details","PhD program",
308
- "What is the syllabus for the PhD entrance exam?","PhD entrance exam","PhD entrance exam syllabus",
309
- "Do I need a master's degree for a PhD?",
310
- "What is the selection process for PhD?","PhD election process","phd research",
311
- "What is the research proposal format for PhD?",
312
- "What are the deadlines for PhD admission?",
313
- "How can I apply online for PhD?","phd apply","phd online apply","apply for phd","online apply for phd",
314
- "Is there financial aid for PhD students?",
315
- "Can I apply for a PhD without GATE/NET?",
316
- "Where can I download the PhD guidelines?","PhD guidelines","guidelines for PhD",
317
- "What are the PhD specializations offered?",
318
- "PhD classifications at JUIT","PhD classifications","types of PhD","PhD types",
319
- "How are PhD scholars evaluated?",
320
- "Can I change my PhD supervisor?","PhD supervisor",
321
- "What is the maximum duration for a PhD?","how much time to complete PhD", "maximum duration of PhD",
322
- "Can I withdraw from the PhD program?", "PhD program withdraw","withdraw from PhD program",
323
- "PhD attendance requirements","PhD attendance",
324
- "PhD course work details","PhD course work","details of PhD course work",
325
- "Is teaching mandatory for PhD scholars?","PhD scholars? teaching"]
326
-
327
 
328
 
329
  };
@@ -350,6 +144,7 @@
350
  }
351
  }
352
 
 
353
  // Handle message submission and user input history
354
  $("#messageArea").on("submit", function(event) {
355
  $(".predictive-text").hide(); // Hide predictive suggestions
@@ -363,21 +158,79 @@
363
  chatHistory.push(rawText); // Store the user's message in history
364
  currentIndex = chatHistory.length - 1; // Update the current index
365
 
366
- var userHtml = '<div class="d-flex justify-content-end mb-4"><div class="msg_cotainer_send">' + rawText +
367
- '<span class="msg_time_send">' + str_time + '</span></div><div class="img_cont_msg"><img src="https://i.ibb.co/d5b84Xw/Untitled-design.png" class="rounded-circle user_img_msg"></div></div>';
 
 
 
 
 
 
 
368
 
369
  $("#text").val(""); // Clear the input field
370
  $("#messageFormeight").append(userHtml); // Add the user message to the chat
371
 
372
- // Handle up arrow key for cycling through messages
373
- $(document).on("keydown", function(event) {
374
- if (event.key === "ArrowUp") {
375
- if (currentIndex > 0) {
376
- currentIndex--; // Move to the previous message
377
- $("#text").val(chatHistory[currentIndex]); // Update the input field with the previous message
378
- }
379
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
380
  });
 
 
 
 
381
 
382
  // Send the message to the server via AJAX
383
  $.ajax({
@@ -388,7 +241,8 @@
388
  url: "/get",
389
  }).done(function(data) {
390
  var lines = data.split("**");
391
- var botHtml = '<div class="d-flex justify-content-start mb-4"><div class="img_cont_msg"><img src="https://i.ibb.co/jRMcPVs/snjb.jpg" class="rounded-circle user_img_msg"></div><div class="msg_cotainer">';
 
392
  for (var i = 0; i < lines.length; i++) {
393
  botHtml += '<div class="msg_cotainer">' + lines[i] + '</div>';
394
  }
@@ -404,7 +258,58 @@
404
  });
405
  });
406
  </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
407
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
408
  </body>
409
 
410
  </html>
 
5
  <meta charset="UTF-8">
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
  <title>JUIT AI Assist</title>
8
+ <link rel="shortcut icon" href="/static/juitlogo.png" type="image/x-icon">
9
+
10
+
11
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
12
+ integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
13
+ crossorigin="anonymous">
14
+
15
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css"
16
  integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU"
17
  crossorigin="anonymous">
 
23
  <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}" />
24
 
25
  <style>
26
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  </style>
28
 
29
  </head>
 
36
  <div class="card-header msg_head">
37
  <div class="d-flex bd-highlight">
38
  <div class="img_cont">
39
+ <img src="/static/juitlogo.png" class="rounded-circle user_img">
40
  <span class="online_icon"></span>
41
  </div>
42
+
43
  <div class="user_info">
44
  <span>JUIT AI Assist</span>
45
  <p>Explore College and Beyond: Ask Anything! 🎓</p>
46
  <div class="predefined-text">
47
+ Created by
48
+ Ramandeep Singh Makkar
49
+ (<a href="https://www.linkedin.com/in/ramandeep-singh-makkar/" target="_blank">
50
+ <i class="fab fa-linkedin"></i> LinkedIn
51
+ </a>)
52
+ (<a href="mailto:[email protected]">
53
+ <i class="fas fa-envelope"></i> Gmail
54
+ </a>)
55
+ and
56
+ Aditya Singh
57
+ (<a href="https://www.linkedin.com/in/aditsg26/" target="_blank">
58
+ <i class="fab fa-linkedin"></i> LinkedIn
59
+ </a>)
60
+ (<a href="mailto:[email protected]">
61
+ <i class="fas fa-envelope"></i> Gmail
62
+ </a>)
63
  </div>
64
+
65
+ <!-- Add this inside the card-header (after user_info div) -->
66
+ <button id="themeToggle" class="btn btn-sm btn-light ml-auto">Light Mode</button>
67
+
68
  </div>
69
  </div>
70
  </div>
 
73
  <!-- Chat messages will be displayed here -->
74
  </div>
75
  <div class="card-footer" style="position: relative;">
76
+ <form id="messageArea" class="input-group" style="position: relative;">
77
+ <!-- Predictive Text Suggestions (ADD THIS HERE) -->
78
+ <div class="predictive-text" style="position: absolute; background: white; border: 1px solid #ccc; display: none; z-index: 1000; width: 100%;"></div>
79
+
80
  <input type="text" id="text" name="msg" placeholder="Type your message..." autocomplete="off"
81
  class="form-control type_msg" required />
82
  <div class="input-group-append">
83
+ <button type="submit" id="send" class="input-group-text send_btn">
84
+ <i class="fas fa-location-arrow"></i>
85
+ </button>
86
  </div>
87
  </form>
88
+ <button id="clearChat" class="btn btn-danger mt-2">Clear Chat</button>
89
+
90
+
91
+
92
  </div>
93
  </div>
94
  </div>
 
116
  var predictions = [];
117
  var patterns = {
118
  "greeting": ["Hi", "Hey", "How are you", "what's up", "Is anyone there?", "Hello", "Good day"],
119
+ "name": ["what is your name", "name", "what's your name", "who are you", "what should I call you"]
120
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
 
122
 
123
  };
 
144
  }
145
  }
146
 
147
+
148
  // Handle message submission and user input history
149
  $("#messageArea").on("submit", function(event) {
150
  $(".predictive-text").hide(); // Hide predictive suggestions
 
158
  chatHistory.push(rawText); // Store the user's message in history
159
  currentIndex = chatHistory.length - 1; // Update the current index
160
 
161
+ var userHtml = `
162
+ <div class="d-flex justify-content-end mb-4">
163
+ <div class="msg_cotainer_send">${rawText}
164
+ <span class="msg_time_send">${str_time}</span>
165
+ </div>
166
+ <div class="img_cont_msg">
167
+ <img src="/static/userlogo.png" class="rounded-circle user_img_msg">
168
+ </div>
169
+ </div>`;
170
 
171
  $("#text").val(""); // Clear the input field
172
  $("#messageFormeight").append(userHtml); // Add the user message to the chat
173
 
174
+ $(document).ready(function () {
175
+ let chatHistory = JSON.parse(localStorage.getItem("chatHistory")) || []; // Load stored history
176
+ let currentIndex = chatHistory.length; // Set index to last message
177
+
178
+ $("#messageArea").on("submit", function (event) {
179
+ event.preventDefault(); // Prevent form submission
180
+
181
+ let rawText = $("#text").val().trim();
182
+ if (rawText === "") return; // Ignore empty input
183
+
184
+ const time = new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
185
+
186
+ // Append user message to chat
187
+ let userHtml = `
188
+ <div class="d-flex justify-content-end mb-4">
189
+ <div class="msg_cotainer_send">${rawText}<span class="msg_time_send">${time}</span></div>
190
+ <div class="img_cont_msg"><img src="https://i.ibb.co/d5b84Xw/Untitled-design.png" class="rounded-circle user_img_msg"></div>
191
+ </div>`;
192
+ $("#messageFormeight").append(userHtml);
193
+
194
+ // Update chat history
195
+ chatHistory.push(rawText);
196
+ localStorage.setItem("chatHistory", JSON.stringify(chatHistory)); // Save in localStorage
197
+ currentIndex = chatHistory.length; // Reset index to end
198
+
199
+ // Clear input field & scroll down
200
+ $("#text").val("");
201
+ $("#messageFormeight").animate({ scrollTop: $("#messageFormeight")[0].scrollHeight }, 500);
202
+
203
+ // Send message to server
204
+ $.ajax({
205
+ data: { msg: rawText },
206
+ type: "POST",
207
+ url: "/get",
208
+ }).done(function (response) {
209
+ let botHtml = `
210
+ <div class="d-flex justify-content-start mb-4">
211
+ <div class="img_cont_msg">
212
+ <img src="/static/juitlogo.png" class="rounded-circle user_img_msg">
213
+ </div>
214
+ <div class="msg_cotainer">${response}<span class="msg_time">${time}</span></div>
215
+ </div>`;
216
+
217
+ $("#messageFormeight").append($.parseHTML(botHtml));
218
+ $("#messageFormeight").animate({ scrollTop: $("#messageFormeight")[0].scrollHeight }, 500);
219
+ });
220
+ });
221
+
222
+ // Clear chat history
223
+ $("#clearChat").click(function () {
224
+ $("#messageFormeight").html(""); // Clears UI
225
+ chatHistory = []; // Clears array
226
+ localStorage.removeItem("chatHistory"); // Clears from storage
227
+ currentIndex = 0;
228
+ });
229
  });
230
+
231
+
232
+
233
+
234
 
235
  // Send the message to the server via AJAX
236
  $.ajax({
 
241
  url: "/get",
242
  }).done(function(data) {
243
  var lines = data.split("**");
244
+ var botHtml = '<div class="d-flex justify-content-start mb-4"><div class="img_cont_msg"><img src="/static/juitlogo.png" class="rounded-circle user_img_msg"></div><div class="msg_cotainer">';
245
+
246
  for (var i = 0; i < lines.length; i++) {
247
  botHtml += '<div class="msg_cotainer">' + lines[i] + '</div>';
248
  }
 
258
  });
259
  });
260
  </script>
261
+
262
+ <script>
263
+ document.addEventListener("DOMContentLoaded", () => {
264
+ const themeToggle = document.getElementById("themeToggle");
265
+ if (!themeToggle) return; // Prevent errors if button is missing
266
+
267
+ const body = document.body;
268
+
269
+ // Check local storage for a saved theme, default to dark
270
+ const savedTheme = localStorage.getItem("theme") || "dark";
271
+ body.classList.toggle("light-mode", savedTheme === "light");
272
+
273
+ updateButton(); // Update button text on load
274
+
275
+ // Toggle theme on button click
276
+ themeToggle.addEventListener("click", () => {
277
+ body.classList.toggle("light-mode");
278
+ const newTheme = body.classList.contains("light-mode") ? "light" : "dark";
279
+ localStorage.setItem("theme", newTheme);
280
+ updateButton();
281
+ });
282
+
283
+ function updateButton() {
284
+ themeToggle.textContent = body.classList.contains("light-mode") ? "Switch to Dark Mode" : "Switch to Light Mode";
285
+ }
286
+ });
287
+
288
+
289
+ function showPredictiveText(predictions) {
290
+ if (predictions.length > 0 && $("#text").val().trim() !== "") {
291
+
292
+ let html = predictions.map(p => `<p>${p}</p>`).join('');
293
+ $(".predictive-text").html(html).show();
294
+ } else {
295
+ $(".predictive-text").hide();
296
 
297
+ }
298
+ }
299
+ function scrollToBottom() {
300
+ $("#messageFormeight").animate({ scrollTop: $("#messageFormeight")[0].scrollHeight }, 500);
301
+ }
302
+
303
+ $(document).ready(function() {
304
+ $("#clearChat").click(function() {
305
+ $("#messageFormeight").html(""); // Clears the chat area
306
+ localStorage.removeItem("chatHistory"); // Clears stored history
307
+ });
308
+ });
309
+
310
+
311
+ </script>
312
+
313
  </body>
314
 
315
  </html>