-
Notifications
You must be signed in to change notification settings - Fork 1
/
Explainer.html
325 lines (258 loc) ยท 7.63 KB
/
Explainer.html
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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
<!DOCTYPE html>
<html>
<head>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
<!-- satoshi font family -->
<link
href="https://api.fontshare.com/v2/css?f[]=satoshi@1,900,700,500,300,400&display=swap"
rel="stylesheet"
/>
<!-- inter font family -->
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap"
rel="stylesheet"
/>
<!-- <link rel="stylesheet" type="text/css" href="style.css"> -->
</head>
<body>
<h1>Explainer AI</h1>
<div id="upload-container">
<textarea id="input-text" placeholder="Enter your text here......"></textarea>
<button id="upload-button" onclick="generateExplaination()">Generate Explaination</button>
</div>
<div id="loading-message">Waiting for your input...</div>
<div id ="tab-area"class="tab">
<div id="tab-content-container">
<div id="simple-container">
<button class="tab-button" id="simple-btn" value="OFF" onclick="toggleSimpleContent()">See Explaination</button>
<div id="simplecontent" class="tab-content">
<div id="typewriter">
<p id="simplesummary"></p>
</div>
</div>
</div>
</div>
</div>
</body>
<style>
/* style.css */
/* Reset default margin and padding */
body, h1, p {
margin: 25px;
padding: 0;
color: #000000;
}
/* Set background and text color for the page */
body {
background-color: #ff961e;
color: #333;
font-family: 'Satoshi', sans-serif;
}
/* Center align the h1 */
h1 {
margin-top: 5px;
font-size: 60px;
font-weight:800;
line-height: 1.15;
color: #000;
text-align: center;
}
/* Style the tab content */
#tab-content-container {
display: flex;
justify-content: space-evenly;
}
/* Style the tab buttons */
.tab-button {
border: none;
background-color: #5fd4ff;
color: #000000;
padding: 10px 20px;
margin-bottom: 10px;
border-radius: 5px;
font-size: 20px;
cursor: pointer;
outline: none;
transition: background-color 0.3s ease;
}
.tab-button:hover {
background-color: #ffd000;
}
.tab-button.active {
background-color: #0821ff;
}
.tab-content {
background-color: #ffffff;
padding: 20px;
margin-bottom: 20px;
max-width: 500px;
height: auto;
}
/* Show the active tab content */
.tab-content.active {
display: block;
}
#simple-container{
display: flex;
flex-direction: column;
}
/* make the initail code display hidden */
#simplecontent{
display: none;
border-radius: 10px;
max-width: 500px;
}
#upload-container {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 20px;
margin-bottom: 50px;
}
#input-text {
width: 60%;
height: 250px;
padding: 10px;
font-size: 16px;
border-radius: 5px;
border: 1px solid #ccc;
resize: vertical;
margin-bottom: 10px;
}
#upload-button {
border: none;
background-color: #00bbff;
color: #000000;
padding: 10px 20px;
border-radius: 5px;
font-size: 20px;
cursor: pointer;
outline: none;
}
#upload-button:hover {
background-color: #ffd000;
margin: 5px;
}
.blinking-cursor {
margin-left: 5px;
background-color: #7d7a7a;
animation: blink 1s infinite;
}
#tab-area{
display: none;
}
#loading-message {
text-align: center;
font-size: 30px;
font-weight: bold;
margin-top: 20px;
margin-bottom: 30px;
color: #000000;
}
</style>
<script>
// Get the button and content elements
let simpleBtn = document.getElementById("simple-btn");
let simplecontent = document.getElementById("simplecontent");
let uploadBtn = document.getElementById("upload-button")
let tabArea = document.getElementById("tab-area")
const typewriter = document.getElementById('typewriter');
const simpleSummary = document.getElementById("simplesummary");
const text = simpleSummary.textContent;
let inputText = String;
function generateExplaination() {
var loadingMessage = document.getElementById("loading-message");
var inputText = document.getElementById("input-text").value;
// Array of loading messages
var loadingMessages = [
"Initializing... ๐",
"Loading Resources... โ๏ธ",
"Generating a magical summary for you โจ",
"Setting up the environment...๐๏ธ",
"Doing the Hidden API work...๐ต๏ธ",
"Verifying data integrity...โ
",
"Cross-checking references...๐",
"Verifying accuracy...โ๏ธ",
"Double-checking calculations...๐งฎ",
"Adding finishing touches...๐๏ธ",
"Testing functionality...๐งช",
"Reviewing the results...๐",
"Validating inputs...๐",
"Here you go!...๐"
];
// Function to update the loading message with a delayed effect
function updateLoadingMessage(index) {
loadingMessage.textContent = loadingMessages[index];
// Increment the index
index++;
if (index < loadingMessages.length) {
// Call the function recursively after the delay
setTimeout(function() {
updateLoadingMessage(index);
}, 1000);
} else {
// Hide loading message and show tab area
loadingMessage.style.display = "none";
tabArea.style.display = "block";
}
}
// Start updating the loading message
updateLoadingMessage(0);
var xhr = new XMLHttpRequest();
// Set up the request
xhr.open("POST", "/explain-text", true);
xhr.setRequestHeader("Content-Type", "application/json");
// Define the request payload
var payload = {
text: inputText
};
// Convert the payload to JSON string
var payloadJson = JSON.stringify(payload);
// Set up the event handler for when the response is received
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
var response = JSON.parse(xhr.responseText);
var explaination = response.explaination;
var summaryTextArea = document.getElementById("simplecontent");
var paragraph = document.getElementById("simplesummary"); // Get the existing paragraph element
var indexSummary = 0; // Current index of the summary text
var indexExpertSummary = 0; // Current index of the expertsummary text
var delay = 20; // Delay between each character (adjust as needed)
// Function to update the text content with a delayed effect
function updateSummaryText() {
// Update the text content of the paragraph with bullet points
paragraph.innerHTML = explaination;
// Increment the index
indexSummary++;
// Check if there are more characters to update
if (indexSummary <= summary.length) {
// Call the function recursively after the delay
setTimeout(updateSummaryText, delay);
}
}
// Start updating the summary text content with a delayed effect
updateSummaryText();
}
};
// Send the request
xhr.send(payloadJson);
}
window.addEventListener("load",()=>{
function toggleSimpleContent() {
if(simpleBtn.value == "OFF"){
simplecontent.style.display = "block";
simpleBtn.value = "ON";
}
else if (simpleBtn.value == "ON")
{
simplecontent.style.display = "none";
simpleBtn.value = "OFF";
}
}
simpleBtn.addEventListener("click", toggleSimpleContent);
// uploadBtn.addEventListener("click",generateExplaination);
})
</script>
</html>