-
Notifications
You must be signed in to change notification settings - Fork 136
/
playground.html
194 lines (173 loc) · 5.38 KB
/
playground.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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Δ.js Playground</title>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/Rabrennie/anything.js@master/dist/anything.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.9.0/codemirror.min.css"
/>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.9.0/addon/hint/show-hint.min.css"
/>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.1.6/semantic.min.css"/>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.9.0/theme/material.css"/>
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.9.0/codemirror.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.9.0/mode/javascript/javascript.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.9.0/addon/lint/javascript-lint.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.9.0/addon/hint/show-hint.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.9.0/addon/hint/javascript-hint.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.1.6/semantic.min.js"></script>
<script>
var anything = Δ;
var old_log = console.log;
console.log = function(){
commonLog(arguments[0], "");
old_log.apply(this, arguments)
}
var old_error = console.error;
console.error = function(){
commonLog(arguments[0], "error");
old_error.apply(this, arguments)
}
var old_info = console.info;
console.info = function(){
commonLog(arguments[0], "info");
old_info.apply(this, arguments);
}
var commonLog = function(val, type){
var lv = '';
var lt = typeof val;
switch(lt)
{
case "string":
lv = val.replace(/(?:\r\n|\r|\n)/g, '<br />');
break;
case "undefined":
lv = lt
default:
lv = val;
}
document.getElementById('opt').innerHTML += '<span class="log '+ lt + " " + type +'">'+lv+'</span>';
}
var RunThisBitch = function(){
document.getElementById('opt').innerHTML = '';
eval(myCodeMirror.getValue());
}
var AddΔ = function(){
myCodeMirror.replaceSelection('Δ.');
myCodeMirror.focus();
CodeMirror.commands.autocomplete(myCodeMirror, null, {completeSingle: false});
}
$(document).ready(function() {
RunThisBitch();
});
window.onerror = function (errorMsg, url, lineNumber) {
console.error(errorMsg + ' (Line '+ lineNumber +')');
return false;
}
</script>
<style type="text/css">
body, .pusher {
background: #111!important;
}
#opt
{
width: 100%;
min-height: 300px;
background: #14171A;
color:#46AFE3;
padding: 1em;
padding:0!important;
}
.log {
padding: 4px;
margin: 0;
font-family: monospace;
display: block;
width: 100%;
border-left: 4px solid #666;
}
.log.number {
color : #41A453;
}
.log.boolean
{
color: #EB5368;
}
.log.undefined
{
color: #666;
}
.log.object, .log.array
{
color: #fff;
font-style: italic;
}
.error
{
background-color: #382127;
color: #fff;
border-left: 4px solid red;
}
.info
{
color: #666;
border-left: 4px solid #46AFE3;
}
</style>
</head>
<body class="pushable">
<!-- Main Menu -->
<div class="ui fixed inverted menu">
<a href="index.html" class="header item">
<img class="logo" src="assets/tb_icon.png">
</a>
<a href="index.html" class="item">Home</a>
<a class="olive active item">Playground</a>
<a href="documentation.html" class="pink item">Documentation</a>
</div>
<!-- Page Contents -->
<div class="pusher">
<h1> </h1>
<div style="position: absolute; right: 2em; z-index: 100; top: 5em;">
<button class="ui inverted teal button" onclick="AddΔ()">Δ</button>
<button class="ui inverted olive button" onclick="RunThisBitch()">Run This Bitch <i class="right play icon"></i></button>
</div>
<textarea class="editor" id="Edit">
// Random shit
Δ.doTheThing();
console.log(Δ.flipText("anything!"));
// Calculate the answer to the life, the universe and everything
var theAnswer = Δ.theAnswerToLifeTheUniverseAndEverything();
// See if the answer equals to 5
if(Δ.isNumber5(theAnswer))
{
Δ.getOffMyLawn("WTF");
}
// Let them know
console.log("The answer... to the life... the universe... and everything is...\n\n" + theAnswer);
// Get a random numbah
var rnd = Δ.getRandomNumber();
console.log("The numbah is "+ rnd +". Guaranteed to be random");
// This doesn't do anything
Δ.nothing();
</textarea>
<script>
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById('Edit'), {lineNumbers: true,
extraKeys: {"Ctrl-Space": "autocomplete", "Ctrl-Enter": RunThisBitch},
mode: {name: "javascript", globalVars: true},
theme: 'material'
});
var orig = CodeMirror.hint.javascript;
myCodeMirror.on("keyup", function (cm, event) {
if (!cm.state.completionActive && event.keyCode == 190) {
CodeMirror.commands.autocomplete(cm, null, {completeSingle: false});
}
});
myCodeMirror.setSize(null, 400);
</script>
<h4 style="color:#fff;margin:1em;"><i class="icon file code outline"></i> Output (Console)</h4>
<div id="opt"></div>
</div>
</body>
</html>