LiamDowd commited on
Commit
6b4b98e
1 Parent(s): 83851a0

Upload chat.html

Browse files
Files changed (1) hide show
  1. templates/chat.html +862 -0
templates/chat.html ADDED
@@ -0,0 +1,862 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Redact</title>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css">
9
+ </head>
10
+
11
+ <body>
12
+ <div id="fileUploadModal" class="modal">
13
+ <div class="modal-content">
14
+ <span class="close-btn" onclick="closeFileUploadModal()">&times;</span>
15
+ <div class="load"></div>
16
+ <br>
17
+ <div class="file-upload">
18
+ <label for="upload" class="file-upload__label">Upload PDF Files</label>
19
+ <input type="file" name="pdf-file" class="file-upload__input" style="padding:10px" multiple="true" id="upload"
20
+ onchange="updateFileNames()" required>
21
+ </div>
22
+
23
+ <h1 class="text-success" id="uploadedFileNames"></h1>
24
+ <h1 class="text-timer" id="timer"></h1>
25
+
26
+ <br><br>
27
+ <button type="button" onclick="uploadDocument()" class="flipping-button">
28
+ <span>
29
+ <em>Process</em>
30
+ </span>
31
+ <span>
32
+ <em>Submit</em>
33
+ </span>
34
+ </button>
35
+ </div>
36
+ </div>
37
+
38
+ <div id="documentsModal" class="modal">
39
+ <div class="modal-content-documents">
40
+ <span class="close-btn-documents" onclick="closeDocumentsModal()">&times;</span>
41
+ <h1 id="title-documents">Documents</h1>
42
+ <ul id="fileList">
43
+ {% for document in documents %}
44
+ <a class="links" href="/document?name={{ document }}" target="_blank">
45
+ <li>
46
+ {{ document }}
47
+ </li>
48
+ </a>
49
+ {% endfor %}
50
+ </ul>
51
+
52
+ <button class="clear" onclick="location.href = '/clear'">Delete All Documents</button>
53
+ </div>
54
+ </div>
55
+
56
+ <section class="message">
57
+ <header class="message-header">
58
+ <div class="message-header-title">
59
+ <i class="fas fa-scroll"></i> Redact
60
+ </div>
61
+ <div class="message-header-options">
62
+ <a onclick="openDocumentsModal();" id="files-update" style="cursor: pointer;"><i class="fas fa-folder-open"
63
+ id="files"></i> <span class="font-update" style="cursor: pointer;">Files</span></a>
64
+ <a onclick="openFileUploadModal();" id="documents-update"><i class="fas fa-file-upload" id="upload"></i> <span
65
+ class="font-update" style="cursor:pointer;">Upload</span></a>
66
+ </div>
67
+ </header>
68
+
69
+ <main class="message-chat">
70
+ {% for right_msg, left_msg in history %}
71
+ {% if right_msg %}
72
+ <div class="msg right-msg">
73
+ <div class="msg-bubble">
74
+ <div class="msg-text">{{ right_msg }}</div>
75
+ </div>
76
+ </div>
77
+ {% endif %}
78
+
79
+ {% if left_msg %}
80
+ <div class="msg left-msg">
81
+ <div class="msg-bubble">
82
+ <div class="msg-text">{{ left_msg }}</div>
83
+ </div>
84
+ </div>
85
+ {% endif %}
86
+ {% endfor %}
87
+ </main>
88
+
89
+ <div class="message-inputarea">
90
+ <input type="text" class="message-input" placeholder="Message RedactAI..." id="messageInput">
91
+ <button class="message-send-btn" onclick="sendMessage()">Send</button>
92
+ </div>
93
+
94
+ <h3 id="info">Redact can make mistakes. Be sure to double check important information.</h3>
95
+
96
+ <style>
97
+ :root {
98
+ --body-bg: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
99
+ --message-bg: #2a2836;
100
+ --border-bottom: 2px solid #2a2836;
101
+ --left-msg-bg: gray;
102
+ --right-msg-bg: #218aff;
103
+
104
+ --base-line-height: 24px;
105
+ --white: rgb(255, 255, 255);
106
+ --off-white: rgba(255, 255, 255, 0.2);
107
+ --spin-duration: 1s;
108
+ --pulse-duration: 750ms;
109
+ }
110
+
111
+ html {
112
+ box-sizing: border-box;
113
+ }
114
+
115
+ a,
116
+ a:hover,
117
+ a:visited,
118
+ a:active {
119
+ color: inherit;
120
+ text-decoration: none;
121
+ }
122
+
123
+ *,
124
+ *:before,
125
+ *:after {
126
+ margin: 0;
127
+ padding: 0;
128
+ box-sizing: inherit;
129
+ }
130
+
131
+ body {
132
+ display: flex;
133
+ justify-content: center;
134
+ align-items: center;
135
+ height: 100vh;
136
+ font-family: Helvetica, sans-serif;
137
+ background-color: #2a2836;
138
+ }
139
+
140
+ .message {
141
+ display: flex;
142
+ flex-flow: column wrap;
143
+ justify-content: space-between;
144
+ width: 100%;
145
+ max-width: 100%;
146
+ height: calc(100%);
147
+ margin-top: 0;
148
+ border: var(--border);
149
+ border-radius: 5px;
150
+ background: var(--message-bg);
151
+ box-shadow: 0 15px 15px -5px rgba(0, 0, 0, 0.2);
152
+ }
153
+
154
+ ul {
155
+ list-style-type: none;
156
+ padding: 0;
157
+ }
158
+
159
+ li {
160
+ margin: 10px 0;
161
+ padding: 10px;
162
+ border: 1px solid #ccc;
163
+ border-radius: 5px;
164
+ background-color: #f9f9f9;
165
+ cursor: pointer;
166
+ transition: background-color 0.3s;
167
+ }
168
+
169
+ li:hover {
170
+ background-color: #e0e0e0;
171
+ }
172
+
173
+ .clear {
174
+ margin-top: 50px;
175
+ display: inline-block;
176
+ position: relative;
177
+ left: 50%;
178
+ transform: translate(-50%, -50%);
179
+ background-color: #f43535;
180
+ color: #fff;
181
+ padding: 10px;
182
+ border-radius: 10px;
183
+ border-style: none;
184
+ font-size: 1em;
185
+ position: absolute;
186
+ top: 75%;
187
+ left: 50%;
188
+ transform: translate(-50%, -50%);
189
+ z-index: 1001;
190
+ cursor: pointer;
191
+ }
192
+
193
+ #files-update {
194
+ position: absolute;
195
+ top: 10px;
196
+ right: 170px;
197
+ }
198
+
199
+ #documents-update {
200
+ position: absolute;
201
+ top: 20px;
202
+ right: 25px;
203
+ }
204
+
205
+ #fileList {
206
+ position: absolute;
207
+ top: 50%;
208
+ left: 50%;
209
+ transform: translate(-50%, -50%);
210
+ width: 50%;
211
+ height: 50%;
212
+ text-align: center;
213
+ z-index: 1001;
214
+ }
215
+
216
+ .links {
217
+ text-decoration: none;
218
+ color: #333;
219
+ font-weight: bold;
220
+ }
221
+
222
+ .font-update {
223
+ font-family: Helvetica, sans-serif;
224
+ font-style: normal;
225
+ display: inline-block;
226
+ font-size: 1em;
227
+ font-weight: 600;
228
+ }
229
+
230
+ .message-header {
231
+ display: flex;
232
+ justify-content: space-between;
233
+ padding: 12.5px;
234
+ border-bottom: var(--border);
235
+ background: #eee;
236
+ color: #676;
237
+ }
238
+
239
+ .message-header-title {
240
+ font-family: Helvetica, sans-serif;
241
+ font-style: normal;
242
+ display: inline-block;
243
+ font-size: 2em;
244
+ font-weight: 600;
245
+ margin-left: 25px;
246
+ }
247
+
248
+ .message-header-options {
249
+ margin: 0;
250
+ padding: 0;
251
+ font-size: 1.5em;
252
+ }
253
+
254
+ .message-chat {
255
+ flex: 1;
256
+ overflow-y: auto;
257
+ padding: 10px;
258
+ }
259
+
260
+ .msg {
261
+ display: flex;
262
+ align-items: flex-end;
263
+ margin-bottom: 10px;
264
+ }
265
+
266
+ .msg:last-of-type {
267
+ margin: 0;
268
+ }
269
+
270
+ .msg-img {
271
+ width: 50px;
272
+ height: 50px;
273
+ margin-right: 10px;
274
+ background: #ddd;
275
+ background-repeat: no-repeat;
276
+ background-position: center;
277
+ background-size: cover;
278
+ border-radius: 50%;
279
+ display: none;
280
+ }
281
+
282
+ .msg-bubble {
283
+ color: #FFFCF9;
284
+ font-size: 1em;
285
+ max-width: 450px;
286
+ padding: 15px;
287
+ border-radius: 15px;
288
+ background: var(--left-msg-bg);
289
+ }
290
+
291
+ .msg-info {
292
+ display: flex;
293
+ justify-content: space-between;
294
+ align-items: center;
295
+ margin-bottom: 10px;
296
+ }
297
+
298
+ .left-msg .msg-bubble {
299
+ border-bottom-left-radius: 0;
300
+ }
301
+
302
+ .right-msg {
303
+ flex-direction: row-reverse;
304
+ }
305
+
306
+ .right-msg .msg-bubble {
307
+ background: var(--right-msg-bg);
308
+ color: #fff;
309
+ border-bottom-right-radius: 0;
310
+ }
311
+
312
+ .right-msg .msg-img {
313
+ margin: 0 0 0 10px;
314
+ }
315
+
316
+ .message-inputarea {
317
+ display: flex;
318
+ padding: 30px;
319
+ padding-bottom: 40px;
320
+ border-top: var(--border);
321
+ background: #FFFCF9;
322
+ -webkit-border-radius: 25px 25px 0px 0px;
323
+ border-radius: 25px 25px 0px 0px;
324
+ }
325
+
326
+ .message-inputarea * {
327
+ padding: 10px;
328
+ border: none;
329
+ border-radius: 3px;
330
+ font-size: 1em;
331
+ }
332
+
333
+ .message-input {
334
+ font-family: Helvetica, sans-serif;
335
+ font-style: normal;
336
+ display: inline-block;
337
+ font-size: 1.125rem;
338
+ font-weight: 400;
339
+ flex: 1;
340
+ background: #ddd;
341
+ }
342
+
343
+ .message-send-btn {
344
+ font-family: Helvetica, sans-serif;
345
+ font-size: 1.5em;
346
+ margin-left: 10px;
347
+ background: #218aff;
348
+ color: #fff;
349
+ font-weight: bold;
350
+ cursor: pointer;
351
+ transition: background 0.23s;
352
+ border-radius: 15px;
353
+ }
354
+
355
+ .message-send-btn:hover {
356
+ background: #218aff;
357
+ }
358
+
359
+ .message-chat {
360
+ font-family: Helvetica, sans-serif;
361
+ font-style: normal;
362
+ display: inline-block;
363
+ font-size: 1.125rem;
364
+ font-weight: 400;
365
+ width: 95%;
366
+ position: absolute;
367
+ top: 50%;
368
+ left: 50%;
369
+ transform: translate(-50%, -50%);
370
+ background-color: #2a2836;
371
+ height: 65%;
372
+ }
373
+
374
+ #files {
375
+ margin-top: 12.5%;
376
+ margin-bottom: 0;
377
+ }
378
+
379
+ #upload {
380
+ cursor: pointer;
381
+ margin-right: 5px;
382
+ margin-bottom: 0;
383
+ }
384
+
385
+ .modal {
386
+ display: none;
387
+ position: fixed;
388
+ top: 0;
389
+ left: 0;
390
+ width: 100%;
391
+ height: 100%;
392
+ background-color: rgba(0, 0, 0, 0.5);
393
+ justify-content: center;
394
+ align-items: center;
395
+ z-index: 999;
396
+ backdrop-filter: blur(5px);
397
+ }
398
+
399
+ .modal-content {
400
+ width: 50%;
401
+ height: 50%;
402
+ background-color: #ffffff;
403
+ padding: 20px;
404
+ border-radius: 15px;
405
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
406
+ text-align: center;
407
+ float: none;
408
+ display: flex;
409
+ flex-direction: row;
410
+ flex-wrap: wrap;
411
+ justify-content: center;
412
+ align-items: center;
413
+ }
414
+
415
+ .modal-content-documents {
416
+ width: 80%;
417
+ height: 80%;
418
+ background-color: #ffffff;
419
+ padding: 20px;
420
+ border-radius: 15px;
421
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
422
+ text-align: center;
423
+ float: none;
424
+ display: flex;
425
+ flex-direction: row;
426
+ flex-wrap: wrap;
427
+ justify-content: center;
428
+ align-items: center;
429
+ }
430
+
431
+ .flipping-button {
432
+ display: flex;
433
+ flex-direction: column;
434
+ align-items: center;
435
+ overflow: hidden;
436
+ line-height: 1;
437
+ border-radius: 0.7rem;
438
+ padding: .815rem 1.232rem;
439
+ cursor: pointer;
440
+ border: none;
441
+ color: #fff;
442
+ background: #2a2836;
443
+ transition: background .4s linear;
444
+ will-change: background;
445
+ position: absolute;
446
+ top: 60%;
447
+ left: 50%;
448
+ transform: translate(-50%, -50%);
449
+ }
450
+
451
+ .flipping-button:hover {
452
+ color: #fff;
453
+ background: #218aff;
454
+ }
455
+
456
+ .flipping-button:hover span:nth-of-type(1) em {
457
+ opacity: 0;
458
+ transform: rotateX(90deg) scaleX(.9) translate3d(0, -10px, 0);
459
+ }
460
+
461
+ .flipping-button:hover span:nth-of-type(2) em {
462
+ opacity: 1;
463
+ transform: rotateX(0deg) scaleX(1) translateZ(0);
464
+ transition: transform .75s cubic-bezier(.645, .045, .355, 1), opacity .35s linear .3s;
465
+ }
466
+
467
+ #title-documents {
468
+ position: absolute;
469
+ top: 15%;
470
+ left: 50%;
471
+ transform: translate(-50%, -50%);
472
+ width: 100%;
473
+ text-align: center;
474
+ font-family: Helvetica, sans-serif;
475
+ font-style: normal;
476
+ display: inline-block;
477
+ font-size: 1.5em;
478
+ font-weight: 600;
479
+ z-index: 10001;
480
+ }
481
+
482
+ #info {
483
+ position: absolute;
484
+ top: 97%;
485
+ left: 50%;
486
+ transform: translate(-50%, -50%);
487
+ width: 100%;
488
+ text-align: center;
489
+ font-family: Helvetica, sans-serif;
490
+ font-style: normal;
491
+ display: inline-block;
492
+ font-size: 1em;
493
+ font-weight: 400;
494
+
495
+ }
496
+
497
+ span {
498
+ position: relative;
499
+ display: block;
500
+ perspective: 108px;
501
+ }
502
+
503
+ span:nth-of-type(2) {
504
+ position: absolute;
505
+ }
506
+
507
+ em {
508
+ font-style: normal;
509
+ display: inline-block;
510
+ font-size: 1.125rem;
511
+ color: #fff;
512
+ font-weight: 600;
513
+ will-change: transform, opacity, transition;
514
+ transition: transform .55s cubic-bezier(.645, .045, .355, 1), opacity .35s linear .2s;
515
+ }
516
+
517
+ span:nth-of-type(1) em {
518
+ transform-origin: top;
519
+ }
520
+
521
+ span:nth-of-type(2) em {
522
+ opacity: 0;
523
+ transform: rotateX(-90deg) scaleX(.9) translate3d(0, 10px, 0);
524
+ transform-origin: bottom;
525
+ }
526
+
527
+ .file-upload {
528
+ display: inline-block;
529
+ position: absolute;
530
+ top: 45%;
531
+ left: 50%;
532
+ transform: translate(-50%, -50%);
533
+ cursor: pointer;
534
+ }
535
+
536
+ .file-upload__label {
537
+ font-family: Helvetica, sans-serif;
538
+ font-style: normal;
539
+ display: inline-block;
540
+ font-size: 1.125rem;
541
+ color: #fff;
542
+ font-weight: 600;
543
+ display: block;
544
+ padding: 1em 2em;
545
+ color: #fff;
546
+ background: #2a2836;
547
+ border-radius: .4em;
548
+ transition: background .3s;
549
+ cursor: pointer;
550
+
551
+ &:hover {
552
+ cursor: pointer;
553
+ background: #000;
554
+ }
555
+ }
556
+
557
+ .file-upload__input {
558
+ cursor: pointer;
559
+ position: absolute;
560
+ left: 0;
561
+ top: 0;
562
+ right: 0;
563
+ bottom: 0;
564
+ font-size: 1;
565
+ width: 0;
566
+ height: 100%;
567
+ opacity: 0;
568
+ background-color: #2a2836;
569
+ font-family: Helvetica, sans-serif;
570
+ }
571
+
572
+ .text-success {
573
+ position: absolute;
574
+ top: 40%;
575
+ left: 50%;
576
+ transform: translate(-50%, -50%);
577
+ z-index: 1000;
578
+ color: #2a2836;
579
+ font-style: normal;
580
+ display: inline-block;
581
+ font-size: 1.125rem;
582
+ font-weight: 600;
583
+ font-size: 2em;
584
+ }
585
+
586
+ .close-btn {
587
+ cursor: pointer;
588
+ font-size: 60px;
589
+ font-weight: bold;
590
+ color: #f43535;
591
+ position: absolute;
592
+ top: 30%;
593
+ left: 30%;
594
+ transform: translate(-50%, -50%);
595
+ z-index: 10002;
596
+ }
597
+
598
+ .close-btn-documents {
599
+ cursor: pointer;
600
+ font-size: 60px;
601
+ font-weight: bold;
602
+ color: #f43535;
603
+ position: absolute;
604
+ top: 15%;
605
+ left: 15%;
606
+ transform: translate(-50%, -50%);
607
+ z-index: 10002;
608
+ }
609
+
610
+ .load {
611
+ border-radius: 50%;
612
+ width: var(--base-line-height);
613
+ height: var(--base-line-height);
614
+ border: 0.25rem solid #D3D3D3;
615
+ border-top-color: #000;
616
+ animation: spin var(--spin-duration) infinite linear;
617
+ z-index: 1001;
618
+ position: absolute;
619
+ top: 40%;
620
+ left: calc(50%-80px);
621
+ margin: 0 auto;
622
+ justify-content: center;
623
+ width: 80px;
624
+ height: 80px;
625
+ display: none;
626
+ }
627
+
628
+ #timer {
629
+ display: none;
630
+ position: absolute;
631
+ z-index: 1001;
632
+ top: 62.5%;
633
+ left: 50%;
634
+ transform: translate(-50%, -50%);
635
+ }
636
+
637
+ .spin-animation {
638
+ -webkit-animation: spin 1s linear infinite;
639
+ animation: spin 1s linear infinite;
640
+ }
641
+
642
+ @-webkit-keyframes spin {
643
+ 0% {
644
+ -webkit-transform: rotate(0deg);
645
+ }
646
+
647
+ 100% {
648
+ -webkit-transform: rotate(360deg);
649
+ }
650
+ }
651
+
652
+ @keyframes spin {
653
+ 0% {
654
+ transform: rotate(0deg);
655
+ }
656
+
657
+ 100% {
658
+ transform: rotate(360deg);
659
+ }
660
+ }
661
+ </style>
662
+ </body>
663
+
664
+ <script>
665
+ function sendMessage() {
666
+ var messageInput = document.getElementById('messageInput');
667
+ var newMessageText = messageInput.value;
668
+
669
+ if (newMessageText.trim() === "") {
670
+ return;
671
+ }
672
+
673
+ messageInput.value = "";
674
+
675
+ var chatContainer = document.querySelector('.message-chat');
676
+ var userMessage = `
677
+ <div class="msg right-msg">
678
+ <div class="msg-img"></div>
679
+ <div class="msg-bubble">
680
+ <div class="msg-text">${newMessageText}</div>
681
+ </div>
682
+ </div>
683
+ `;
684
+ chatContainer.insertAdjacentHTML('beforeend', userMessage);
685
+
686
+ chatContainer.scrollTop = chatContainer.scrollHeight;
687
+ var loadingMessage = `
688
+ <div class="msg left-msg loading">
689
+ <div class="msg-img"></div>
690
+ <div class="msg-bubble loading">
691
+ <div class="msg-text">Loading</div>
692
+ </div>
693
+ </div>
694
+ `;
695
+
696
+ chatContainer.insertAdjacentHTML('beforeend', loadingMessage);
697
+
698
+ setTimeout(function () {
699
+ var loadingElement = document.querySelector('.left-msg.loading');
700
+ updateLoadingMessage(loadingElement, 3);
701
+ }, 500);
702
+
703
+ function updateLoadingMessage(element, iterations) {
704
+ var counter = 0;
705
+ var intervalId = setInterval(function () {
706
+ counter++;
707
+ element.querySelector('.msg-text').innerText = 'Loading' + '.'.repeat(counter);
708
+ if (counter === iterations) {
709
+ clearInterval(intervalId);
710
+ }
711
+ }, 500);
712
+ }
713
+ chatContainer.scrollTop = chatContainer.scrollHeight;
714
+
715
+ url = "/chat?message=" + newMessageText;
716
+ fetch(url, {
717
+ method: 'GET',
718
+ headers: {
719
+ 'Content-Type': 'application/text',
720
+ },
721
+ args: {
722
+ message: newMessageText
723
+ }
724
+ })
725
+ .then(response => response.text())
726
+ .then(data => {
727
+ var loadingMessages = document.querySelectorAll('.loading');
728
+ loadingMessages.forEach(loadingMessage => {
729
+ loadingMessage.style.display = 'none';
730
+ });
731
+ var botMessage = `
732
+ <div class="msg left-msg">
733
+ <div class="msg-img"></div>
734
+ <div class="msg-bubble">
735
+ <div class="msg-text">${data}</div>
736
+ </div>
737
+ </div>
738
+ `;
739
+ chatContainer.insertAdjacentHTML('beforeend', botMessage);
740
+ chatContainer.scrollTop = chatContainer.scrollHeight;
741
+ })
742
+ .catch(error => console.error('Error:', error));
743
+ }
744
+
745
+ function openFileUploadModal() {
746
+ var modal = document.getElementById('fileUploadModal');
747
+ modal.style.display = 'flex';
748
+ }
749
+
750
+ function closeFileUploadModal() {
751
+ var modal = document.getElementById('fileUploadModal');
752
+ modal.style.display = 'none';
753
+ }
754
+
755
+ function openDocumentsModal() {
756
+ var modal = document.getElementById('documentsModal');
757
+ modal.style.display = 'flex';
758
+ }
759
+
760
+ function closeDocumentsModal() {
761
+ var modal = document.getElementById('documentsModal');
762
+ modal.style.display = 'none';
763
+ }
764
+
765
+ function updateFileNames() {
766
+ var fileInput = document.getElementById('upload');
767
+
768
+ if (fileInput.files.length === 1) {
769
+ fileNames = fileInput.files.length + " file";
770
+ }
771
+ if (fileInput.files.length > 1) {
772
+ fileNames = fileInput.files.length + " files";
773
+ }
774
+
775
+ var uploadedFileNames = document.getElementById('uploadedFileNames');
776
+ uploadedFileNames.textContent = fileNames;
777
+ uploadedFileNames.style.display = 'flex';
778
+ uploadedFileNames.style.position = 'absolute';
779
+ var fileInput = document.querySelector('.file-upload');
780
+ fileInput.style.top = '52.5%';
781
+ var process = document.querySelector('.flipping-button');
782
+ process.style.top = '65%';
783
+ }
784
+
785
+ document.querySelector("#form").addEventListener("submit", load);
786
+
787
+ function resetUpload() {
788
+ var fileInput = document.getElementById('upload');
789
+ fileInput.value = "";
790
+ var uploadedFileNames = document.getElementById('uploadedFileNames');
791
+ uploadedFileNames.textContent = "";
792
+ uploadedFileNames.style.display = 'none';
793
+ var fileInput = document.querySelector('.file-upload');
794
+ fileInput.style.display = 'flex';
795
+ fileInput.style.top = '50%';
796
+ var process = document.querySelector('.flipping-button');
797
+ process.style.display = 'flex';
798
+ process.style.top = '60%';
799
+ var timer = document.getElementById('timer');
800
+ timer.style.display = 'none';
801
+ var load = document.querySelector('.load');
802
+ load.style.display = 'none';
803
+ }
804
+
805
+ function uploadDocument() {
806
+ var fileInput = document.getElementById('upload');
807
+ var files = fileInput.files;
808
+
809
+ if (files.length === 0) {
810
+ alert('Please select at least one file.');
811
+ return;
812
+ }
813
+
814
+ var fileInput = document.querySelector('.file-upload');
815
+ fileInput.style.display = 'none';
816
+
817
+ var loadingIcon = document.querySelector('.load');
818
+ loadingIcon.style.display = 'flex';
819
+ loadingIcon.classList.add('spin-animation');
820
+
821
+ var process = document.querySelector('.flipping-button');
822
+ process.style.display = 'none';
823
+
824
+ var uploadedFileNames = document.getElementById('uploadedFileNames');
825
+ uploadedFileNames.style.display = 'none';
826
+
827
+ var timer = document.getElementById('timer');
828
+ timer.style.display = 'flex';
829
+
830
+ var time = 0;
831
+ var interval = setInterval(function () {
832
+ time += 0.01;
833
+ timer.textContent = time.toFixed(2) + " seconds";
834
+ }, 10);
835
+
836
+ var formData = new FormData();
837
+ for (var i = 0; i < files.length; i++) {
838
+ formData.append('pdf-files[]', files[i]);
839
+ }
840
+
841
+ fetch('/', {
842
+ method: 'POST',
843
+ body: formData,
844
+ })
845
+ .then(response => response.text())
846
+ .then(data => {
847
+ console.log(data);
848
+ clearInterval(interval);
849
+ resetUpload();
850
+ closeFileUploadModal();
851
+ })
852
+ .catch(error => {
853
+ console.error('Error:', error);
854
+ clearInterval(interval);
855
+ resetUpload();
856
+ closeFileUploadModal();
857
+ });
858
+ }
859
+
860
+ </script>
861
+ </section>
862
+ </html>