-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
210 lines (205 loc) · 5.51 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>SIML -- Try it out!</title>
<script src="dist/siml.all.min.js"></script>
<script src="vendor/ace/ace.js"></script>
<style>
html, body {
height: 100%;
padding: 0;
margin: 0;
font-family: sans-serif;
}
#tryout {
clear: both;
height: 100%;
padding-top: 100px;
position: absolute;
top: 0;
left: 0;
width: 100%;
}
#header {
height: 100px;
background: #222;
text-align: center;
position: absolute;
top: 0;
left: 0;
width: 100%;
z-index: 3;
font-size: .8em;
}
#header h1, #header h1 a {
line-height: 100px;
color: #FFF;
margin: 0;
padding: 0;
}
#header a { color: #FFF; }
#tryout > *, #tryout, #error {
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
}
#tryout > * {
float: left;
margin: 0;
border: 3px solid #CCC;
padding: 10px;
font-size: .7em;
width: 33.33%;
height: 100%;
overflow: auto;
font-size: 12px;
}
#input, #html {
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Droid Sans Mono', 'Consolas', monospace;
}
#header #checkbox-container {
position: absolute;
left: 10px;
bottom: 10px;
background: rgba(0,0,0,0.8);
color: #FFF;
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
padding: 6px;
z-index: 9999;
font-size: 10px;
}
#angular-label { padding-right: 10px; }
#header label input { margin: 0; width: 12px; height: 12px; }
#input-container {
position: relative;
padding: 0;
}
#input {
font-size: 12px;
width: 100%;
border: none;
height: 100%;
margin: 0;
padding: 0;
}
#error {
position: absolute;
background: red;
color: #FFF;
font-weight: 700;
font-size: 12px;
bottom: 0;
left: 0;
display: none;
padding: 10px;
width: 100%;
z-index: 9999;
}
</style>
</head>
<body>
<div>
<a href="https://github.com/padolsey/SIML">
<img style="position: absolute; z-index:87; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png" alt="Fork me on GitHub">
</a>
</div>
<div id="header">
<h1>Try out <a href="https://github.com/padolsey/SIML">SIML</a></h1>
<div id="checkbox-container">
<label title="Employ Angular parsing for directives/pseudo-classes" for="doAngular" id="angular-label">
Angular mode <a href="https://github.com/padolsey/SIML/wiki/AngularJS">[?]</a> <input id="doAngular" type="checkbox" checked />
</label>
<label title="Tick to force SIML to ignore hierarchical indentation" for="curly" id="curly-label">
FORCE curlies? <small>[for nesting]</small> <input id="curly" type="checkbox" />
</label>
</div>
</div>
<div id="tryout">
<div id="input-container">
<div id="error"></div>
<div id="input">// SIML can do fancy-pants tabby HTML:<br>
section<br>
header > h1 'Hi there!'<br>
p 'This is a demo of SIML'<br>
p 'Try typing something...' <br>
p > small<br>
'<br>
Tip: Tick "Force curlies?" if you<br>
wanna force SIML to parse without paying<br>
attention to indentation level.<br>
'<br>
<br>
hr //-------------------------------------------<br>
<br>
// SIML can do HTML that looks like CSS<br>
form {<br>
fieldset {<br>
label {<br>
for: "your-name";<br>
text: "Enter something..."<br>
}<br>
input.something#your-name {<br>
placeholder: " something ";<br>
}<br>
}<br>
}<br>
<br>
hr //-------------------------------------------<br>
<br>
// SIML can do one-liners with vowelless quick tags:<br>
ftr>(strng{'SIML'} 'is on ' a[href='//git.io/siml']'Github')</div>
</div>
<pre id="html"></pre>
<div id="out"></div>
</div>
<script>
(function() {
var htmlOutput = document.getElementById('html');
var output = document.getElementById('out');
var curly = document.getElementById('curly');
var doAngular = document.getElementById('doAngular');
var error = document.getElementById('error');
var inputEditor = ace.edit('input');
inputEditor.setTheme('ace/theme/github');
var inputSession = inputEditor.getSession();
inputSession.on('change', debounce(update, 400));
curly.onchange = curly.oninput = doAngular.onchange = doAngular.oninput = update;
update();
function update() {
var value = inputSession.getValue();
error.style.display = '';
error.innerHTML = '';
try {
var html = siml[doAngular.checked?'angular':'html5'].parse( value, {curly: !!curly.checked, indent:' '} );
} catch(e) {
error.style.display = 'block';
error.innerHTML = String(e);
window.console && console.warn && console.warn(String(e));
return;
}
output.innerHTML = html;
htmlOutput.innerHTML = '';
htmlOutput.appendChild( document.createTextNode(html) );
}
function debounce(func, wait, immediate) {
var t, result;
return function() {
var context = this, args = arguments;
var later = function() {
t = null;
if (!immediate) result = func.apply(context, args);
};
var callNow = immediate && !t;
clearTimeout(t);
t = setTimeout(later, wait);
if (callNow) result = func.apply(context, args);
return result;
};
}
}());
</script>
</body>
</html>