Skip to content

Commit 0cef7a9

Browse files
committed
better encapsulation of complete app state
1 parent 96cac25 commit 0cef7a9

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

‎v3/js/opt-frontend-common.js‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2626
2727
*/
2828

29+
// include this file BEFORE any OPT frontend files
30+
2931

3032
// backend scripts to execute (Python 2 and 3 variants, if available)
3133
// make two copies of ../web_exec.py and give them the following names,
@@ -73,7 +75,7 @@ function setCodeMirrorVal(dat) {
7375

7476

7577
var myVisualizer = null; // singleton ExecutionVisualizer instance
76-
var myVisualizerState = null; // contains the parameters necessary to generate myVisualizer
78+
var visualizedAppState = null; // parameters necessary to generate myVisualizer
7779

7880

7981
var rawInputLst = []; // a list of strings inputted by the user in response to raw_input or mouse_input events
@@ -189,7 +191,7 @@ function executePythonCode(pythonSourceCode,
189191
return;
190192
}
191193

192-
myVisualizerState = null; // clear this before attempting to execute
194+
visualizedAppState = null; // clear this before attempting to execute
193195

194196
$.get(backendScript,
195197
{user_script : pythonSourceCode,
@@ -249,11 +251,8 @@ function executePythonCode(pythonSourceCode,
249251

250252
// set some nasty global state that represents the current
251253
// code that's being visualized at the moment
252-
myVisualizerState = {visualizedCode: pythonSourceCode,
253-
backendScript: backendScript,
254-
backendOptionsObj: backendOptionsObj,
255-
frontendOptionsObj: frontendOptionsObj};
256-
// TODO: insert UUID
254+
visualizedAppState = getAppState(); // TODO: add UUID
255+
visualizedAppState.visualizedAppState = null; // prevent chaining
257256

258257
handleSuccessFunc();
259258
}

‎v3/js/opt-frontend.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ function getAppState() {
9999
textReferences: $('#textualMemoryLabelsSelector').val(),
100100
showOnlyOutputs: $('#showOnlyOutputsSelector').val(),
101101
py: $('#pythonVersionSelector').val(),
102-
myVisualizerState: myVisualizerState};
102+
// the app state that led to the CURRENT visualization
103+
visualizedAppState: visualizedAppState};
103104
}
104105

105106

0 commit comments

Comments
 (0)