Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit e816ed8

Browse files
committed
bug fix: factory must return an ActiveCode not just store it.
1 parent 7896f86 commit e816ed8

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

runestone/activecode/js/activecode.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,13 +1449,13 @@ ACFactory = {};
14491449
ACFactory.createActiveCode = function (orig, lang) {
14501450
var opts = {'orig' : orig, 'useRunestoneServices': eBookConfig.useRunestoneServices, 'python3' : eBookConfig.python3 };
14511451
if (lang === "javascript") {
1452-
edList[orig.id] = new JSActiveCode(opts);
1452+
return new JSActiveCode(opts);
14531453
} else if (lang === 'htmlmixed') {
1454-
edList[orig.id] = new HTMLActiveCode(opts);
1454+
return new HTMLActiveCode(opts);
14551455
} else if (['java', 'cpp', 'c', 'python3', 'python2'].indexOf(lang) > -1) {
1456-
edList[orig.id] = new LiveCode(opts);
1456+
return new LiveCode(opts);
14571457
} else { // default is python
1458-
edList[orig.id] = new ActiveCode(opts);
1458+
return new ActiveCode(opts);
14591459
}
14601460

14611461
}
@@ -1467,10 +1467,10 @@ ACFactory.addActiveCodeToDiv = function(outerdiv, acdiv, sid, initialcode, langu
14671467
thepre = document.createElement("pre");
14681468
thepre['data-component'] = "activecode";
14691469
thepre.id = acdiv;
1470-
thepre['data-lang'] = language;
1470+
$(thepre).data('lang', language);
14711471
$("#"+acdiv).append(thepre);
14721472
var opts = {'orig' : thepre, 'useRunestoneServices': true };
1473-
// todo: look at lang to decide what kind of ActiveCode to make
1473+
14741474
newac = ACFactory.createActiveCode(thepre,language);
14751475
savediv = newac.divid;
14761476
newac.divid = outerdiv;
@@ -1522,10 +1522,10 @@ ACFactory.createScratchActivecode = function() {
15221522
});
15231523
});
15241524

1525-
$(document).bind('keypress', '\\', function(evt) {
1526-
ACFactory.toggleScratchActivecode();
1527-
return false;
1528-
});
1525+
//$(document).bind('keypress', '\\', function(evt) {
1526+
// ACFactory.toggleScratchActivecode();
1527+
// return false;
1528+
//});
15291529
};
15301530

15311531

@@ -1540,7 +1540,7 @@ ACFactory.toggleScratchActivecode = function () {
15401540
$(document).ready(function() {
15411541
ACFactory.createScratchActivecode();
15421542
$('[data-component=activecode]').each( function(index ) {
1543-
ACFactory.createActiveCode(this, $(this).data('lang'));
1543+
edList[this.id] = ACFactory.createActiveCode(this, $(this).data('lang'));
15441544
});
15451545
if (loggedout) {
15461546
for (k in edList) {

0 commit comments

Comments
 (0)