-
Notifications
You must be signed in to change notification settings - Fork 2
/
today.html
106 lines (88 loc) · 2.9 KB
/
today.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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>Wellcome Today</title>
<style type="text/css">
.wrapper {
position: fixed;
top:3em;
left: 0;
bottom: 0;
right: 0;
overflow: auto;
}
#osd {
background-color: #fff;
width:100%;
height:100%;
}
#collection {
width:30em;
}
</style>
<script src="openseadragon/openseadragon.min.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
</head>
<body>
<div class="selector">
<input class="loader" id="recents" type="button" value="Most recent 24" data-uri="http://wellcomelibrary.org/service/collections/recently-digitised/24/" />
<input class="loader" id="lucky" type="button" value="Lucky dip 24" data-uri="http://wellcomelibrary.org/service/collections/lucky-dip/24/" />
|
<input id="collection" type="text" placeholder="(Collection URL)" />
<input class="loader" id="gobutton" type="button" value="Go" />
<span id="status" />
</div>
<div class="wrapper">
<div id="osd" class="openseadragon"></div>
</div>
<script type="text/javascript">
var viewer;
$(function() {
var qs = /collection=(.*)/g.exec(window.location.search);
if(qs && qs[1]){
loadCollection(qs[1]);
$('#collection').val(qs[1]);
}
});
$('input.loader').click(function() {
var uri = $(this).attr('data-uri');
if(uri){
$('#collection').val(uri);
} else {
uri = $('#collection').val();
}
loadCollection(uri);
});
function loadCollection(collection){
$('#status').text('loading collection...');
var max = 100;
$.getJSON( collection, function( data ) {
var thumbServices = [];
$.each(data.manifests, function(i, m){
if(m.thumbnail && m.thumbnail.service && max-- > 0){
thumbServices.push(m.thumbnail.service["@id"] + "/info.json");
}
});
var cols = Math.ceil(Math.sqrt(thumbServices.length));
if(viewer){
viewer.removeHandler('open');
viewer.destroy();
viewer = null;
}
$('#status').text('loading images...');
viewer = OpenSeadragon({
id: "osd",
prefixUrl: "openseadragon/images/",
collectionMode: true,
collectionColumns: cols,
tileSources: thumbServices
});
viewer.addHandler('open', function(data){
$('#status').text('loaded.');
});
});
}
</script>
</body>
</html>