@@ -23,7 +23,7 @@ ActiveCode.prototype.init = function(opts) {
2323 this . python3 = opts . python3 ;
2424 this . origElem = orig ;
2525 this . divid = orig . id ;
26- this . code = $ ( orig ) . text ( ) ;
26+ this . code = $ ( orig ) . text ( ) || "\n\n\n\n\n" ;
2727 this . language = $ ( orig ) . data ( 'lang' ) ;
2828 this . timelimit = $ ( orig ) . data ( 'timelimit' ) ;
2929 this . includes = $ ( orig ) . data ( 'include' ) ;
@@ -316,6 +316,9 @@ ActiveCode.prototype.loadEditor = function () {
316316
317317 if ( res . source ) {
318318 this . editor . setValue ( res . source ) ;
319+ setTimeout ( function ( ) {
320+ this . editor . refresh ( ) ;
321+ } . bind ( this ) , 500 ) ;
319322 $ ( this . loadButton ) . tooltip ( { 'placement' : 'bottom' ,
320323 'title' : "Loaded your saved code." ,
321324 'trigger' : 'manual'
@@ -657,19 +660,21 @@ ActiveCode.prototype.runProg = function() {
657660 } ;
658661
659662ActiveCode . addActiveCodeToDiv = function ( outerdiv , acdiv , sid , initialcode , language ) {
660- var acdiv , thepre , newac ;
663+ var thepre , newac ;
664+ $ ( "#" + acdiv ) . empty ( ) ;
661665 thepre = document . createElement ( "pre" ) ;
662666 thepre [ 'data-component' ] = "activecode" ;
663667 thepre . id = acdiv ;
664668 thepre [ 'data-lang' ] = language ;
665669 $ ( "#" + acdiv ) . append ( thepre ) ;
666670 var opts = { 'orig' : thepre , 'useRunestoneServices' : true } ;
667- newac = new ActiveCode ( opts )
671+ // todo: look at lang to decide what kind of ActiveCode to make
672+ newac = new ActiveCode ( opts ) ;
668673 savediv = newac . divid ;
669674 newac . divid = outerdiv ;
670675 newac . loadEditor ( ) ;
671676 newac . divid = savediv ;
672-
677+ newac . editor . setSize ( 500 , 300 ) ;
673678} ;
674679
675680ActiveCode . createScratchActivecode = function ( ) {
@@ -1548,4 +1553,4 @@ $(document).bind("runestone:logout",function() {
15481553 edList [ k ] . disableSaveLoad ( ) ;
15491554 }
15501555 }
1551- } ) ;
1556+ } ) ;
0 commit comments