Spaces:
Runtime error
Runtime error
Update templates/gui.html
Browse files- templates/gui.html +36 -47
templates/gui.html
CHANGED
|
@@ -58,68 +58,57 @@ processPdf();
|
|
| 58 |
|
| 59 |
</script> -->
|
| 60 |
|
| 61 |
-
|
| 62 |
<!DOCTYPE html>
|
| 63 |
<html lang="en">
|
| 64 |
<head>
|
| 65 |
<meta charset="UTF-8">
|
| 66 |
<title>PDF Viewer</title>
|
| 67 |
<style>
|
| 68 |
-
body { margin: 0;
|
| 69 |
-
|
| 70 |
-
#links {
|
| 71 |
-
position: fixed;
|
| 72 |
-
top: 10px;
|
| 73 |
-
left: 10px;
|
| 74 |
-
background: rgba(255, 255, 255, 0.9);
|
| 75 |
-
padding: 8px 12px;
|
| 76 |
-
border-radius: 10px;
|
| 77 |
-
box-shadow: 0 0 6px rgba(0,0,0,0.2);
|
| 78 |
-
}
|
| 79 |
-
.pdf-link {
|
| 80 |
-
display: block;
|
| 81 |
-
margin: 6px 0;
|
| 82 |
-
cursor: pointer;
|
| 83 |
-
color: #0056b3;
|
| 84 |
-
text-decoration: underline;
|
| 85 |
-
}
|
| 86 |
</style>
|
| 87 |
</head>
|
| 88 |
<body>
|
| 89 |
-
<div id="links"></div>
|
| 90 |
|
| 91 |
-
<!--
|
| 92 |
-
<iframe
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
allowfullscreen
|
| 96 |
-
></iframe>
|
| 97 |
|
| 98 |
<script>
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
{ page: 15, zoom: 180 }
|
| 105 |
-
];
|
| 106 |
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
| 122 |
});
|
| 123 |
</script>
|
|
|
|
| 124 |
</body>
|
| 125 |
</html>
|
|
|
|
| 58 |
|
| 59 |
</script> -->
|
| 60 |
|
|
|
|
| 61 |
<!DOCTYPE html>
|
| 62 |
<html lang="en">
|
| 63 |
<head>
|
| 64 |
<meta charset="UTF-8">
|
| 65 |
<title>PDF Viewer</title>
|
| 66 |
<style>
|
| 67 |
+
body { margin: 0; overflow: hidden; }
|
| 68 |
+
iframe { width: 100vw; height: 100vh; border: none; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
</style>
|
| 70 |
</head>
|
| 71 |
<body>
|
|
|
|
| 72 |
|
| 73 |
+
<!-- PDF viewer -->
|
| 74 |
+
<iframe id="pdfViewer"
|
| 75 |
+
src="/get-pdf#page={{ start_page }}&zoom={{ start_zoom }}"
|
| 76 |
+
allowfullscreen></iframe>
|
|
|
|
|
|
|
| 77 |
|
| 78 |
<script>
|
| 79 |
+
/**
|
| 80 |
+
* Listen for external navigation updates.
|
| 81 |
+
* If the viewer is already open, update the page/zoom dynamically
|
| 82 |
+
* when the user clicks another external /view-pdf?pdfLink=...&page=X&zoom=Y link.
|
| 83 |
+
*/
|
|
|
|
|
|
|
| 84 |
|
| 85 |
+
// Detect changes to URL parameters dynamically
|
| 86 |
+
function getQueryParams() {
|
| 87 |
+
const params = new URLSearchParams(window.location.search);
|
| 88 |
+
return {
|
| 89 |
+
pdfLink: params.get('pdfLink'),
|
| 90 |
+
page: params.get('page') || '1',
|
| 91 |
+
zoom: params.get('zoom') || '100'
|
| 92 |
+
};
|
| 93 |
+
}
|
| 94 |
|
| 95 |
+
function updatePDFView(page, zoom) {
|
| 96 |
+
const iframe = document.getElementById('pdfViewer');
|
| 97 |
+
iframe.src = `/get-pdf#page=${page}&zoom=${zoom}`;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
// Listen for URL changes (e.g. when user clicks another link externally)
|
| 101 |
+
window.addEventListener('popstate', () => {
|
| 102 |
+
const { page, zoom } = getQueryParams();
|
| 103 |
+
updatePDFView(page, zoom);
|
| 104 |
+
});
|
| 105 |
+
|
| 106 |
+
// Also handle initial load (page refresh or direct open)
|
| 107 |
+
window.addEventListener('load', () => {
|
| 108 |
+
const { page, zoom } = getQueryParams();
|
| 109 |
+
updatePDFView(page, zoom);
|
| 110 |
});
|
| 111 |
</script>
|
| 112 |
+
|
| 113 |
</body>
|
| 114 |
</html>
|