Update index.html
Browse files- index.html +210 -197
index.html
CHANGED
@@ -1,200 +1,213 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
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 |
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
+
<head>
|
4 |
+
<title>Jio Search</title>
|
5 |
+
<link rel="icon" type="image/png" href="../static/Jio-Logo.png" />
|
6 |
+
<link rel="apple-touch-icon" type="image/png" href="../static/Jio-Logo.png" />
|
7 |
+
<style>
|
8 |
+
body {
|
9 |
+
background-color: #ECE5DD;
|
10 |
+
font-family: Arial, sans-serif;
|
11 |
+
font-size: 14px;
|
12 |
+
padding: 20px;
|
13 |
+
}
|
14 |
+
.container {
|
15 |
+
display: flex;
|
16 |
+
flex-direction: column;
|
17 |
+
height: 900px;
|
18 |
+
/* max-width: 700px;*/
|
19 |
+
margin: 0 auto;
|
20 |
+
background-color: #fff;
|
21 |
+
border-radius: 10px;
|
22 |
+
box-shadow: 0px 5px 10px rgba(0,0,0,0.1);
|
23 |
+
overflow: hidden;
|
24 |
+
}
|
25 |
+
.header {
|
26 |
+
display: flex;
|
27 |
+
align-items: center;
|
28 |
+
justify-content: center;
|
29 |
+
height: 60px;
|
30 |
+
background-color:#0f3cc9 ;
|
31 |
+
/* #075E54 */
|
32 |
+
color: #fff;
|
33 |
+
font-weight: bold;
|
34 |
+
font-size: 20px;
|
35 |
+
}
|
36 |
+
.chat-area {
|
37 |
+
flex-grow: 1;
|
38 |
+
padding: 20px;
|
39 |
+
overflow-y: auto;
|
40 |
+
}
|
41 |
+
.chat-area p {
|
42 |
+
margin: 5px 0;
|
43 |
+
}
|
44 |
+
.message-box {
|
45 |
+
display: flex;
|
46 |
+
align-items: center;
|
47 |
+
background-color: #F4F4F4;
|
48 |
+
padding: 10px;
|
49 |
+
border-top: 1px solid #ccc;
|
50 |
+
}
|
51 |
+
.message-box input {
|
52 |
+
flex-grow: 1;
|
53 |
+
border: none;
|
54 |
+
padding: 10px;
|
55 |
+
font-size: 14px;
|
56 |
+
border-radius: 5px;
|
57 |
+
background-color: #fff;
|
58 |
+
margin-right: 10px;
|
59 |
+
}
|
60 |
+
.message-box button {
|
61 |
+
background-color:#0f3cc9 ;
|
62 |
+
/* #075E54 */
|
63 |
+
color: #fff;
|
64 |
+
border: none;
|
65 |
+
padding: 10px;
|
66 |
+
font-size: 14px;
|
67 |
+
font-weight: bold;
|
68 |
+
border-radius: 5px;
|
69 |
+
cursor: pointer;
|
70 |
+
}
|
71 |
+
.user-message {
|
72 |
+
display: flex;
|
73 |
+
flex-direction: row-reverse;
|
74 |
+
align-items: center;
|
75 |
+
margin-bottom: 10px;
|
76 |
+
}
|
77 |
+
.bot-message {
|
78 |
+
display: flex;
|
79 |
+
align-items: center;
|
80 |
+
margin-bottom: 10px;
|
81 |
+
}
|
82 |
+
.user-message p, .bot-message p {
|
83 |
+
background-color:#ccd6f2;
|
84 |
+
/* #DCF8C6; */
|
85 |
+
color: #000;
|
86 |
+
padding: 10px;
|
87 |
+
border-radius: 10px;
|
88 |
+
max-width: 60%;
|
89 |
+
word-wrap: break-word;
|
90 |
+
}
|
91 |
+
.user-message p {
|
92 |
+
margin-right: 10px;
|
93 |
+
}
|
94 |
+
.bot-message p {
|
95 |
+
margin-left: 10px;
|
96 |
+
}
|
97 |
+
|
98 |
+
.logoClass
|
99 |
+
{
|
100 |
+
width: 50px;
|
101 |
+
height: 40px;
|
102 |
+
align-self: center;
|
103 |
+
margin-right: 10px;
|
104 |
+
gap: 20px 20px;
|
105 |
+
background-repeat: no-repeat;
|
106 |
+
background-size: cover;
|
107 |
+
/* background-image: url({{url_for('static',filename='Jio-Logo.png')}}); */
|
108 |
+
}
|
109 |
+
</style>
|
110 |
+
</head>
|
111 |
+
<body>
|
112 |
+
<div class="container">
|
113 |
+
<div class="header">
|
114 |
+
<div><img class="logoClass" src="../static/Jio-Logo.png" alt="Jio Logo"/> </div>
|
115 |
+
<div>Search Powered by Jio Embedding Engine</div>
|
116 |
+
</div>
|
117 |
+
|
118 |
+
<div class="message-box">
|
119 |
+
<input id="user-input" type="text" placeholder="Enter your Search Query..." onkeyup="return searchKeyPress(event)">
|
120 |
+
<button id="send-button" onclick="sendMessage()">Search</button>
|
121 |
+
</div>
|
122 |
+
|
123 |
+
<div class="chat-area">
|
124 |
+
<!-- <div class="bot-message">
|
125 |
+
<p>Hello! How can I assist you today?</p>
|
126 |
+
</div> -->
|
127 |
+
</div>
|
128 |
+
|
129 |
+
</div>
|
130 |
+
|
131 |
+
<script>
|
132 |
+
|
133 |
+
function searchKeyPress(event) {
|
134 |
+
event.preventDefault();
|
135 |
+
if (event.keyCode === 13) {
|
136 |
+
document.getElementById("send-button").click();
|
137 |
+
}
|
138 |
+
};
|
139 |
+
|
140 |
+
async function sendMessage() {
|
141 |
+
var response="";
|
142 |
+
// Get the user input
|
143 |
+
document.querySelector(".chat-area").innerHTML = ""
|
144 |
+
var userInput = document.getElementById("user-input").value;
|
145 |
+
|
146 |
+
// Create a new user message and add it to the chat area
|
147 |
+
var userMessage = document.createElement("div");
|
148 |
+
userMessage.classList.add("bot-message");
|
149 |
+
userMessage.innerHTML = '<p> Your Search Results for <b> “' + userInput + '” </b></p>';
|
150 |
+
document.querySelector(".chat-area").appendChild(userMessage);
|
151 |
+
|
152 |
+
// Clear the input field
|
153 |
+
document.getElementById("user-input").value = "";
|
154 |
+
|
155 |
+
|
156 |
+
|
157 |
+
// Generate a bot response
|
158 |
+
var botResponse = await generateBotResponse(userInput);
|
159 |
+
|
160 |
+
|
161 |
+
}
|
162 |
+
|
163 |
+
async function generateBotResponse(userInput) {
|
164 |
+
// Make a POST request to the chatbot API endpoint
|
165 |
+
// response = await fetch('http://127.0.0.1:1111/post_json', {
|
166 |
+
// method: 'POST',
|
167 |
+
// headers: {
|
168 |
+
// 'Content-Type': 'application/json'
|
169 |
+
// },
|
170 |
+
// body: JSON.stringify({
|
171 |
+
// query: userInput
|
172 |
+
// })
|
173 |
+
// });
|
174 |
+
|
175 |
+
var xhr = new XMLHttpRequest();
|
176 |
+
//xhr.open("POST", 'http://127.0.0.1:1111/post_json', true);
|
177 |
+
xhr.open("POST", '/post_json', true);
|
178 |
+
xhr.setRequestHeader('Content-Type', 'application/json');
|
179 |
+
xhr.send(JSON.stringify({
|
180 |
+
query: userInput
|
181 |
+
}));
|
182 |
+
|
183 |
+
xhr.onload = function() {
|
184 |
+
|
185 |
+
console.log(this.responseText);
|
186 |
+
var responseArray = JSON.parse(this.responseText).botMessage;
|
187 |
+
console.log(responseArray);
|
188 |
+
|
189 |
+
// Create a new bot message and add it to the chat area
|
190 |
+
for(let i = 0; i < responseArray.length; i++)
|
191 |
+
{
|
192 |
+
response=responseArray[i]
|
193 |
+
var botMessage = document.createElement("div");
|
194 |
+
botMessage.classList.add("bot-message");
|
195 |
+
botMessage.innerHTML = '<p> <b> Source :: </b><a>' + response.documentSource + '</a> <br> <br> <b> Semantically Matching Content::</b> '+response.pageContent+'</p>';
|
196 |
+
document.querySelector(".chat-area").appendChild(botMessage);
|
197 |
+
|
198 |
+
// Scroll to the bottom of the chat area
|
199 |
+
document.querySelector('.chat-area').scrollTop = document.querySelector('.chat-area').scrollHeight;
|
200 |
+
}
|
201 |
+
|
202 |
+
return response.botMessage;
|
203 |
+
}
|
204 |
+
|
205 |
+
// Parse the response JSON and return the bot message
|
206 |
+
//console.log(data);
|
207 |
+
//var data = await response.json();
|
208 |
+
|
209 |
+
//return response.botMessage;
|
210 |
+
}
|
211 |
+
</script>
|
212 |
+
</body>
|
213 |
</html>
|