-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
477 lines (454 loc) · 21.1 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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Scrollbar in Sidebar | Codehal</title>
<link rel="stylesheet" href="style.css" />
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
crossorigin="anonymous"
/>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css"
/>
</head>
<body>
<div class="d-flex flex-column page">
<img src="navbar.png" class="header" />
<div class="d-flex flex-row" style="overflow: hidden">
<div class="sidebar">
<div class="scrollbox">
<div
class="scrollbox-inner d-flex flex-column align-items-center"
>
<div
class="ppt-card ppt-card-active d-flex justify-content-center align-items-center"
>
1
</div>
<div
class="ppt-card d-flex justify-content-center align-items-center mt-3"
>
2
</div>
<div
class="ppt-card d-flex justify-content-center align-items-center mt-3"
>
3
</div>
<div
class="ppt-card d-flex justify-content-center align-items-center mt-3"
>
4
</div>
<div
class="ppt-card d-flex justify-content-center align-items-center mt-3"
>
5
</div>
<div
class="ppt-card d-flex justify-content-center align-items-center mt-3"
>
6
</div>
<div
class="ppt-card d-flex justify-content-center align-items-center mt-3"
>
7
</div>
<div
class="ppt-card d-flex justify-content-center align-items-center mt-3"
>
8
</div>
<div
class="ppt-card d-flex justify-content-center align-items-center mt-3"
>
9
</div>
</div>
</div>
</div>
<div
style="
background-color: lightgray;
width: 1px;
height: 100%;
"
></div>
<div class="d-flex flex-column flex-fill">
<!-- row contains slide and Bar Chart Data-->
<div class="d-flex flex-row flex-fill">
<!-- Slide -->
<div class="d-flex flex-column">
<div
class="d-flex flex-row flex-fill"
>
<div
style="
padding: 20px;
margin: 20px;
background: white;
position: relative;
border: 1px solid #ccc;
"
class="shadow d-flex flex-column"
>
<!--Title text field and logos-->
<div
class="d-flex flex-row justify-content-between align-items-center"
style="
position: relative;
left: 2.5%;
top: 2.5%;
width: 95%;
height: 10%;
font-size: 60px;
margin: 10px;
"
>
<input
class="no-decoration flex-fill"
placeholder="Title"
style="width: 50%"
/>
<!--Logos-->
<div
class="d-flex flex-row align-items-center"
style="
width: 50%;
justify-content: flex-end;
"
>
<img
style="height: 50px"
src="https://teco.edu/wp-content/themes/teco/images/teco_trans.png"
/>
<img
style="height: 60px"
src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Logo_KIT.svg/2560px-Logo_KIT.svg.png"
/>
</div>
</div>
<!--Text field and graph display-->
<div
class="flex-row"
,
style="
height: 100%;
position: relative;
margin: 10px;
"
>
<textarea
placeholder="Add your text here.."
class="no-decoration"
id="inputField"
onkeyup="addBullets()"
style="
position: absolute;
left: 2.5%;
top: 5%;
width: 47.5%;
height: 95%;
font-size: 22px;
"
></textarea>
<div
class="d-flex justify-content-center align-items-center"
style="
position: absolute;
left: 52.5%;
top: 5%;
width: 47.5%;
height: 95%;
background: lightgray;
"
>
<div
style="
color: gray;
font-family: monospace;
padding: 10px;
"
>
Waiting for data to<br />
generate graph ...
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Bar Chart data -->
<div
class="flex-fill d-flex flex-column shadow"
style="
padding: 20px;
border: 1px solid lightgray;
background-color: rgb(236, 236, 236);
margin: 0px 0px 0px 0px;
min-width: 400px;
border-width: 0px 0px 0px 1px;
overflow: hidden;
"
>
<div
class="d-flex flex-row justify-content-between"
>
<h5>Bar Chart Data</h5>
<button class="btn btn-ppt">
Update Chart
</button>
</div>
<hr />
<div
id="container"
class="flex-fill mb-2"
style="overflow-y: scroll; overflow-x: hidden"
></div>
<div
class="d-flex flex-row justify-content-stretch"
>
<button
class="btn btn-block btn-ppt w-100"
onclick="addRow()"
>
+
</button>
</div>
</div>
</div>
<div
class="flex-fill w-100 p-3 align-items-center d-flex"
style="
width: 100%;
background: rgb(240, 240, 241);
border-top-width: 1px;
border: 1px solid lightgray;
border-width: 1px 0px 0px 0px;
max-height: 120px;
"
>
<button
onclick="generateGraph()"
class="btn btn-ppt justify-content-center"
style="
margin-left: 10px;
width: 190px;
max-height: 300px;
height: 100%;
font-size: 20px;
"
>
<b>Generate Pictograph</b>
</button>
</div>
</div>
</div>
</div>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
crossorigin="anonymous"
></script>
<script>
let slides = Array.from({ length: 9 }, () => ({
title: "",
bulletContent: "",
chartData: [],
}));
let currentSlideIndex = 0;
function addRow() {
const container = document.getElementById("container");
const row = document.createElement("div");
row.className = "row";
row.innerHTML = `
<div class="d-flex flex-row mt-3 justify-content-between">
<input class="no-decoration " type="text" placeholder="Name">
<input class="no-decoration" style="width: 100px" type="number" placeholder="Number">
<button class="no-decoration btn btn-ppt" onclick="deleteRow(this)"><i class="bi bi-trash"></i></button>
</div>
`;
container.append(row);
}
function deleteRow(button) {
const row = button.parentElement.parentElement;
row.remove();
}
function addBullets() {
const inputField = document.getElementById("inputField");
const lines = inputField.value.split("\n");
let formattedText = "";
lines.forEach((line, index) => {
if (line !== "") {
// Add bullet if the line does not already have one
if (!line.startsWith("•")) {
formattedText += "• " + line;
} else {
formattedText += line;
}
// Add newline character if it's not the last line
if (index < lines.length - 1) {
formattedText += "\n";
}
} else {
// Preserve empty lines
if (index < lines.length - 1) {
formattedText += "\n";
}
}
});
inputField.value = formattedText;
}
function generateGraph() {
const title = document.querySelector(
".no-decoration.flex-fill"
).value;
const bulletContent =
document.getElementById("inputField").value;
const rows = document.querySelectorAll(".row");
const data = [];
rows.forEach((row) => {
const inputs = row.querySelectorAll("input");
const name = inputs[0].value;
const number = inputs[1].value;
data.push({ name, number });
});
const csvContent = data
.map((e) => e.name + "," + e.number)
.join("\n");
// Prepare the payload
const payload = {
title: title,
bulletContent: bulletContent,
csvData: csvContent,
};
// Send the POST request
fetch("/inpaint", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
})
.then((response) => response.json())
.catch((error) => {
console.error("Error:", error);
});
}
function saveCurrentSlide() {
const title = document.querySelector(
".no-decoration.flex-fill"
).value;
const bulletContent =
document.getElementById("inputField").value;
const rows = document.querySelectorAll(".row");
const chartData = [];
rows.forEach((row) => {
const inputs = row.querySelectorAll("input");
const name = inputs[0].value;
const number = inputs[1].value;
chartData.push({ name, number });
});
slides[currentSlideIndex] = {
title: title,
bulletContent: bulletContent,
chartData: chartData,
};
}
function loadSlide(index) {
currentSlideIndex = index;
const slide = slides[currentSlideIndex];
document.querySelector(".no-decoration.flex-fill").value =
slide.title;
document.getElementById("inputField").value =
slide.bulletContent;
const container = document.getElementById("container");
container.innerHTML = "";
slide.chartData.forEach((data) => {
const row = document.createElement("div");
row.className = "row";
row.innerHTML = `
<div class="d-flex flex-row mt-3 justify-content-between">
<input class="no-decoration " type="text" placeholder="Name" value="${data.name}">
<input class="no-decoration" style="width: 100px" type="number" placeholder="Number" value="${data.number}">
<button class="no-decoration btn btn-ppt" onclick="deleteRow(this)"><i class="bi bi-trash"></i></button>
</div>
`;
container.append(row);
});
}
const cards = document.querySelectorAll(".ppt-card");
// Add a click event listener to each card
cards.forEach((card, index) => {
card.addEventListener("click", () => {
console.log("clock");
saveCurrentSlide();
// Remove 'ppt-card-active' class from all cards
cards.forEach((c) => c.classList.remove("ppt-card-active"));
// Add 'ppt-card-active' class to the clicked card
card.classList.add("ppt-card-active");
loadSlide(index);
currentSlideIndex = index;
});
});
function handleKeyNavigation(event) {
console.log(currentSlideIndex);
if (
document.activeElement.tagName === "INPUT" ||
document.activeElement.tagName === "TEXTAREA"
) {
return;
}
let activeCard = document.querySelector(".ppt-card-active");
if (event.key === "ArrowUp") {
event.preventDefault();
saveCurrentSlide();
if (currentSlideIndex > 0) {
loadSlide(currentSlideIndex - 1);
}
if (activeCard) {
let prevCard = activeCard.previousElementSibling;
if (
prevCard &&
prevCard.classList.contains("ppt-card")
) {
activeCard.classList.remove("ppt-card-active");
prevCard.classList.add("ppt-card-active");
}
} else {
cards[cards.length - 1].classList.add(
"ppt-card-active"
);
}
} else if (event.key === "ArrowDown") {
event.preventDefault();
saveCurrentSlide();
if (currentSlideIndex < cards.length - 1) {
loadSlide(currentSlideIndex + 1);
}
if (activeCard) {
let nextCard = activeCard.nextElementSibling;
if (
nextCard &&
nextCard.classList.contains("ppt-card")
) {
activeCard.classList.remove("ppt-card-active");
nextCard.classList.add("ppt-card-active");
}
} else {
cards[0].classList.add("ppt-card-active");
}
}
}
// Add a keydown event listener to the document
document.addEventListener("keydown", handleKeyNavigation);
</script>
</body>
</html>