forked from UniversalViewer/examples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
av.html
143 lines (108 loc) · 4.33 KB
/
av.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
<!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-av/uv.css">
<script type="text/javascript" src="lib/utils/dist/utils.js"></script>
<script type="text/javascript" src="uv-av/lib/offline.js"></script>
<script type="text/javascript" src="uv-av/helpers.js"></script>
<style>
body {
margin: 0px;
padding: 20px;
}
#uv {
width: 924px;
height: 668px;
}
#options {
padding: 20px 0 0 0;
}
</style>
</head>
<body>
<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>
<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 = {
root: './uv-av',
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);
});
}
function loadManifests(cb) {
// load manifests
$.getJSON('av.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
});
});
</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-av/uv.js"></script>
</body>
</html>