This repository was archived by the owner on Aug 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
45 lines (41 loc) · 1.43 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
<!DOCTYPE html>
<html>
<head>
<title>JSON Schema Validator Web Component Demo</title>
<script src="polyfills/custom-elements.js"></script>
<script src="polyfills/babel-polyfill.js"></script>
<script src="dist/json-schema-validator.js"></script>
</head>
<body style="box-sizing: border-box; margin: 0 auto; max-width: 900px; padding: 50px; width: 100%;">
<div>
<json-schema-validator jsoneditor="https://unpkg.com/jsoneditor@5.25.0" metaschema="./json-schema-draft-04.json" schema="./example-schema.json"></json-schema-validator>
</div>
<script>
/*
I'd prefer to use fetch, but need to get demo to work on IE :-(
*/
function getText(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
callback(xhr.response);
}
}
xhr.open('GET', url, true);
xhr.send('');
}
getText("./example-data.json", function(text) {
var intervalID = setInterval(function(){
var validator = document.querySelector("json-schema-validator");
if (validator.editor) {
console.log("validator.editor exists");
validator.editor.setText(text);
console.log("set text");
clearInterval(intervalID);
console.log("cleared interval");
}
}, 1000);
});
</script>
</body>
</html>