-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
119 lines (113 loc) · 3.67 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="kennel.css">
<title>Kennel Live Renderer</title>
<script src="bundle.js"></script> <!-- browserify wrapper.js -o bundle.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ace.min.js"></script>
<style type="text/css">
html, body {
margin: 0;
}
#root {
display: grid;
grid-template-columns: 100% 100%;
width: 50vw;
height: 100vh;
}
#root > .grid {
border: none;
margin: 0;
padding: 10px;
}
#kennelIn {
background: #202020;
color: white;
}
#kennelOut {
background: #161616;
color: white;
overflow: auto;
font-family: sans-serif;
}
</style>
</head>
<body>
<div id="root">
<div class="grid" id="kennelIn"></div>
<div class="grid" id="kennelOut">
</div>
</div>
</body>
<script type="text/javascript">
let isTyping = 9999;
setInterval(()=>{
if (--isTyping <= 0) {
update();
isTyping = 9999;
}
}, 10);
function ndChangeTab(show, hide) {
let i;
// Hide elements.
for (i = 0; i < document.querySelectorAll(`${hide}.nd_tab`).length; i++) {
document.querySelectorAll(`${hide}.nd_tab`)[i].classList.add("nd_hidden");
document.querySelectorAll(`${hide}.nd_nav_btn`)[i].classList.remove("nd_active");
}
// Show elements.
for (i = 0; i < document.querySelectorAll(`${show}.nd_tab`).length; i++) {
document.querySelectorAll(`${show}.nd_tab`)[i].classList.remove("nd_hidden");
document.querySelectorAll(`${show}.nd_nav_btn`)[i].classList.add("nd_active");
}
}
function update() {
try {
const nd = new Kennel(JSON.parse(editor.getValue()));
document.getElementById("kennelOut").innerHTML = nd.render();
} catch(err) {
document.getElementById("kennelOut").innerHTML = `<div style="color: red; opacity: 0.5"><b>Error: </b> ${err}</div>`;
}
localStorage.setItem("data", editor.getValue())
}
// Set up text editor (Ace)
const editor = ace.edit("kennelIn");
editor.session.setMode("ace/mode/json");
editor.setTheme("ace/theme/nord_dark");
// Restore text
const oldData = localStorage.getItem("data")
if (oldData) {
editor.setValue(oldData)
} else {
editor.setValue(JSON.stringify({
"minVersion": "0.1",
"tintColor": "#33dd33",
"tabs": [
{
"tabname": "Details",
"views": [
{
"class": "DepictionHeaderView",
"title": "Welcome to Kennel Live Renderer!"
},
{
"class": "DepictionMarkdownView",
"markdown": "Type in any valid native depiction code here and watch it get rendered!"
},
{
"class": "DepictionTableButtonView",
"title": "View Depiction Documentation",
"action": "https://developer.getsileo.app/native-depictions",
"openExternal": 1
}
],
"class": "DepictionStackView"
}
],
"class": "DepictionTabView"
}, null, 4))
}
document.getElementById("kennelIn").onkeyup = () => {isTyping = 60};
update();
</script>
</html>