-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
88 lines (86 loc) · 3.92 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
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Cubix interpreter</title>
<script src="cubix.js"></script>
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro|Source+Sans+Pro' rel='stylesheet' type='text/css'>
<style>
* {
font-family: "Source Sans Pro", sans-serif;
}
textarea, pre, span {
font-family: "Source Code Pro", monospace;
font-size: 14px;
}
.arrow-N {
background-image: url("img/ip-n.png");
}
.arrow-S {
background-image: url("img/ip-s.png");
}
.arrow-E {
background-image: url("img/ip-e.png");
}
.arrow-W {
background-image: url("img/ip-w.png");
}
</style>
</head>
<body>
<textarea id="code" rows=5 cols=50 placeholder="Code" oninput="net()">./v.o;@?/"!dlroW"S',u/"Hello"</textarea>
<br>
<button id="golf" onclick="golf()">Shorten</button>
<button id="cube" onclick="cube()">Cubify</button>
Preset: <select id="select" onchange="$('input').value=this.value.split('`')[0];$('code').value=this.value.split('`')[1];net();">
<option value="`./v.o;@?/"!dlroW"S',u/"Hello"">Hello, World!</option>
<option value="13`%@\?I:u;>O/)((./0\)?/">Primality test</option>
<option value="1`!I\@O">Truth machine</option>
<option value="0`@IO?$">Lie machine</option>
<option value="Hello!`@_i?o">cat</option>
<option value="`......">Blank 1-cube</option>
<option value="`........................">Blank 2-cube</option>
<option value="`......................................................">Blank 3-cube</option>
<option value="`................................................................................................">Blank 4-cube</option>
</select>
<br>
<textarea id="input" rows=2 cols=50 placeholder="Input"></textarea>
<br>
Iterations per second: <input id="speed" type="number" step="any" min=1 value=20 max=100></input>
<br>
<button id="run" onclick="Cubix.run($('code').value,$('input').value)">Run</button>
<button id="pause" onclick="pause()" disabled>Pause</button>
<button id="step" onclick="if(!$('run').disabled)Cubix.run($('code').value,$('input').value),pause();update()">Step</button>
<button id="stop" onclick="stop('Program stopped manually.')" disabled>Stop</button>
<input type="checkbox" id="debug">Debug*
<br>
<textarea id="output" rows=3 cols=50 placeholder="Output appears here."></textarea><br>
* Sends debug info to browser console.<br>
<button onclick="link()">Generate permalink</button>
<p>Upload an ISO-8859-1-encoded file:</p>
<input id="text-file" type="file" onsubmit="document.getElementById('code').value=this.value" />
<input id="submit" type="button" value="Submit" onclick="var fr=new FileReader();fr.onload=function(){document.getElementById('code').value=fr.result};fr.readAsBinaryString(document.getElementById('text-file').files[0])"></button>
<pre id="net" style="position:absolute;top:100px;left:480px;"></pre>
<script>
function link() {
window.history.pushState('', 'Cubix interpreter',
'/cubix/?code=' + btoa(document.getElementById('code').value)
+ '\&input=' + btoa(document.getElementById('input').value)
+ '\&speed=' + document.getElementById('speed').value);
}
var args = location.search.match(/[&?](c(?:ode)?|i(?:nput)?|s(?:peed)?)=[^&]*/g);
var code, input;
if(args) for(var i = 0; i < args.length; ++i) {
var item = args[i];
var tmp = item.slice(item.indexOf('=') + 1);
if(/^.c/i.test(item))
document.getElementById("code").value = atob(tmp);
else if(/^.i/i.test(item))
document.getElementById("input").value = atob(tmp);
else if(/^.s/i.test(item))
document.getElementById("speed").value = Math.max(+tmp || 20, 0) || 1;
}
net();
</script>
</body>
</html>