forked from UniversalViewer/examples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
215 lines (164 loc) · 6.72 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Universal Viewer Examples</title>
<link rel="icon" href="uv/favicon.ico">
<link rel="stylesheet" type="text/css" href="uv/uv.css">
<script type="text/javascript" src="lib/utils/dist/utils.js"></script>
<script type="text/javascript" src="uv/lib/offline.js"></script>
<script type="text/javascript" src="uv/helpers.js"></script>
<style>
body {
margin: 0px;
padding: 20px;
}
#uv {
width: 924px;
height: 668px;
/* width: 1024px;
height: 576px; */
}
#options {
padding: 20px 0 0 0;
}
</style>
</head>
<body>
<!--<div>
<h1>UV v3.0 alpha testing</h1>
<p>Please report any issues you find on the <a href="https://github.com/UniversalViewer/universalviewer/milestone/8" target="_blank">UV 3.0 milestone</a></p>
</div>-->
<div id="uv" class="uv"></div>
<div id="options">
<select id="manifestSelect"></select>
<input id="manifest" type="text" value="" />
<a id="setManifestButton" class="button" href="#">Set</a>
</div>
<div>
<button id="prev"><</button>
<button id="next">></button>
</div>
<div>
<!--<textarea id="annotations" rows="10" cols="50" placeholder="annotations"></textarea>
<button id="updateAnnotations">Update</button>-->
<!--<button id="addAnnotation" disabled>Add Annotation</button>-->
</div>
<script type="text/javascript">
var uv, manifest, urlDataProvider;
window.addEventListener('uvLoaded', function(e) {
urlDataProvider = new UV.URLDataProvider();
loadManifests(function() {
setSelectedManifest();
setupUV();
});
}, false);
function setupUV() {
var data = {
iiifResourceUri: manifest,
configUri: 'examples-config.json',
collectionIndex: Number(urlDataProvider.get('c', 0)),
manifestIndex: Number(urlDataProvider.get('m', 0)),
sequenceIndex: Number(urlDataProvider.get('s', 0)),
canvasIndex: Number(urlDataProvider.get('cv', 0)),
rotation: Number(urlDataProvider.get('r', 0)),
xywh: urlDataProvider.get('xywh', '')
};
uv = createUV('#uv', data, urlDataProvider);
uv.on('created', function() {
Utils.Urls.setHashParameter('manifest', manifest);
});
// uv.on('openseadragonExtension.open', function() {
// console.log('osd opened');
// });
}
function loadManifests(cb) {
// load manifests
$.getJSON('manifests.json', function(manifests) {
var $manifestSelect = $('#manifestSelect');
for (var i = 0; i < manifests.collections.length; i++) {
var collection = manifests.collections[i];
if (collection.visible === false) {
continue;
}
$manifestSelect.append('<optgroup label="' + collection.label + '">');
for (var j = 0; j < collection.manifests.length; j++) {
var manifest = collection.manifests[j];
if (manifest.visible !== false) {
$manifestSelect.append('<option value="' + manifest['@id'] + '">' + manifest.label + '</option>');
}
}
$manifestSelect.append('</optgroup>');
}
cb();
});
}
function setSelectedManifest() {
manifest = Utils.Urls.getHashParameter('manifest');
if (manifest) {
$('#manifestSelect').val(manifest);
} else {
var options = $('#manifestSelect option');
if (options.length) {
manifest = options[0].value;
}
}
$('#manifest').val(manifest);
}
$('#manifestSelect').on('change', function() {
$('#manifest').val($('#manifestSelect option:selected').val());
});
$('#setManifestButton').on('click', function() {
manifest = $('#manifest').val();
uv.set({
iiifResourceUri: manifest,
collectionIndex: 0,
manifestIndex: 0,
sequenceIndex: 0,
canvasIndex: 0
});
});
$('#prev').on('click', function() {
uv.set({
canvasIndex: uv.get('canvasIndex') - 1
});
});
$('#next').on('click', function() {
uv.set({
canvasIndex: uv.get('canvasIndex') + 1
});
});
// annotationList = {
// "@context": "http://iiif.io/api/search/0/context.json",
// "@id": "http://wellcomelibrary.org/iiif/b18035723/manifest",
// "@type": "sc:AnnotationList",
// "within": {
// "@type": "sc:Layer"
// },
// "startIndex": 0,
// "resources": []
// };
// $('#updateAnnotations').on('click', function() {
// var annotations = JSON.parse($('#annotations').val());
// uv.set({
// annotations: annotations
// });
// });
// var $addAnnotation = $('#addAnnotation');
// // load test annotations
// $.getJSON('test-annotations.json', function(testAnnotations) {
// $addAnnotation.prop('disabled', false);
// $addAnnotation.on('click', function() {
// var annotation = testAnnotations[Math.floor(Math.random() * testAnnotations.length)];
// annotation.on = "https://wellcomelibrary.org/iiif/b18035723/canvas/c0#xywh=909,3067,339,50";
// annotationList.resources.push(annotation);
// uv.set({
// annotations: annotationList
// });
// });
// });
</script>
<!-- Put at the bottom of the page to ensure that the uvLoaded event isn't fired before a listener is registered -->
<script type="text/javascript" src="uv/uv.js"></script>
</body>
</html>