hzaustingg commited on
Commit
93975b4
·
verified ·
1 Parent(s): 5057c26

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +610 -19
index.html CHANGED
@@ -1,19 +1,610 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>PDF Reader</title>
7
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.min.js"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
9
+ <style>
10
+ :root {
11
+ --primary-color: #2563eb;
12
+ --secondary-color: #1e40af;
13
+ --background-color: #f8fafc;
14
+ --card-background: #ffffff;
15
+ --text-color: #1e293b;
16
+ --text-secondary: #64748b;
17
+ --border-color: #e2e8f0;
18
+ --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
19
+ --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
20
+ }
21
+
22
+ * {
23
+ margin: 0;
24
+ padding: 0;
25
+ box-sizing: border-box;
26
+ }
27
+
28
+ body {
29
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
30
+ background-color: var(--background-color);
31
+ color: var(--text-color);
32
+ line-height: 1.6;
33
+ min-height: 100vh;
34
+ display: flex;
35
+ flex-direction: column;
36
+ }
37
+
38
+ .header {
39
+ background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
40
+ color: white;
41
+ padding: 1rem 2rem;
42
+ box-shadow: var(--shadow);
43
+ position: sticky;
44
+ top: 0;
45
+ z-index: 100;
46
+ }
47
+
48
+ .header-content {
49
+ max-width: 1200px;
50
+ margin: 0 auto;
51
+ display: flex;
52
+ justify-content: space-between;
53
+ align-items: center;
54
+ flex-wrap: wrap;
55
+ gap: 1rem;
56
+ }
57
+
58
+ .logo {
59
+ font-size: 1.5rem;
60
+ font-weight: bold;
61
+ display: flex;
62
+ align-items: center;
63
+ gap: 0.5rem;
64
+ }
65
+
66
+ .logo i {
67
+ font-size: 1.8rem;
68
+ }
69
+
70
+ .anycoder-link {
71
+ color: white;
72
+ text-decoration: none;
73
+ font-weight: 500;
74
+ padding: 0.5rem 1rem;
75
+ border-radius: 0.5rem;
76
+ transition: all 0.3s ease;
77
+ background-color: rgba(255, 255, 255, 0.2);
78
+ }
79
+
80
+ .anycoder-link:hover {
81
+ background-color: rgba(255, 255, 255, 0.3);
82
+ transform: translateY(-2px);
83
+ }
84
+
85
+ .main-container {
86
+ max-width: 1200px;
87
+ margin: 2rem auto;
88
+ padding: 0 1rem;
89
+ flex: 1;
90
+ display: flex;
91
+ flex-direction: column;
92
+ gap: 2rem;
93
+ }
94
+
95
+ .upload-section {
96
+ background: var(--card-background);
97
+ border-radius: 1rem;
98
+ padding: 2rem;
99
+ box-shadow: var(--shadow);
100
+ transition: all 0.3s ease;
101
+ }
102
+
103
+ .upload-section:hover {
104
+ box-shadow: var(--shadow-lg);
105
+ transform: translateY(-2px);
106
+ }
107
+
108
+ .upload-area {
109
+ border: 2px dashed var(--border-color);
110
+ border-radius: 0.75rem;
111
+ padding: 3rem 2rem;
112
+ text-align: center;
113
+ cursor: pointer;
114
+ transition: all 0.3s ease;
115
+ background-color: var(--background-color);
116
+ }
117
+
118
+ .upload-area:hover {
119
+ border-color: var(--primary-color);
120
+ background-color: rgba(37, 99, 235, 0.05);
121
+ }
122
+
123
+ .upload-area.dragover {
124
+ border-color: var(--primary-color);
125
+ background-color: rgba(37, 99, 235, 0.1);
126
+ }
127
+
128
+ .upload-icon {
129
+ font-size: 3rem;
130
+ color: var(--primary-color);
131
+ margin-bottom: 1rem;
132
+ }
133
+
134
+ .upload-text {
135
+ font-size: 1.2rem;
136
+ color: var(--text-color);
137
+ margin-bottom: 0.5rem;
138
+ }
139
+
140
+ .upload-subtext {
141
+ color: var(--text-secondary);
142
+ font-size: 0.9rem;
143
+ }
144
+
145
+ #fileInput {
146
+ display: none;
147
+ }
148
+
149
+ .pdf-viewer-section {
150
+ background: var(--card-background);
151
+ border-radius: 1rem;
152
+ padding: 2rem;
153
+ box-shadow: var(--shadow);
154
+ display: none;
155
+ flex-direction: column;
156
+ gap: 1.5rem;
157
+ }
158
+
159
+ .pdf-viewer-section.active {
160
+ display: flex;
161
+ }
162
+
163
+ .pdf-header {
164
+ display: flex;
165
+ justify-content: space-between;
166
+ align-items: center;
167
+ flex-wrap: wrap;
168
+ gap: 1rem;
169
+ }
170
+
171
+ .pdf-title {
172
+ font-size: 1.25rem;
173
+ font-weight: 600;
174
+ color: var(--text-color);
175
+ }
176
+
177
+ .pdf-controls {
178
+ display: flex;
179
+ align-items: center;
180
+ gap: 1rem;
181
+ flex-wrap: wrap;
182
+ }
183
+
184
+ .control-group {
185
+ display: flex;
186
+ align-items: center;
187
+ gap: 0.5rem;
188
+ background: var(--background-color);
189
+ padding: 0.5rem;
190
+ border-radius: 0.5rem;
191
+ }
192
+
193
+ .control-btn {
194
+ background: none;
195
+ border: none;
196
+ color: var(--text-color);
197
+ cursor: pointer;
198
+ padding: 0.5rem;
199
+ border-radius: 0.25rem;
200
+ transition: all 0.2s ease;
201
+ display: flex;
202
+ align-items: center;
203
+ justify-content: center;
204
+ width: 2.5rem;
205
+ height: 2.5rem;
206
+ }
207
+
208
+ .control-btn:hover {
209
+ background-color: var(--primary-color);
210
+ color: white;
211
+ }
212
+
213
+ .control-btn:disabled {
214
+ opacity: 0.5;
215
+ cursor: not-allowed;
216
+ }
217
+
218
+ .zoom-controls {
219
+ display: flex;
220
+ align-items: center;
221
+ gap: 0.5rem;
222
+ }
223
+
224
+ .zoom-value {
225
+ min-width: 3rem;
226
+ text-align: center;
227
+ font-weight: 500;
228
+ }
229
+
230
+ .pdf-container {
231
+ flex: 1;
232
+ display: flex;
233
+ justify-content: center;
234
+ align-items: center;
235
+ background-color: #f1f5f9;
236
+ border-radius: 0.5rem;
237
+ overflow: hidden;
238
+ position: relative;
239
+ }
240
+
241
+ #pdfViewer {
242
+ max-width: 100%;
243
+ max-height: 100%;
244
+ box-shadow: var(--shadow);
245
+ }
246
+
247
+ .loading-spinner {
248
+ position: absolute;
249
+ top: 50%;
250
+ left: 50%;
251
+ transform: translate(-50%, -50%);
252
+ display: none;
253
+ }
254
+
255
+ .spinner {
256
+ width: 50px;
257
+ height: 50px;
258
+ border: 5px solid var(--border-color);
259
+ border-top: 5px solid var(--primary-color);
260
+ border-radius: 50%;
261
+ animation: spin 1s linear infinite;
262
+ }
263
+
264
+ @keyframes spin {
265
+ 0% { transform: rotate(0deg); }
266
+ 100% { transform: rotate(360deg); }
267
+ }
268
+
269
+ .page-info {
270
+ text-align: center;
271
+ color: var(--text-secondary);
272
+ font-size: 0.9rem;
273
+ }
274
+
275
+ .error-message {
276
+ background-color: #fee2e2;
277
+ color: #dc2626;
278
+ padding: 1rem;
279
+ border-radius: 0.5rem;
280
+ margin-top: 1rem;
281
+ display: none;
282
+ }
283
+
284
+ .error-message.show {
285
+ display: block;
286
+ }
287
+
288
+ @media (max-width: 768px) {
289
+ .header-content {
290
+ flex-direction: column;
291
+ text-align: center;
292
+ }
293
+
294
+ .main-container {
295
+ margin: 1rem auto;
296
+ padding: 0 0.5rem;
297
+ }
298
+
299
+ .upload-section, .pdf-viewer-section {
300
+ padding: 1.5rem;
301
+ }
302
+
303
+ .pdf-controls {
304
+ justify-content: center;
305
+ }
306
+
307
+ .control-group {
308
+ flex-direction: column;
309
+ width: fit-content;
310
+ margin: 0 auto;
311
+ }
312
+ }
313
+
314
+ @media (max-width: 480px) {
315
+ .header {
316
+ padding: 1rem;
317
+ }
318
+
319
+ .logo {
320
+ font-size: 1.2rem;
321
+ }
322
+
323
+ .upload-icon {
324
+ font-size: 2rem;
325
+ }
326
+
327
+ .upload-text {
328
+ font-size: 1rem;
329
+ }
330
+ }
331
+ </style>
332
+ </head>
333
+ <body>
334
+ <header class="header">
335
+ <div class="header-content">
336
+ <div class="logo">
337
+ <i class="fas fa-file-pdf"></i>
338
+ <span>PDF Reader</span>
339
+ </div>
340
+ <a href="https://huggingface.co/spaces/akhaliq/anycoder" class="anycoder-link" target="_blank">
341
+ Built with anycoder
342
+ </a>
343
+ </div>
344
+ </header>
345
+
346
+ <main class="main-container">
347
+ <section class="upload-section">
348
+ <div class="upload-area" id="uploadArea">
349
+ <i class="fas fa-cloud-upload-alt upload-icon"></i>
350
+ <div class="upload-text">Drop your PDF file here or click to browse</div>
351
+ <div class="upload-subtext">Supports PDF files only</div>
352
+ <input type="file" id="fileInput" accept=".pdf">
353
+ </div>
354
+ <div class="error-message" id="errorMessage"></div>
355
+ </section>
356
+
357
+ <section class="pdf-viewer-section" id="pdfViewerSection">
358
+ <div class="pdf-header">
359
+ <div class="pdf-title" id="pdfTitle">Document Title</div>
360
+ <div class="pdf-controls">
361
+ <div class="control-group">
362
+ <button class="control-btn" id="prevPage" title="Previous Page">
363
+ <i class="fas fa-chevron-left"></i>
364
+ </button>
365
+ <span id="pageInfo">Page 1 of 1</span>
366
+ <button class="control-btn" id="nextPage" title="Next Page">
367
+ <i class="fas fa-chevron-right"></i>
368
+ </button>
369
+ </div>
370
+ <div class="control-group zoom-controls">
371
+ <button class="control-btn" id="zoomOut" title="Zoom Out">
372
+ <i class="fas fa-search-minus"></i>
373
+ </button>
374
+ <span class="zoom-value" id="zoomValue">100%</span>
375
+ <button class="control-btn" id="zoomIn" title="Zoom In">
376
+ <i class="fas fa-search-plus"></i>
377
+ </button>
378
+ <button class="control-btn" id="zoomReset" title="Reset Zoom">
379
+ <i class="fas fa-compress-arrows-alt"></i>
380
+ </button>
381
+ </div>
382
+ </div>
383
+ </div>
384
+ <div class="pdf-container">
385
+ <div class="loading-spinner" id="loadingSpinner">
386
+ <div class="spinner"></div>
387
+ </div>
388
+ <canvas id="pdfViewer"></canvas>
389
+ </div>
390
+ <div class="page-info" id="pageInfoBottom">Page 1 of 1</div>
391
+ </section>
392
+ </main>
393
+
394
+ <script>
395
+ // Set PDF.js worker
396
+ pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.worker.min.js';
397
+
398
+ const uploadArea = document.getElementById('uploadArea');
399
+ const fileInput = document.getElementById('fileInput');
400
+ const pdfViewerSection = document.getElementById('pdfViewerSection');
401
+ const pdfViewer = document.getElementById('pdfViewer');
402
+ const pdfTitle = document.getElementById('pdfTitle');
403
+ const prevPageBtn = document.getElementById('prevPage');
404
+ const nextPageBtn = document.getElementById('nextPage');
405
+ const zoomInBtn = document.getElementById('zoomIn');
406
+ const zoomOutBtn = document.getElementById('zoomOut');
407
+ const zoomResetBtn = document.getElementById('zoomReset');
408
+ const zoomValue = document.getElementById('zoomValue');
409
+ const pageInfo = document.getElementById('pageInfo');
410
+ const pageInfoBottom = document.getElementById('pageInfoBottom');
411
+ const loadingSpinner = document.getElementById('loadingSpinner');
412
+ const errorMessage = document.getElementById('errorMessage');
413
+
414
+ let pdfDoc = null;
415
+ let currentPage = 1;
416
+ let zoomLevel = 1.0;
417
+ let pageRendering = false;
418
+ let pageNumPending = null;
419
+
420
+ // Upload area click handler
421
+ uploadArea.addEventListener('click', () => {
422
+ fileInput.click();
423
+ });
424
+
425
+ // File input change handler
426
+ fileInput.addEventListener('change', (e) => {
427
+ const file = e.target.files[0];
428
+ if (file && file.type === 'application/pdf') {
429
+ loadPDF(file);
430
+ } else {
431
+ showError('Please select a valid PDF file.');
432
+ }
433
+ });
434
+
435
+ // Drag and drop handlers
436
+ uploadArea.addEventListener('dragover', (e) => {
437
+ e.preventDefault();
438
+ uploadArea.classList.add('dragover');
439
+ });
440
+
441
+ uploadArea.addEventListener('dragleave', () => {
442
+ uploadArea.classList.remove('dragover');
443
+ });
444
+
445
+ uploadArea.addEventListener('drop', (e) => {
446
+ e.preventDefault();
447
+ uploadArea.classList.remove('dragover');
448
+ const file = e.dataTransfer.files[0];
449
+ if (file && file.type === 'application/pdf') {
450
+ loadPDF(file);
451
+ } else {
452
+ showError('Please drop a valid PDF file.');
453
+ }
454
+ });
455
+
456
+ // Load PDF function
457
+ function loadPDF(file) {
458
+ const fileReader = new FileReader();
459
+
460
+ loadingSpinner.style.display = 'block';
461
+
462
+ fileReader.onload = function() {
463
+ const typedarray = new Uint8Array(this.result);
464
+
465
+ pdfjsLib.getDocument(typedarray).promise.then(function(pdf) {
466
+ pdfDoc = pdf;
467
+ pdfTitle.textContent = file.name;
468
+ currentPage = 1;
469
+ zoomLevel = 1.0;
470
+ updateZoomDisplay();
471
+ renderPage(currentPage);
472
+ pdfViewerSection.classList.add('active');
473
+ loadingSpinner.style.display = 'none';
474
+ updatePageButtons();
475
+ }).catch(function(error) {
476
+ loadingSpinner.style.display = 'none';
477
+ showError('Error loading PDF: ' + error.message);
478
+ });
479
+ };
480
+
481
+ fileReader.readAsArrayBuffer(file);
482
+ }
483
+
484
+ // Render page function
485
+ function renderPage(num) {
486
+ pageRendering = true;
487
+ pdfDoc.getPage(num).then(function(page) {
488
+ const viewport = page.getViewport({ scale: zoomLevel });
489
+ pdfViewer.height = viewport.height;
490
+ pdfViewer.width = viewport.width;
491
+
492
+ const renderContext = {
493
+ canvas: pdfViewer,
494
+ viewport: viewport
495
+ };
496
+
497
+ const renderTask = page.render(renderContext);
498
+
499
+ renderTask.promise.then(function() {
500
+ pageRendering = false;
501
+ if (pageNumPending !== null) {
502
+ renderPage(pageNumPending);
503
+ pageNumPending = null;
504
+ }
505
+ updatePageInfo();
506
+ });
507
+ });
508
+ }
509
+
510
+ // Queue render page
511
+ function queueRenderPage(num) {
512
+ if (pageRendering) {
513
+ pageNumPending = num;
514
+ } else {
515
+ renderPage(num);
516
+ }
517
+ }
518
+
519
+ // Show previous page
520
+ prevPageBtn.addEventListener('click', () => {
521
+ if (currentPage <= 1) return;
522
+ currentPage--;
523
+ queueRenderPage(currentPage);
524
+ updatePageButtons();
525
+ });
526
+
527
+ // Show next page
528
+ nextPageBtn.addEventListener('click', () => {
529
+ if (currentPage >= pdfDoc.numPages) return;
530
+ currentPage++;
531
+ queueRenderPage(currentPage);
532
+ updatePageButtons();
533
+ });
534
+
535
+ // Zoom in
536
+ zoomInBtn.addEventListener('click', () => {
537
+ if (zoomLevel >= 3.0) return;
538
+ zoomLevel += 0.25;
539
+ updateZoomDisplay();
540
+ queueRenderPage(currentPage);
541
+ });
542
+
543
+ // Zoom out
544
+ zoomOutBtn.addEventListener('click', () => {
545
+ if (zoomLevel <= 0.5) return;
546
+ zoomLevel -= 0.25;
547
+ updateZoomDisplay();
548
+ queueRenderPage(currentPage);
549
+ });
550
+
551
+ // Reset zoom
552
+ zoomResetBtn.addEventListener('click', () => {
553
+ zoomLevel = 1.0;
554
+ updateZoomDisplay();
555
+ queueRenderPage(currentPage);
556
+ });
557
+
558
+ // Update zoom display
559
+ function updateZoomDisplay() {
560
+ zoomValue.textContent = Math.round(zoomLevel * 100) + '%';
561
+ }
562
+
563
+ // Update page info
564
+ function updatePageInfo() {
565
+ pageInfo.textContent = `Page ${currentPage} of ${pdfDoc.numPages}`;
566
+ pageInfoBottom.textContent = `Page ${currentPage} of ${pdfDoc.numPages}`;
567
+ }
568
+
569
+ // Update page buttons
570
+ function updatePageButtons() {
571
+ prevPageBtn.disabled = currentPage <= 1;
572
+ nextPageBtn.disabled = currentPage >= pdfDoc.numPages;
573
+ }
574
+
575
+ // Show error message
576
+ function showError(message) {
577
+ errorMessage.textContent = message;
578
+ errorMessage.classList.add('show');
579
+ setTimeout(() => {
580
+ errorMessage.classList.remove('show');
581
+ }, 5000);
582
+ }
583
+
584
+ // Keyboard navigation
585
+ document.addEventListener('keydown', (e) => {
586
+ if (!pdfViewerSection.classList.contains('active')) return;
587
+
588
+ switch(e.key) {
589
+ case 'ArrowLeft':
590
+ prevPageBtn.click();
591
+ break;
592
+ case 'ArrowRight':
593
+ nextPageBtn.click();
594
+ break;
595
+ case '+':
596
+ case '=':
597
+ zoomInBtn.click();
598
+ break;
599
+ case '-':
600
+ case '_':
601
+ zoomOutBtn.click();
602
+ break;
603
+ case '0':
604
+ zoomResetBtn.click();
605
+ break;
606
+ }
607
+ });
608
+ </script>
609
+ </body>
610
+ </html>