-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.erb
87 lines (72 loc) · 2.69 KB
/
index.erb
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Instant</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
<link href="/css/bootstrap.css" rel="stylesheet">
<link href="/css/bootstrap-responsive.css" rel="stylesheet">
<link href="/css/app.css" rel="stylesheet">
</head>
<body>
<div class="row-fluid">
<div class="span12">
<div class="row-fluid">
<div class="left">
<div id="editor">def binary_search(search, array)
low = 0
high = array.length - 1
end
binary_search('c', ['a', 'b', 'c', 'd', 'e', 'f'])</div>
</div>
<div class="right">
<pre id="output">
</pre>
</div>
</div>
</div>
</div>
<a href="http://github.com/siuying/instant"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://a248.e.akamai.net/assets.github.com/img/7afbc8b248c68eb468279e8c17986ad46549fb71/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub"></a>
<script src="/js/jquery.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/coffee-script.js"></script>
<script src="/js/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="/js/theme-twilight.js" type="text/javascript" charset="utf-8"></script>
<script src="/js/mode-ruby.js" type="text/javascript" charset="utf-8"></script>
<script type="text/coffeescript">
$ ->
editor = ace.edit("editor")
Ruby = require("ace/mode/ruby").Mode
editor.getSession().setMode(new Ruby())
editor.setTheme("ace/theme/twilight")
editor.getSession().setTabSize(2)
editor.getSession().setUseSoftTabs(true)
compile = ->
val = editor.getSession().getValue()
$.ajax
type: 'POST'
url: '/compile'
data:
source: val
success: (data) ->
$(".err-msg").remove()
if data.result
$("#output").text(data.result)
else
$("#output").text("(no output)")
$("#output").append("\nreturn #{data.return_value}")
if data.status == "error" && data.message
$("#output").after "<div class='alert alert-error err-msg'>#{data.message}</div>"
error: (x, t, e) ->
console.log x, t, e
$(".err-msg").remove()
$("#output").after "<div class='alert alert-error err-msg'>#{x.responseText}</div>"
dataType: 'json'
compile()
editor.getSession().on 'change', compile
</script>
</body>
</html>