-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.html
48 lines (48 loc) · 1.84 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
<!DOCTYPE html>
<html lang="en">
<head>
<title>X-Wing Squadron Specification</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="dist/xws.min.js"></script>
</head>
<body style="padding: 1em;">
<h1>XWS Specification and Validator</h1>
<div>
<h2>Specification Links</h2>
<p><a href="https://github.com/elistevens/xws-spec/blob/master/README.md">XWS Specification Text (Human Readable)</a></p>
<p><a href="./sample.json">Sample XWS JSON</a></p>
<p><a href="./schema.json">JSON Schema Validator Document</a></p>
<p><a href="https://github.com/geraintluff/tv4">Tiny Validator for JSON Schema v4</a></p>
</div>
<div>
<h2>Enter XWS JSON</h2>
<textarea id="input_json" style="width: 50em; height: 20em;"></textarea>
</div>
<div>
<p>
<button id="button_validate" class="btn btn-primary">Validate XWS JSON</button>
</p>
</div>
<div>
<h2>Validation Errors</h2>
<div id="errors">(Enter JSON First)</div>
</div>
<script>
$('#button_validate').click(function (event) {
try {
var ret = window.xws.validateSquadron(JSON.parse($('#input_json').val()));
if(ret[1].length) {
$('#errors').html('<p>' + ret[1].join('</p><p>') + '</p>');
} else {
$('#errors').html('<p>No validation errors.</p>');
}
} catch(error) {
$('#errors').html('<p>' + error + '</p>');
}
})
</script>
</body>
</html>