This repository was archived by the owner on Jan 25, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathviewer.html
More file actions
168 lines (151 loc) · 6.03 KB
/
viewer.html
File metadata and controls
168 lines (151 loc) · 6.03 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>IIIF Image Gallery Viewer</title>
<link rel="stylesheet" href="styles.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/openseadragon/4.0.0/openseadragon.min.js"></script>
<style>
/* Viewer hint overlay */
#viewer { position: relative; }
#viewerHint {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
color: #7e7d7d;
font-size: 1rem;
text-align: center;
pointer-events: none;
padding: 0.5rem 0.75rem;
background: rgba(255, 255, 255, 0.85);
border-radius: 6px;
}
/* Hide the hint once an image has been opened */
.viewer-has-image #viewerHint { display: none !important; }
/* View-only: hide all builder controls and delete buttons */
.view-only #inputPanel { display: none !important; }
.view-only #toggleInputs { display: none !important; }
.view-only .delete-btn { display: none !important; }
.view-only #addManifest { display: none !important; }
.view-only #saveLocally { display: none !important; }
</style>
</head>
<body class="view-only">
<div class="container">
<div class="left-panel">
<div class="header">
<div class="header-top">
<img src="https://upload.wikimedia.org/wikipedia/commons/e/e8/International_Image_Interoperability_Framework_logo.png" alt="IIIF Logo" class="iiif-logo">
<h1 id="page-title">
<span class="title-base">IIIF Image Gallery Viewer</span>
<span class="title-gallery" id="gallery-title-display"></span>
</h1>
<div class="control-links">
<a href="info.html" class="control-link" target="_blank">ⓘ Get Help</a>
<a href="#" id="toggleViewer" class="control-link">Hide Viewer</a>
</div>
</div>
</div>
<!-- Keep all controls in DOM so script.js can bind to them; CSS hides them in view-only -->
<div id="inputPanel" class="input-panel">
<!-- Builder controls (hidden in view-only) -->
<div class="input-section">
<label for="manifestUrl" class="section-label">Add IIIF Manifests</label>
<input type="text" id="manifestUrl" placeholder="Enter IIIF Manifest URLs (comma-separated)" />
<button id="addManifest">Add Manifest(s)</button>
</div>
<div class="section-divider"></div>
<div class="input-section">
<label class="section-label">Load Gallery</label>
<div class="load-option">
<label for="uploadManifest" class="file-input-label">Choose File</label>
<input type="file" id="uploadManifest" accept=".json" style="display: none;" />
<span id="fileName" class="file-name">No file chosen</span>
</div>
<div class="load-option-divider">OR</div>
<div class="load-option">
<input type="text" id="galleryUrl" placeholder="Paste gallery JSON URL" />
</div>
<button id="loadFromUrl">Load from URL</button>
</div>
<div class="section-divider"></div>
<div class="input-section">
<label for="manifestName" class="section-label">Save Gallery</label>
<input type="text" id="manifestName" placeholder="Enter gallery name (optional - auto-generated if empty)" />
<button id="saveLocally">💾 Save Locally</button>
</div>
</div>
<div id="gallery"></div>
</div>
<!-- Resizable divider and viewer -->
<div id="resizer"></div>
<div id="viewer"></div>
<!-- Include script.js exactly once -->
<script src="script.js"></script>
<!-- Page Selector Modal (required so script.js event binding doesn't fail) -->
<div id="pageSelectorModal" class="modal">
<div class="modal-content">
<div class="modal-header">
<h2 id="modalTitle">Select Pages to Add</h2>
<span class="close-modal">×</span>
</div>
<div class="modal-controls">
<button id="selectAllPages" class="modal-btn">Select All</button>
<button id="deselectAllPages" class="modal-btn">Deselect All</button>
<span id="selectionCount">0 pages selected</span>
</div>
<div id="pageGrid" class="page-grid">
<!-- Pages will be dynamically added here -->
</div>
<div class="modal-footer">
<button id="cancelPageSelection" class="modal-btn-secondary">Cancel</button>
<button id="addSelectedPages" class="modal-btn-primary">Add Selected Pages</button>
</div>
</div>
</div>
</div>
<!-- Hint + openFirst script -->
<script>
document.addEventListener('DOMContentLoaded', function() {
var viewerEl = document.getElementById('viewer');
if (viewerEl && !document.getElementById('viewerHint')) {
var hint = document.createElement('div');
hint.id = 'viewerHint';
hint.textContent = 'Click any thumbnail to load an image.';
viewerEl.appendChild(hint);
}
var params = new URLSearchParams(window.location.search);
var openFirst = (params.get('openFirst') === '1' || params.get('openfirst') === '1');
var opened = false;
function markViewerHasImage() {
document.body.classList.add('viewer-has-image');
}
function tryOpenFirst() {
if (opened) return;
var firstThumb = document.querySelector('#gallery .card img');
if (firstThumb) {
opened = true;
firstThumb.click();
markViewerHasImage();
}
}
if (openFirst) {
tryOpenFirst();
var gallery = document.getElementById('gallery');
if (gallery) {
var mo = new MutationObserver(function() {
tryOpenFirst();
});
mo.observe(gallery, { childList: true, subtree: true });
}
}
document.addEventListener('click', function(e) {
if (e.target && e.target.matches('#gallery .card img')) {
markViewerHasImage();
}
});
});
</script>
</body>
</html>