-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
124 lines (105 loc) · 3.34 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Editor</title>
<style type="text/css" media="screen">
body {
overflow: hidden;
}
#editor-1 {
margin: 0;
position: absolute;
top: 0;
bottom: 20%;
left: 0;
right: 50%;
}
#editor-2 {
margin: 0;
position: absolute;
top: 0;
bottom: 0;
left: 50%;
right: 0;
}
#editor-3 {
margin: 0;
position: absolute;
top: 80%;
bottom: 0;
left: 0;
right: 50%;
}
</style>
</head>
<body>
<pre id="editor-1"></pre>
<pre id="editor-2"></pre>
<pre id="editor-3"></pre>
<link rel="stylesheet" type="text/css" href="../themes/jquery-ui-1.8.16.custom.css"/>
<script src="jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
<script src="coffee-script.js" type="text/javascript"></script>
<script src="ace/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="ace/theme-monokai.js" type="text/javascript" charset="utf-8"></script>
<script src="ace/mode-javascript.js" type="text/javascript" charset="utf-8"></script>
<script src="ace/mode-coffee.js" type="text/javascript" charset="utf-8"></script>
<script>
window.onload = function() {
var match = location.search.match(/coffee=([^&]*)/);
var coffeeCode = '';
var JavaScriptMode = require("ace/mode/javascript").Mode;
var CoffeeScriptMode = require("ace/mode/coffee").Mode;
var coffee = ace.edit("editor-1");
coffee.setTheme("ace/theme/monokai");
coffee.getSession().setMode(new CoffeeScriptMode());
var js = ace.edit("editor-2");
js.setTheme("ace/theme/monokai");
js.getSession().setMode(new JavaScriptMode());
var output = ace.edit("editor-3");
output.setTheme("ace/theme/monokai");
output.getSession().setMode(new CoffeeScriptMode());
var timeout;
coffee.getSession().getDocument().on('change', function() {
clearTimeout(timeout);
timeout = setTimeout(function() {
outputValue = '';
output.getSession().getDocument().setValue(outputValue);
var code = coffee.getSession().getDocument().getValue();
try {
coffeeCode = code;
outputMessage(code);
code = CoffeeScript.compile(code, {comments: true});
js.getSession().getDocument().setValue(code);
log(CoffeeScript.eval(coffeeCode, {bare: true}));
} catch(e) {
log(e);
}
}, 100);
});
window.onerror = function(message, url, line) {
log(line + ': ' + message);
}
log = function() {
var message = '';
for(var i = 0; i < arguments.length; ++i) {
message += (message === '' ? '>> ' : ', ' ) + arguments[i];
}
outputMessage(message);
}
outputValue = '';
outputMessage = function(message) {
outputValue += message + '\n';
output.getSession().getDocument().setValue(outputValue);
}
if(match != null) {
coffeeCode = decodeURI(location.search.match(/coffee=([^&]*)/)[1]);
coffee.getSession().getDocument().setValue(coffeeCode);
}
window.coffee = coffee;
};
</script>
</body>
</html>