Skip to content

Commit 4d3df2c

Browse files
committed
started OptFrontend class
1 parent 88eed7f commit 4d3df2c

2 files changed

Lines changed: 60 additions & 11 deletions

File tree

‎v5-unity/js/opt-frontend-common.ts‎

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,66 @@ const CODE_SNAPSHOT_DEBOUNCE_MS = 1000;
7070
const SUBMIT_UPDATE_HISTORY_INTERVAL_MS = 1000 * 60;
7171

7272

73+
class OptFrontend {
74+
sessionUUID: string = generateUUID(); // remains constant throughout one page load ("session")
75+
76+
myVisualizer; // singleton ExecutionVisualizer instance from pytutor.ts
77+
78+
// 'edit' or 'display'. also support 'visualize' for backward
79+
// compatibility (same as 'display')
80+
appMode: string = 'edit';
81+
82+
// inputted by user for raw_input / mouse_input events
83+
rawInputLst: string[] = [];
84+
85+
isExecutingCode: boolean = false;
86+
87+
originFrontendJsFile: string;
88+
appStateAugmenter: any; // super hacky! fixme
89+
loadTestCases: any; // super hacky! fixme
90+
91+
executeCode: (forceStartingInstr: number, forceRawInputLst: string[]) => void;
92+
93+
pyInputAceEditor; // Ace editor object that contains the input code
94+
95+
dmp = new diff_match_patch();
96+
curCode = ''; // TODO: do we need this?
97+
deltaObj : {start: string, deltas: any[], v: number, startTime: number, executeTime?: number} = undefined;
98+
99+
num414Tries = 0;
100+
101+
constructor(originFrontendJsFile: string,
102+
executeCode: (forceStartingInstr: number, forceRawInputLst: string[]) => void,
103+
params=null) {
104+
this.originFrontendJsFile = originFrontendJsFile;
105+
this.executeCode = executeCode;
106+
107+
// optional params -- TODO: handle later
108+
/*
109+
if (params.TogetherjsReadyHandler) {
110+
TogetherjsReadyHandler = params.TogetherjsReadyHandler;
111+
}
112+
if (params.TogetherjsCloseHandler) {
113+
TogetherjsCloseHandler = params.TogetherjsCloseHandler;
114+
}
115+
if (params.startSharedSession) {
116+
startSharedSession = params.startSharedSession;
117+
}
118+
if (params.initAceEditor) {
119+
initAceEditor = params.initAceEditor;
120+
}
121+
if (params.appStateAugmenter) {
122+
appStateAugmenter = params.appStateAugmenter;
123+
}
124+
if (params.loadTestCases) {
125+
loadTestCases = params.loadTestCases;
126+
}
127+
*/
128+
}
129+
130+
} // END class OptFrontend
131+
132+
73133
// TODO: encapsulate tons of globals into a class of some sort:
74134

75135
var myVisualizer = null; // singleton ExecutionVisualizer instance
@@ -176,7 +236,6 @@ function supports_html5_storage() {
176236
}
177237
}
178238

179-
180239
function initDeltaObj() {
181240
// make sure the editor already exists
182241
// (editor doesn't exist when you're, say, doing an iframe embed)

‎v5-unity/visualize.html‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,6 @@
112112
<option value="false">draw pointers as arrows [default]</option>
113113
<option value="true">use text labels for pointers</option>
114114
</select>
115-
116-
<!-- hide these for now -->
117-
<select id="drawParentPointerSelector" style="display: none;">
118-
<option value="false">hide environment parent pointers (default)</option>
119-
<!--<option value="true">show environment parent pointers</option>-->
120-
</select>
121-
<select id="showOnlyOutputsSelector" style="display: none;">
122-
<option value="false">show everything (default)</option>
123-
<!--<option value="true">show only outputs</option>-->
124-
</select>
125115
</div>
126116

127117

0 commit comments

Comments
 (0)