@@ -117,8 +117,10 @@ var curVisualizerID = 1; // global to uniquely identify each ExecutionVisualizer
117117// granularity instead of line-level granularity (HIGHLY EXPERIMENTAL!)
118118// hideCode - hide the code display and show only the data structure viz
119119// tabularView - render a tabular view of ALL steps at once (EXPERIMENTAL)
120- // lang - to render labels in a style appropriate for other languages.
121- // e.g., 'js' for JavaScript, 'java' for Java [default is Python]
120+ // lang - to render labels in a style appropriate for other languages,
121+ // and to display the proper language in langDisplayDiv
122+ // e.g., 'py2' for Python 2, 'py3' for Python 3, 'js' for JavaScript
123+ // [default is Python-style labels]
122124// debugMode - some extra debugging printouts
123125function ExecutionVisualizer ( domRootID , dat , params ) {
124126 this . curInputCode = dat . code . rtrim ( ) ; // kill trailing spaces
@@ -314,6 +316,7 @@ ExecutionVisualizer.prototype.render = function() {
314316
315317 var codeDisplayHTML =
316318 '<div id="codeDisplayDiv">\
319+ <div id="langDisplayDiv"></div>\
317320 <div id="pyCodeOutputDiv"/>\
318321 <div id="editCodeLinkDiv"><a id="editBtn">Edit code</a></div>\
319322 <div id="executionSlider"/>\
@@ -444,6 +447,18 @@ ExecutionVisualizer.prototype.render = function() {
444447 this . domRoot . find ( '#editBtn' ) . click ( function ( ) { return false ; } ) ; // DISABLE the link!
445448 }
446449
450+ if ( this . params . lang !== undefined ) {
451+ if ( this . params . lang === 'js' ) {
452+ this . domRoot . find ( '#langDisplayDiv' ) . html ( 'JavaScript (experimental)' ) ;
453+ } else if ( this . params . lang === 'py2' ) {
454+ this . domRoot . find ( '#langDisplayDiv' ) . html ( 'Python 2.7' ) ;
455+ } else if ( this . params . lang === 'py3' ) {
456+ this . domRoot . find ( '#langDisplayDiv' ) . html ( 'Python 3.3' ) ;
457+ } else {
458+ this . domRoot . find ( '#langDisplayDiv' ) . hide ( ) ;
459+ }
460+ }
461+
447462 if ( this . params . allowEditAnnotations !== undefined ) {
448463 this . allowEditAnnotations = this . params . allowEditAnnotations ;
449464 }
0 commit comments