Skip to content

Commit 468b446

Browse files
committed
added codeDivWidth and codeDivHeight as adjustable options
1 parent 80c3340 commit 468b446

3 files changed

Lines changed: 20 additions & 7 deletions

File tree

v3/js/iframe-embed.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,18 @@ $(document).ready(function() {
5353
var cumModeBool = (queryStrOptions.cumulativeState == 'true');
5454

5555
var codeDivWidth = undefined;
56-
var cdv = $.bbq.getState('codeDivWidth');
57-
if (cdv) {
58-
codeDivWidth = Number(cdv);
56+
var cdw = $.bbq.getState('codeDivWidth');
57+
if (cdw) {
58+
codeDivWidth = Number(cdw);
5959
}
6060

61+
var codeDivHeight = undefined;
62+
var cdh = $.bbq.getState('codeDivHeight');
63+
if (cdh) {
64+
codeDivHeight = Number(cdh);
65+
}
66+
67+
6168
var startingInstruction = queryStrOptions.preseededCurInstr;
6269
if (!startingInstruction) {
6370
startingInstruction = 0;
@@ -119,6 +126,7 @@ $(document).ready(function() {
119126
pyCrazyMode: (pyState == '2crazy'),
120127
highlightLines: typeof $.bbq.getState("highlightLines") !== "undefined",
121128
codeDivWidth: codeDivWidth,
129+
codeDivHeight: codeDivHeight,
122130
}
123131

124132
function executeCode(forceStartingInstr) {

v3/js/opt-frontend.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,8 @@ $(document).ready(function() {
553553
showOnlyOutputs: $('#showOnlyOutputsSelector').val(),
554554
py: $('#pythonVersionSelector').val(),
555555
curInstr: myVisualizer.curInstr,
556+
codeDivWidth: myVisualizer.DEFAULT_EMBEDDED_CODE_DIV_WIDTH,
557+
codeDivHeight: myVisualizer.DEFAULT_EMBEDDED_CODE_DIV_HEIGHT,
556558
};
557559

558560
var embedUrlStr = $.param.fragment(domain + "iframe-embed.html", myArgs, 2 /* clobber all */);

v3/js/pytutor.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ var curVisualizerID = 1; // global to uniquely identify each ExecutionVisualizer
8282
// codeDivWidth - maximum width of #pyCodeOutputDiv (in integer pixels)
8383
// editCodeBaseURL - the base URL to visit when the user clicks 'Edit code' (if null, then 'Edit code' link hidden)
8484
// allowEditAnnotations - allow user to edit per-step annotations (default: false)
85-
// embeddedMode - shortcut for hideOutput=true, allowEditAnnotations=false
86-
// codeDivWidth=350, codeDivHeight=400
85+
// embeddedMode - shortcut for hideOutput=true, allowEditAnnotations=false,
86+
// codeDivWidth=this.DEFAULT_EMBEDDED_CODE_DIV_WIDTH,
87+
// codeDivHeight=this.DEFAULT_EMBEDDED_CODE_DIV_HEIGHT
8788
// disableHeapNesting - if true, then render all heap objects at the top level (i.e., no nested objects)
8889
// drawParentPointers - if true, then draw environment diagram parent pointers for all frames
8990
// WARNING: there are hard-to-debug MEMORY LEAKS associated with activating this option
@@ -109,6 +110,8 @@ function ExecutionVisualizer(domRootID, dat, params) {
109110
this.curInputCode = dat.code.rtrim(); // kill trailing spaces
110111
this.curTrace = dat.trace;
111112

113+
this.DEFAULT_EMBEDDED_CODE_DIV_WIDTH = 350;
114+
this.DEFAULT_EMBEDDED_CODE_DIV_HEIGHT = 400;
112115

113116
// optional filtering to remove redundancy ...
114117
// ok, we're gonna filter out all trace entries of 'call' events,
@@ -419,11 +422,11 @@ ExecutionVisualizer.prototype.render = function() {
419422

420423
// don't override if they've already been set!
421424
if (this.params.codeDivWidth === undefined) {
422-
this.params.codeDivWidth = 350;
425+
this.params.codeDivWidth = this.DEFAULT_EMBEDDED_CODE_DIV_WIDTH;
423426
}
424427

425428
if (this.params.codeDivHeight === undefined) {
426-
this.params.codeDivHeight = 400;
429+
this.params.codeDivHeight = this.DEFAULT_EMBEDDED_CODE_DIV_HEIGHT;
427430
}
428431

429432
this.allowEditAnnotations = false;

0 commit comments

Comments
 (0)