Skip to content

Commit

Permalink
Merge branch 'refs/heads/tryjavascript'
Browse files Browse the repository at this point in the history
  • Loading branch information
bnmnetp committed Jan 24, 2014
2 parents 7b946bb + 1d51021 commit 95ca394
Show file tree
Hide file tree
Showing 5 changed files with 686 additions and 22 deletions.
13 changes: 8 additions & 5 deletions common/js/bookfuncs.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
*/

/* This should come from a config object loaded by the book...
something like configjs */


function handleEdKeys(ed, e) {
if (e.keyCode === 13) {
Expand Down Expand Up @@ -83,6 +80,7 @@ function createEditors() {
for (var i = 0; i < edList.length; i++) {
newEdId = edList[i].id;
var includes = edList[i].getAttribute('prefixcode');
var lang = edList[i].getAttribute('lang');
var first_line = 1;
if (includes !== "undefined") {
includes = eval(includes)
Expand All @@ -94,7 +92,7 @@ function createEditors() {
first_line = 1;
}
cm_editors[newEdId] = CodeMirror.fromTextArea(edList[i], {
mode: {name: "python",
mode: {name: lang,
version: 2,
singleLineStringErrors: false},
lineNumbers: true,
Expand Down Expand Up @@ -279,8 +277,13 @@ function runit(myDiv, theButton, includes, suffix) {
read: builtinRead,
python3: true
});
var lang = document.getElementById(myDiv).lang;
try {
Sk.importMainWithBody("<stdin>", false, prog);
if(lang === 'python') {
Sk.importMainWithBody("<stdin>", false, prog);
} else {
eval(prog);
}
logRunEvent({'div_id': myDiv, 'code': prog, 'errinfo': 'success'}); // Log the run event
} catch (e) {
logRunEvent({'div_id': myDiv, 'code': prog, 'errinfo': e.toString()}); // Log the run event
Expand Down
Loading

0 comments on commit 95ca394

Please sign in to comment.