Anshit9999 commited on
Commit
a369d8c
·
verified ·
1 Parent(s): 6ebc716

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. README.md +3 -8
  3. book.pdf +3 -0
  4. index.html +88 -18
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ book.pdf filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,10 +1,5 @@
1
  ---
2
- title: Anshit Physics Book Final V2
3
- emoji: 🐢
4
- colorFrom: red
5
- colorTo: green
6
  sdk: static
7
- pinned: false
8
- ---
9
-
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: Anshit-Physics-Book-Final-V2
3
+ app_file: index.html
 
 
4
  sdk: static
5
+ ---
 
 
 
book.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d5fe4a8721dd9765ed9735880bb027ef6c98d9ad572e963502b62ddf3948a226
3
+ size 797031907
index.html CHANGED
@@ -1,19 +1,89 @@
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
+
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Fast PDF Viewer</title>
8
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.min.js"></script>
9
+ <style>
10
+ body { margin: 0; background: #222; color: white; font-family: sans-serif; height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
11
+ .controls { background: #333; padding: 10px; display: flex; justify-content: center; gap: 15px; box-shadow: 0 2px 10px rgba(0,0,0,0.5); z-index: 10; }
12
+ button { padding: 8px 16px; background: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; }
13
+ button:disabled { background: #555; }
14
+ #page-info { font-weight: bold; min-width: 120px; text-align: center; display: flex; align-items: center; }
15
+ #viewer-container { flex: 1; overflow: auto; display: flex; justify-content: center; padding: 20px; background: #525659; }
16
+ canvas { box-shadow: 0 4px 15px rgba(0,0,0,0.6); max-width: 100%; height: auto; background: white; }
17
+
18
+ /* Error Box to see what is wrong */
19
+ #error-msg {
20
+ display: none; position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
21
+ background: red; color: white; padding: 15px; border-radius: 5px; z-index: 1000; font-weight: bold;
22
+ }
23
+ </style>
24
+ </head>
25
+ <body>
26
+ <div id="error-msg"></div>
27
+ <div class="controls">
28
+ <button id="prev">Previous</button>
29
+ <span id="page-info">Loading...</span>
30
+ <button id="next">Next</button>
31
+ <a href="book.pdf" download style="color:#aaa; text-decoration:none; margin-left:10px; font-size:12px; display:flex; align-items:center;">(Download)</a>
32
+ </div>
33
+ <div id="viewer-container">
34
+ <canvas id="the-canvas"></canvas>
35
+ </div>
36
+ <script>
37
+ const url = 'book.pdf';
38
+ pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.worker.min.js';
39
+ let pdfDoc = null, pageNum = 1, pageRendering = false, pageNumPending = null;
40
+ const scale = 1.5, canvas = document.getElementById('the-canvas'), ctx = canvas.getContext('2d');
41
+
42
+ function showError(msg) {
43
+ const el = document.getElementById('error-msg');
44
+ el.style.display = 'block';
45
+ el.innerHTML = msg;
46
+ }
47
+
48
+ function renderPage(num) {
49
+ pageRendering = true;
50
+ pdfDoc.getPage(num).then(page => {
51
+ const viewport = page.getViewport({scale: scale});
52
+ canvas.height = viewport.height; canvas.width = viewport.width;
53
+ const renderContext = { canvasContext: ctx, viewport: viewport };
54
+ page.render(renderContext).promise.then(() => {
55
+ pageRendering = false;
56
+ if (pageNumPending !== null) { renderPage(pageNumPending); pageNumPending = null; }
57
+ });
58
+ }).catch(err => showError("Render Error: " + err.message));
59
+
60
+ document.getElementById('page-info').textContent = `Page ${num} / ${pdfDoc.numPages}`;
61
+ document.getElementById('prev').disabled = num <= 1;
62
+ document.getElementById('next').disabled = num >= pdfDoc.numPages;
63
+ document.getElementById('viewer-container').scrollTop = 0;
64
+ }
65
+
66
+ function queueRenderPage(num) { if(pageRendering) pageNumPending = num; else renderPage(num); }
67
+ document.getElementById('prev').addEventListener('click', () => { if(pageNum > 1) { pageNum--; queueRenderPage(pageNum); } });
68
+ document.getElementById('next').addEventListener('click', () => { if(pageNum < pdfDoc.numPages) { pageNum++; queueRenderPage(pageNum); } });
69
+
70
+ // === IMPORTANT: SETTINGS FOR LARGE FILES ===
71
+ const loadingTask = pdfjsLib.getDocument({
72
+ url: url,
73
+ rangeChunkSize: 65536 * 16,
74
+ disableAutoFetch: true, // Stop downloading the whole file!
75
+ disableStream: true // Force random access
76
+ });
77
+
78
+ loadingTask.promise.then(pdf => {
79
+ pdfDoc = pdf;
80
+ document.getElementById('page-info').textContent = `Page 1 / ${pdf.numPages}`;
81
+ renderPage(pageNum);
82
+ }).catch(err => {
83
+ console.error(err);
84
+ showError("Load Error: " + err.message + "<br><small>If you just uploaded this, wait 2 minutes and refresh.</small>");
85
+ });
86
+ </script>
87
+ </body>
88
  </html>
89
+