This repository has been archived by the owner on Oct 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinterpreter2.html
83 lines (83 loc) · 3.62 KB
/
interpreter2.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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>𝔼𝕊𝕄𝕚𝕟 2 Interpreter</title>
<link rel="stylesheet prefetch" href="https://molarmanful.github.io/TerseUI/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/lz-string/1.4.4/lz-string.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/2.4.1/math.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.1/lodash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.string/3.2.2/underscore.string.min.js"></script>
<script src="http://xregexp.com/v/3.0.0/xregexp-min.js"></script>
<script src="https://rawgit.com/Ed-von-Schleck/shoco/master/shoco.js"></script>
<script src="https://rawgit.com/numbers/numbers.js/master/src/numbers.min.js"></script>
<script src="https://rawgit.com/davebalmer/turtlewax/master/pen_min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/numeral.js/1.4.5/numeral.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js"></script>
<link rel='stylesheet prefetch' href='dvsm.css'>
<style>
textarea {
font-family:dvsm;
width:100%;
background-color: #5a5a5a!important;
}
#c {
height:10em
}
#i,#o {
height:5em
}
#cv {
height:100%;
width:100%;
background-color:white;
}
</style>
<script>
function utf(s) {
var len = 0;
for (var i = 0; i < s.length; i++) {
var code = s.charCodeAt(i);
if (code <= 0x7f) {
len += 1;
} else if (code <= 0x7ff) {
len += 2;
} else if (code >= 0xd800 && code <= 0xdfff) {
// Surrogate pair: These take 4 bytes in UTF-8 and 2 chars in UCS-2
// (Assume next char is the other [valid] half and just skip it)
len += 4; i++;
} else if (code < 0xffff) {
len += 3;
} else {
len += 4;
}
}
return len;
}
</script>
</head>
<body onload='c.value=decodeURIComponent((/code=(.+)/.exec(location.search)||[,""])[1]);document.getElementById("i").value=decodeURIComponent((/input=([^&]+)/.exec(location.search)||[,""])[1]);E.checked=eval(decodeURIComponent((/eval=([^&]+)/.exec(location.search)||[,""])[1]));co.innerHTML=c.value.length+" chars, "+utf(c.value)+" bytes, chars to bytes ratio = "+(c.value.length/utf(c.value)).toFixed(2);' >
<div class='container'>
<h1>𝔼𝕊𝕄𝕚𝕟 2 Interpreter (Firefox Only)</h1>
<hr>
<div class='row'>
<div class='col-sm-6'>
<h2>Code <small id='co'></small></h2>
<textarea id='c' class='form-control' wrap='off' oninput='co.innerHTML=c.value.length+" chars, "+utf(c.value)+" bytes, chars to bytes = "+(c.value.length/utf(c.value)).toFixed(2);'></textarea>
<h2>Input</h2>
<textarea id='i' class='form-control' wrap='off'></textarea>
<button id='r' class='btn btn-primary' onclick='cv.getContext("2d").clearRect(0,0,cv.width,cv.height),o.value="",Ξ=[],ᶈ=[],ï=E.checked?eval(document.getElementById("i").value):document.getElementById("i").value,î=ï[0],í=ï[1],ì=ï[2],ᴉ=[...``+ï],paste=[],[...nchars].map((x,y)=>{eval(x+`=`+y)});Σ(c.value)'>Run</button>
<button id='p' class='btn btn-success' onclick="window.location.href='?eval='+E.checked+'&input='+encodeURIComponent(document.getElementById('i').value)+'&code='+encodeURIComponent(c.value)">Permalink</button>
<label><input type='checkbox' id='E'> Eval input?</label>
</div>
<div class='col-sm-6'>
<h2>Output</h2>
<textarea id='o' class='form-control' wrap='off' readonly></textarea>
<h3>Canvas</h3>
<canvas id='cv'></canvas>
</div>
</div>
</div>
<script src="interpreter2.js"></script>
</body>
</html>