-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcommands.js
43 lines (42 loc) · 1 KB
/
commands.js
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
(function() {
var curr_command;
curr_command = -1;
window.Command = Backbone.Model.extend({
defaults: {
'index': 0,
'contents': ""
},
compile: function() {
var jscode;
try {
jscode = CoffeeScript.compile(this.get('contents'));
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")
});
return window.CommandView = Backbone.View.extend({
tagName: "pre",
className: "input",
render: function() {
var code;
code = this.model.get('contents');
$(this.el).addClass('cm-s-idle');
CodeMirror.runMode(code, "coffeescript", this.el);
return $('#puts').append(this.el);
}
});
})();