-
Notifications
You must be signed in to change notification settings - Fork 0
/
json_view.ts
40 lines (38 loc) · 963 Bytes
/
json_view.ts
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
/**
* JSON_VIEW_SRC is the source URL for the json-view script.
*/
const JSON_VIEW_SRC =
"https://cdn.jsdelivr.net/gh/pgrabovets/json-view@master/dist/jsonview.js";
/**
* HTML_JSON_VIEW is the HTML template for the JSON view.
*/
export const HTML_JSON_VIEW = `<!DOCTYPE html>
<html>
<head>
<title>id.fartlabs.org</title>
<link rel="icon" href="https://fartlabs.org/fl-logo.png" type="image/x-icon">
<style>
* {
font-family: consolas, monospace;
}
</style>
</head>
<body>
<div class="root"></div>
<script type="text/javascript" src="${JSON_VIEW_SRC}"></script>
<script type="text/javascript">
fetch('/')
.then((res)=> {
return res.text();
})
.then((data) => {
const tree = jsonview.create(data);
jsonview.render(tree, document.querySelector('.root'));
jsonview.expand(tree);
})
.catch((err) => {
console.log(err);
});
</script>
</body>
</html>`;