-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
196 lines (184 loc) · 6.85 KB
/
index.html
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width"/>
<link rel="stylesheet" href="https://unpkg.com/photoswipe@beta/dist/photoswipe.css">
<!-- demo styles, ignore em-->
<style>
body {
margin: 0;
padding: 0;
font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif;
font-size: 14px;
line-height: 20px;
background: #eee;
}
h1 {
margin: 0;
padding: 50px 50px 30px 50px;
font-size: 26px;
line-height: 1.3;
}
.pswp-gallery__item img {
display: block;
max-width: 90px;
margin-bottom: 4px;
height: auto;
}
.pswp-gallery {
max-width: 600px;
padding: 20px 50px 20px;
background: #eee;
position: relative;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
}
.pswp-test {
margin-left:50px;
margin-bottom: 40px;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
align-items: flex-start;
}
.pswp-test label {
background: #fbfbfb;
padding: 4px;
border-radius: 4px;
margin-bottom: 6px;
font-size: 16px;
line-height: 1;
}
p {
padding: 4px 50px 8px;
margin: 0;
max-width: 600px;
}
</style>
</head>
<body>
<div class="main-page-content">
<h1>
Deepzoom speedtest
</h1>
<p>
Click on the images with different origin to see the time different
PS: please wait for the page to fully load before clicking on the thumb images
</p>
<div class="pswp-gallery" id="gallery"></div>
<div class="pswp-test">
<label for="display_layer_borders">
<input type="checkbox" id="display_layer_borders" name="display_layer_borders" checked>Display layer borders
</label>
</div>
<script>
/* debug stuff */
window.pswpDebug = {
display_layer_borders: true,
};
for(let key in window.pswpDebug) {
document.querySelector('#' + key).checked = window.pswpDebug[key];
}
[...document.querySelectorAll('.pswp-test input')].forEach((checkbox) => {
checkbox.addEventListener('change', (e) => {
if (e.currentTarget.checked) {
window.pswpDebug[e.currentTarget.name] = true;
} else {
window.pswpDebug[e.currentTarget.name] = false;
}
});
});
</script>
<script type="module">
import PhotoSwipeLightbox from 'https://unpkg.com/photoswipe@beta/dist/photoswipe-lightbox.esm.js';
// Load deep zoom images
(async () => {
const deepzoomImages = await fetch("output/output.json");
const deepzoomImagesJson = await deepzoomImages.json();
// Origin config to fetch images from different source, so far only local is supported
const origins = {
'Local': '/output'
};
deepzoomImagesJson.forEach((image, index) => {
for (let source in origins) {
let template = `
<div class="pswp-gallery__item">
<a
href="/output/${image.image}/${image.fullImage}"
data-pswp-width="${image.fullWidth}"
data-pswp-height="${image.fullHeight}"
data-pswp-tile-type="zoomify"
data-pswp-tile-url="${origins[source]}/${image.image}/TileGroup{zoomify_group}/{z}-{x}-{y}.jpg"
data-pswp-tile-size="${image.tileSize}"
data-pswp-max-width="${image.originWidth}"
data-pswp-max-height="${image.originHeight}"
data-pswp-tile-overlap="${image.tileOverlap}"
target="_blank">
<img src="${origins[source]}/${image.image}/TileGroup0/0-0-0.jpg" alt="${image.image}" />
</a>
<div class="caption">
<a href="#"><strong>${image.image} - Origin: ${source}</strong></a>
<br>
${image.tileSize}x${image.tileSize} - ${image.fileCount} tiles
<br>
Zoomify tile format - ${image.folderSize.toFixed(2)}Mb
</div>
</div>
`;
if ( image.format === "deepzoom" ) {
template = `
<div class="pswp-gallery__item">
<a
href="/output/${image.image}/full.jpg"
data-pswp-width="${image.fullWidth}"
data-pswp-height="${image.fullHeight}"
data-pswp-tile-url="/output/${image.image}/output_files/{z}/{x}_{y}.jpg"
data-pswp-tile-size="${image.tileSize}"
data-pswp-max-width="${image.originWidth}"
data-pswp-max-height="${image.originHeight}"
data-pswp-tile-overlap="${image.tileOverlap}"
target="_blank">
<img src="/output/${image.image}/full.jpg" alt="Single demo image" />
</a>
<div class="caption">
<a href="#"><strong>${image.image} - Origin: ${origin}</strong></a>
<br>
${image.tileSize}x${image.tileSize} - ${image.fileCount} tiles
<br>
${image.format} tile format - ${image.folderSize.toFixed(2)}Mb
</div>
</div>
`;
}
document.querySelector('#gallery').insertAdjacentHTML('beforeend', template);
}
let deepZoomPlugin;
const lightbox = new PhotoSwipeLightbox({
gallery: '#gallery',
children: '.pswp-gallery__item > a',
pswpModule: () => import('https://unpkg.com/photoswipe@beta/dist/photoswipe.esm.js'),
// dynamically load deep zoom plugin
openPromise: () => {
// make sure it's initialized only once per lightbox
if (!deepZoomPlugin) {
return import('https://dimsemenov.github.io/photoswipe-deep-zoom-plugin/src/index.js').then((deepZoomPluginModule) => {
deepZoomPlugin = new deepZoomPluginModule.default(lightbox, {
// deep zoom plugin options
});
})
}
},
// Recommended PhotoSwipe options for this plugin
allowPanToNext: false, // prevent swiping to the next slide when image is zoomed
allowMouseDrag: true, // display dragging cursor at max zoom level
wheelToZoom: true, // enable wheel-based zoom
zoom: false // disable default zoom button
});
lightbox.init();
});
})();
</script>
</div>
</body>
</html>