/
DULIIIFTree.html
85 lines (80 loc) · 2.64 KB
/
DULIIIFTree.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
<!DOCTYPE html>
<html>
<head>
<title>Navigating IIIF manifests using Handlebars</title>
<meta charset="utf-8"/>
<style type="text/css">
.handlebars {
display: none;
}
body {
padding: 25px ;
}
td {
padding: 5px ;
}
</style>
<script src="https://code.jquery.com/jquery-2.1.3.min.js" > </script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/3.0.1/handlebars.min.js"> </script>
<script>
Handlebars.registerHelper('ifEquals', function(arg1, arg2, options) {
return (arg1 == arg2) ? options.fn(this) : options.inverse(this);
});
Handlebars.registerHelper('trimString', function(passedString2) {
let theString2 = passedString2.substring(13,19);
return new Handlebars.SafeString(theString2)
});
function getQueryStringValue (key) {
return decodeURIComponent(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + encodeURIComponent(key).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));
}
let start_json_data_url = "https://iiif.durham.ac.uk/manifests/trifle/collection/index";
let json_data_url = getQueryStringValue("manifest");
if (json_data_url) {
json_url = json_data_url
} else {
json_url = start_json_data_url
}
$(document).ready(function(){
$.getJSON(json_url,
function (data) {
let mysource = $('#jsonlisttemplate').html();
let mytemplate = Handlebars.compile(mysource);
let myresult = mytemplate(data)
$('#jsonlist').html(myresult);
});
});
</script>
<script id="jsonlisttemplate" type="text/x-handlebars-template">
<h2>{{label}}</h2> <br />
{{[@id]}} <br />
{{[@type]}} <br />
<h3>Collections</h3>
<form id="form1" method="get" action="">
{{#each collections}}
<button type="submit" name="manifest" value="{{[@id]}}">{{label}}</button><br />
{{[@id]}} <br />
<br />
{{/each}}
<h3>Manifests</h3>
<table>
{{#each manifests}}
<tr>
<td><a href="https://iiif.durham.ac.uk/index.html?manifest={{[@id]}}">{{label}}</a></td>
{{#ifEquals (trimString [@id]) "durham" }}
<td rowspan="2"><input type="button" onclick="location.href='DULIIIFdaoer.html?manifest={{[@id]}}';" value="EAD links" /></td>
{{/ifEquals}}
<td rowspan="2"><input type="button" onclick="location.href='DULIIIFimager.html?manifest={{[@id]}}';" value="Image URLs" /></td>
</tr>
<tr><td>Manifest: {{[@id]}} </td></tr>
{{/each}}
</table>
</form>
</script>
</head>
<body>
<h1>IIIF Manifests</h1>
Buttons in the Collections section link to next level of manifest down <br />
Links in the Manifests section open the item in local Durham Mirador<br /><br />
<div id="jsonlist">Manifest bits go here...</div>
</body>
</html>