-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathindex.html
111 lines (101 loc) · 4.6 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
---
title: Presentation API Validator
title_override: Presentation API Validator
id: index.html
categories: [pages]
layout: page
---
<section class="wrapper">
<div>
This service will validate a IIIF Presentation API resource against the specification. Fill in the URL of your manifest, and it will try to parse it and issue errors for failed requirements, and warnings for recommendations that haven't been followed.
</div>
<div style="border: 1px solid black;margin-left: 10px; margin-top: 20px; padding: 10px">
<form id='manifest-validation-form' method="GET" action="https://presentation-validator.iiif.io/validate">
URL of Manifest to Validate:<br/>
<input style="margin-left: 25px" type="text" id="url" name="url" size="80"><br/>
Select Presentation API Version:
<select name="version" id="version">
<option value="3.0" selected>3.0</option>
<option value="2.1">2.1</option>
<option value="2.0">2.0</option>
<option value="1.0">1.0</option>
</select>
<br/>
<input type="submit" value="Go!" id="submit-url">
</form>
</div>
<br/>
<div id='results' style="display: none;" >
<h3>Validation Results:</h3>
<hr/>
<div id='results-content'></div>
</div>
<br/>
<hr/>
<div style="margin-top:20px">
<b>Technical Note</b>
<p>
If you would like to use the validator programmatically, there are two options:
</p>
<ul>
<li><a href="http://github.com/IIIF/presentation-validator/">Download</a> the code from github and run it locally.</li>
<li>Use it online with JSON based output, by an HTTP GET to this endpoint:<br/>https://presentation-validator.iiif.io/validate?format=json&version=2.0&url=<i>manifest-url-here</i></li>
</ul>
</div>
<!-- AJAX code for form submission -->
<script>
// Call out to the validation service and get a result
function handleSubmission(e) {
e.preventDefault();
var data = {
url: document.getElementById('url').value,
version: document.getElementById('version').value
}
document.getElementById('results-content').innerHTML = 'Processing ' + data.version + " validation...";
document.getElementById('results').style.display = "block";
var url = document.getElementById('manifest-validation-form').action + '?' + new URLSearchParams(data);
fetch(url)
.then(response => response.json())
.then(data => handleValidationResponse(data));
}
// Handle validation service response, render response block
function handleValidationResponse(data) {
str = '<div style="margin-left: 20px">'
str += '<div>URL Tested: '+ data.url + '</div><br/>'
if (data.okay) {
str += '<div><h2 style="color:green">Validated successfully</h2></div>'
} else {
if (data.errorList) {
for (var i = 0; i < data.errorList.length; i++) {
var error = data.errorList[i];
str+='<div>';
str+='<h2 style="color:red">' + error.title + '</h2>';
str+='<p><ul>';
str+='<li><b>Detail: </b> ' + error.detail + '</li>';
str+='<li><b>Path: </b>' + error.path + '</li>';
str+='<li><b>Description: </b>' + error.description + '</li>';
str+='</li></p>';
str+='<pre>';
str+= JSON.stringify(error.context);
str+='</pre>';
str+='</div>';
}
} else {
str += '<div><h2 style="color:red">Validation Error: '+data.error+'</h2></div>'
}
}
if (data.warnings.length){
str += '<div style="margin-top: 20px">Warnings:<ul>';
for(var i =0; i < data.warnings.length; i++) {
str+= '<li>'+data.warnings[i]+'</li>';
}
str += '</ul></div>';
}
str += '</div>';
document.getElementById('results-content').innerHTML = str;
document.getElementById('results').style.display = "block";
}
// Set up event handler.
document.getElementById("submit-url").onclick = handleSubmission;
</script>
</section>