-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
406 lines (325 loc) ยท 10.5 KB
/
index.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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
<!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>AI Summary Generator</h1>
<div id="upload-container">
<textarea id="input-text" placeholder="Enter your text here......"></textarea>
<button id="upload-button" onclick="generateSummary()">Generate</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()">Simple Summary AI</button>
<div id="simplecontent" class="tab-content">
<div id="typewriter">
<p id="git-summary"></p>
</div>
</div>
</div>
<div id ="expert-container">
<button class="tab-button" id="expert-btn" value="OFF" onclick="toggleExpertContent()">Expert Summary AI</button>
<div id="expertcontent" class="tab-content">
<p id="expertsummary"></p>
</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;
}
#expert-container{
display: flex;
flex-direction: column;
}
/* make the initail code display hidden */
#simplecontent{
display: none;
border-radius: 10px;
max-width: 500px;
}
#expertcontent{
border-radius: 10px;
display: none;
}
#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 expertBtn = document.getElementById("expert-btn");
let uploadBtn = document.getElementById("upload-button")
let expertcontent = document.getElementById("expertcontent");
let tabArea = document.getElementById("tab-area")
const typewriter = document.getElementById('typewriter');
const gitSummary = document.getElementById("git-summary");
const text = gitSummary.textContent;
let inputText = String;
function generateSummary() {
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", "/process-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 summary = response.summary; // Get the 'summary' property from the response object
var expertsummary = response.expertsummary; // Get the expert property from response
var summaryTextArea = document.getElementById("simplecontent");
var paragraph = document.getElementById("git-summary"); // Get the existing paragraph element
// Display otherValue in 'expertcontent' div
var expertTextArea = document.getElementById("expertcontent");
var expertparagraph = document.getElementById("expertsummary"); // 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() {
// Get a portion of the summary text based on the current index
var partialSummary = summary.substring(0, indexSummary);
// Replace full stops with full stops followed by bullet points
partialSummary = partialSummary.replace(/\./g, '.<br>->');
// // Update the text content of the paragraph
// paragraph.textContent = partialSummary;
// Update the text content of the paragraph with bullet points
paragraph.innerHTML = 'Simple Summary: <br>' + partialSummary;
// 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);
}
}
// Function to update the expertsummary text content with a delayed effect
function updateExpertSummaryText() {
// Get a portion of the expertsummary text based on the current index
var partialExpertSummary = expertsummary.substring(0, indexExpertSummary);
// Update the text content of the expertparagraph
expertparagraph.textContent = partialExpertSummary;
// Increment the index
indexExpertSummary++;
// Check if there are more characters to update
if (indexExpertSummary <= expertsummary.length) {
// Call the function recursively after the delay
setTimeout(updateExpertSummaryText, delay);
}
}
// Start updating the summary text content with a delayed effect
updateSummaryText();
// Start updating the expertsummary text content with a delayed effect
updateExpertSummaryText();
}
};
// 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";
}
}
// Function to toggle the display of the expert content
function toggleExpertContent() {
if (expertBtn.value == "OFF") {
expertcontent.style.display = "block";
expertBtn.value = "ON";
}
else if (expertBtn.value == "ON") {
expertcontent.style.display = "none";
expertBtn.value = "OFF";
}
}
simpleBtn.addEventListener("click", toggleSimpleContent);
expertBtn.addEventListener("click", toggleExpertContent);
// uploadBtn.addEventListener("click",generateSummary);
// let index = 0;
// function type() {
// if (index < text.length) {
// typewriter.innerHTML = text.slice(0, index) + '<span class="blinking-cursor">|</span>';
// index++;
// setTimeout(type, Math.random() * 100 +20 );
// } else {
// typewriter.innerHTML = text.slice(0, index) + '<span class="blinking-cursor">|</span>';
// }
// }
// // start typing
// type();
})
// export { inputText };
</script>
</html>