-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ejs
42 lines (38 loc) · 1.33 KB
/
index.ejs
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>JSON Form web-component demo</title>
<!--link rel="stylesheet" href="https://unpkg.com/@ubio/[email protected]/index.css"></link-->
<script src="https://unpkg.com/json-viewer-custom-element"></script>
<script>
const q = document.querySelector.bind(document);
window.addEventListener('load', () => {
const form = q('json-form');
const viewer = q('json-viewer');
connect(form, viewer);
});
function connect(form, viewer) {
form.addEventListener('change', () =>
viewer.setAttribute('value', form.getAttribute('value'))
);
}
</script>
<style>
json-viewer { margin: 50px; display: block; }
json-form { margin: 50px; display: block; }
</style>
</head>
<body>
<!--
<json-form
schema='{"type":"string","title":"Greeting","maxLength":5,"description":"Enter any greeting"}'
value='"hello"'
></json-form>
<json-viewer
value='"hello"'
></json-viewer>
-->
</body>
</html>