Skip to content

Commit

Permalink
fix editor shortcut key
Browse files Browse the repository at this point in the history
  • Loading branch information
mohayonao committed May 12, 2014
1 parent fdea54d commit 10b60b1
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,20 @@ window.onload = function() {
}
};

var execute = function() {
var code, result;

code = SCScript.compile(getCode(editor));

result = eval.call(null, code);

if (result) {
result = result.valueOf();
}

console.log(result);
};

editor = CodeMirror.fromTextArea(document.getElementById("editor"), {
mode: "SCScript",
theme: "sc-mode",
Expand All @@ -112,19 +126,8 @@ window.onload = function() {
showCursorWhenSelecting: true,
matchBrackets: true,
extraKeys: {
"Ctrl-Enter": function() {
var code, result;

code = SCScript.compile(getCode(editor));

result = eval.call(null, code);

if (result) {
result = result.valueOf();
}

console.log(result);
}
"Ctrl-Enter": execute,
"Cmd-Enter" : execute
}
});

Expand Down

0 comments on commit 10b60b1

Please sign in to comment.