-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcommands.coffee
36 lines (32 loc) · 865 Bytes
/
commands.coffee
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
do ->
curr_command = -1
window.Command = Backbone.Model.extend
defaults:
'index': 0
'contents': ""
compile: ->
try
jscode = CoffeeScript.compile(@get('contents'))
# remove wrapping closure
jscode = jscode.substring(16)
jscode = jscode.substring(0,jscode.length-16)
return {
type: 'success'
result: jscode
}
catch error
return {
type: 'error'
result: error
}
window.Commands = Backbone.Collection.extend
model: Command
localStorage: new Store("command")
window.CommandView = Backbone.View.extend
tagName: "pre"
className: "input"
render: ->
code = @model.get('contents')
$(@el).addClass('cm-s-idle');
CodeMirror.runMode(code, "coffeescript", @el)
$('#puts').append(this.el)