Skip to content

Commit 038efcf

Browse files
committed
more chuggin' along
1 parent 088550a commit 038efcf

2 files changed

Lines changed: 24 additions & 14 deletions

File tree

‎v4-cokapi/frontends/js/cokapi-frontend.js‎

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4747
var originFrontendJsFile = 'cokapi.js';
4848

4949
function executeCode(forceStartingInstr, forceRawInputLst) {
50+
var isJsMode = ($('#pythonVersionSelector').val() === 'js');
5051
if (forceRawInputLst !== undefined) {
5152
rawInputLst = forceRawInputLst; // UGLY global across modules, FIXME
5253
}
@@ -58,30 +59,31 @@ function executeCode(forceStartingInstr, forceRawInputLst) {
5859
else if ($('#pythonVersionSelector').val() === '3') {
5960
backend_script = '/exec_py3'
6061
}
61-
else if ($('#pythonVersionSelector').val() === 'js') {
62+
else if (isJsMode) {
6263
backend_script = '/exec_js';
6364
}
6465
else {
6566
alert("Invalid version selector");
6667
assert(false);
6768
}
6869

69-
var backendOptionsObj = {cumulative_mode: ($('#cumulativeModeSelector').val() == 'true'),
70-
heap_primitives: ($('#heapPrimitivesSelector').val() == 'true'),
71-
show_only_outputs: ($('#showOnlyOutputsSelector').val() == 'true'),
72-
py_crazy_mode: ($('#pythonVersionSelector').val() == '2crazy'),
70+
// for now, don't enable any custom options when rendering JS
71+
72+
var backendOptionsObj = {cumulative_mode: (isJsMode ? false : ($('#cumulativeModeSelector').val() == 'true')),
73+
heap_primitives: (isJsMode ? false : ($('#heapPrimitivesSelector').val() == 'true')),
74+
show_only_outputs: (isJsMode ? false : ($('#showOnlyOutputsSelector').val() == 'true')),
7375
origin: originFrontendJsFile};
7476

7577
var startingInstruction = forceStartingInstr ? forceStartingInstr : 0;
7678

7779
var frontendOptionsObj = {startingInstruction: startingInstruction,
7880
// tricky: selector 'true' and 'false' values are strings!
79-
disableHeapNesting: ($('#heapPrimitivesSelector').val() == 'true'),
80-
drawParentPointers: ($('#drawParentPointerSelector').val() == 'true'),
81-
textualMemoryLabels: ($('#textualMemoryLabelsSelector').val() == 'true'),
82-
showOnlyOutputs: ($('#showOnlyOutputsSelector').val() == 'true'),
81+
disableHeapNesting: (isJsMode ? false : ($('#heapPrimitivesSelector').val() == 'true')),
82+
drawParentPointers: (isJsMode ? false : ($('#drawParentPointerSelector').val() == 'true')),
83+
textualMemoryLabels: (isJsMode ? false : ($('#textualMemoryLabelsSelector').val() == 'true')),
84+
showOnlyOutputs: (isJsMode ? false : ($('#showOnlyOutputsSelector').val() == 'true')),
8385
executeCodeWithRawInputFunc: executeCodeWithRawInput,
84-
lang: ($('#pythonVersionSelector').val() === 'js') ? 'js' : undefined,
86+
lang: (isJsMode ? 'js' : undefined),
8587

8688
// always use the same visualizer ID for all
8789
// instantiated ExecutionVisualizer objects,
@@ -100,10 +102,17 @@ function executeCode(forceStartingInstr, forceRawInputLst) {
100102
optFinishSuccessfulExecution, handleUncaughtExceptionFunc);
101103
}
102104

105+
function initAceAndOptions() {
106+
if ($('#pythonVersionSelector').val() === 'js') {
107+
$('#optionsPane').hide();
108+
} else {
109+
$('#optionsPane').show();
110+
}
111+
setAceMode(); // update syntax highlighting mode
112+
}
113+
103114

104115
$(document).ready(function() {
105-
//$("#optionsPane").hide();
106-
107116
// canned examples
108117

109118
/*
@@ -124,4 +133,7 @@ $(document).ready(function() {
124133
*/
125134

126135
genericOptFrontendReady(); // initialize at the end
136+
137+
$('#pythonVersionSelector').change(initAceAndOptions);
138+
initAceAndOptions();
127139
});

‎v4-cokapi/frontends/js/opt-frontend-common.js‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,6 @@ function genericOptFrontendReady() {
313313
$("#embedLinkDiv").hide();
314314
$("#executeBtn").attr('disabled', false);
315315
$("#executeBtn").click(executeCodeFromScratch);
316-
317-
$('#pythonVersionSelector').change(setAceMode); // update syntax highlighting mode
318316
}
319317

320318

0 commit comments

Comments
 (0)