-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
executable file
·309 lines (263 loc) · 9.38 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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<!DOCTYPE html>
<html>
<head>
<title>FatFingerJS</title>
<meta name="description" content="FatFinger allows JS to run even with typos; it is a tool and an associated coding style for JS">
<meta charset="utf-8" />
<meta property="og:image" content="" />
<meta name="viewport" content="width=device-width" />
<script type="text/javascript" src="fatfinger.js"></script>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function () {
var cbTree = document.getElementById('cbTree');
var treeHolder = document.getElementById('treeHolder');
cbTree.addEventListener('change', function (e) {
if (cbTree.checked) {
treeHolder.style.display = 'block';
} else {
treeHolder.style.display = 'none';
}
});
var jstext = document.getElementById('jstext');
jstext.addEventListener('keydown', function(e) {
var keyCode = e.keyCode || e.which;
if (keyCode == 9) {
e.preventDefault();
var start = e.target.selectionStart;
var end = e.target.selectionEnd;
// set textarea value to: text before caret + tab + text after caret
e.target.value = (e.target.value.substring(0, start)
+ "\t"
+ e.target.value.substring(end));
// put caret at right position again
e.target.selectionStart =
e.target.selectionEnd = start + 1;
}
});
var btnSubmit = document.getElementById('btnSubmit');
btnSubmit.addEventListener('click', function(e) {
var errors = document.getElementById('errors');
var output = document.getElementById('output');
var newprogram = document.getElementById('newprogram');
var jstext = document.getElementById('jstext');
errors.textContent = '';
output.textContent = '';
newprogram.textContent = '';
var code = jstext.value;
var result = fatfinger.run(code);
if (result.text) {
newprogram.textContent = result.text;
if (result.succeeded)
{
ast = esprima.parse(result.text);
// printNode(ast, 0);
var output = document.getElementById('output');
output.innerHTML = JSON.stringify(ast, null, 4);
}
}
if (!result.succeeded)
{
var errString = "Failed to Parse";
if (result.error) {
errString += "<br/><br/>" + result.error;
}
errors.textContent = errString;
}
});
});
</script>
<style>
body {
padding: 20px;
margin-bottom: 70px;
}
body, * {
font-family: Consolas,monaco,monospace;
font-size: 14px;
line-height: 1.4em;
}
textarea {
font: 'Courier', monospace;
padding-top: 15px !important;
height: 385px !important;
}
.boxy {
-moz-appearance: textfield-multiline;
-webkit-appearance: textarea;
border: 1px solid gray;
font: medium -moz-fixed;
font: -webkit-small-control;
overflow: auto;
padding: 0px;
resize: both;
width: 400px;
height: 400px;
margin: 0px;
}
.holder {
margin: 10px;
float: left;
}
#treeHolder {
display: none;
}
#cbTree {
margin-top: 15px;
}
#cbTreeLabel {
margin-right: 60px;
}
h1 {
font-size: 2em;
font-weight: normal;
}
h2 {
margin-left: 10px;
}
#headerBreak {
margin-bottom: 60px;
}
h3 {
font-weight: bold;
}
p, li, textarea, .actions {
width: 100%;
max-width: 800px;
}
ul.pre li {
white-space: pre;
}
.checkbox {
display: inline-block;
}
.actions a {
float: right;
}
.actions {
clear: both;
}
.greyback {
background-color: #eeeeee;
width: 800px;
line-height: 200%;
}
#testSection {
overflow: hidden;
zoom: 1;
background-color: #eeeeee;
}
#outbox, .boxy {
background-color: #ffffff;
}
p {
margin-top: 20px;
}
p, li {
line-height: 180%;
}
#errors {
margin-left: 30px;
}
</style>
</head>
<body>
<h1><img src="FatFinger_logo.svg" alt="FatFingerJS" width="242" height="53" /></h1>
<h2><a href="http://danieltemkin.com">Daniel Temkin</a>, 2017</h2>
<h2><a href="https://github.com/rottytooth/FatFingerJS">on GitHub</a></h2>
<br id="headerBreak" />
<p>
FatFinger is a JavaScript library expanding JS to allow typos and
misspellings. Why bother with clean, well-formatted code when you
can write this and FatFinger will guess at your intentions?
</p>
<pre class="greyback">
<script type="text/javascript" src="fatfinger.js"></script>
<script type="text/javoscript"> // any misspelling of javascript works here
vart x = "herrrllo werld"
dokkkkumint.rit3(xx)
</script>
</pre>
<p>Don't bother with semi-colons. Open brackets and never close them. Misspell keywords, variables, and functions.</p>
<h3>Why?</h3>
<ul>
<li>Neutralize the autocorrect mentality</li>
<li>Question <a href="https://www.cs.utexas.edu/~EWD/transcriptions/EWD03xx/EWD340.html">forty-five years of advice</a> against expressiveness in the text of code</li>
<li>Play against the <a href="https://www.sac.edu/AcademicProgs/Business/ComputerScience/Pages/Hester_James/HACKER.htm">compulsiveness of programming</a></li>
<li>Embrace the chaos of JavaScript</li>
</ul>
<h3>Does it work?</h3>
<ul>
<li>Sometimes!</li>
</ul>
<p><b>Test out your code:</b></p>
<div id="testSection">
<div class="holder">
<b>INPUT (FatFinger-style JS)</b><br><br>
<textarea id="jstext" class="boxy">
var bottles;
for (var counter = 99; counter >= 1; counter = counter - 1)
{
if (counter == 1) {
botles = 'bottle';
} else {
bottles = 'bottles';
}
constole.log(counter+" "+ bottless +" of ber on the wall.");
if (countr < 99) {
conssole.lg("");
consoles.logg(counter+" "+ botttles+" o beer on the wall.");
}
conable.log(counter+" "+botles+" of beer.");
console.lo("Take one down.");
console.log("Pass it arund.");
ift (ount == 1) {
console.log("No botles of beer on the wall.");
}
}
</textarea>
<br />
<input type="checkbox" value="tree" id="cbTree" /><label for="cbTree" id="cbTreeLabel">Draw Syntax Tree</label>
<input type="button" value="Submit" id="btnSubmit" />
<br /><br/>
<b>Errors:</b>
<div id="errors" style="color: #aa0000;"></div>
<br />
</div>
<div class="holder">
<b>OUTPUT (conventional JavaScript)</b><br><br>
<div id="outbox" class="boxy">
<pre><code id="newprogram"></code></pre>
</div>
</div>
<div class="holder" id="treeHolder">
<b>SYNTAX TREE</b><br /><br />
<div class="boxy">
<pre><code id="output" style="width: 100%;"></code></pre>
</div>
</div>
</div>
<br clear="all" />
<h3>How To Use</h3>
<p>
Include fatfinger.js in your project, add a script tag with any misspelling of JavaScript
containing your FatFingered code. You'll need to declare all your vars as if option
explicit; FatFinger
assumes implicit declarations are actually misspelled assignments.
FatFinger has a poor concept of scope, so if you're doing fancy OO stuff, ask yourself: is there a good reason
I haven't made everything global??? If so, this might not be the right library / coding style for you.
</p>
<h3>See Also</h3>
<ul>
<li><a href="https://github.com/mattdiamond/fuckitjs">FuckItJS</a></li>
<li><a href="https://github.com/reinderien/mimic">Mimic</a></li>
<li><a href="http://jsfuck.com">JSFuck</a></li>
</ul>
<h3>Previous Languages</h3>
<ul>
<li><a href="http://danieltemkin.com/Entropy">Entropy</a> (2010)</li>
<li><a href="http://lightpattern.info/">Light Pattern</a> (2012)</li>
<li><a href="http://esolangs.org/wiki/Folders">Folders</a> (2015)</li>
<li><a href="http://danieltemkin.com/Esolangs">and more...</a></li>
</ul>
</body>
</html>