-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.html
49 lines (38 loc) · 933 Bytes
/
api.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
<!DOCTYPE html>
<meta charset="utf-8" />
<div id="body">
</div>
<script type="module">
import {parse} from './parse.js'
import {toXml} from './toXml.js'
import {toElems} from './toElems.js'
import {jsonToJevko} from './jsonToJevko.js'
document.getElementById("body").append(...toElems(parse(`
label [URL]
input [
id=[url]
type=[text]
style=[width: 30rem]
value=[https://hacker-news.firebaseio.com/v0/user/jl.json?print=pretty]
]
br []
button [
id=[submit]
[submit]
]
pre [id=[jevkoResult]]
`)))
const fetchUrl = async () => fetch(document.getElementById("url").value).then(async (res) => {
const json = await res.json()
console.log(json)
return json
})
document.body.onload = () => {
const submitButton = document.getElementById("submit")
submitButton.onclick = () => {
fetchUrl().then(json => {
document.getElementById("jevkoResult").textContent = jsonToJevko(json)
})
}
}
</script>