Skip to content

Commit 943cd6e

Browse files
committed
bah
1 parent b97068b commit 943cd6e

3 files changed

Lines changed: 22 additions & 16 deletions

File tree

‎v4-cokapi/static/index.html‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@
7474
<div id="codeInputWarnings">Write
7575

7676
<select id="pythonVersionSelector">
77+
<option value="js">JavaScript</option>
7778
<option value="2">Python 2.7</option>
7879
<option value="3">Python 3.4</option>
79-
<option value="js">JavaScript</option>
8080
</select>
8181

8282
code here or <a href="#" id="firstExampleDupLink">load an example</a>:</div>
@@ -91,7 +91,7 @@
9191
<button id="executeBtn" class="bigBtn" type="button">Visualize Execution</button>
9292
</p>
9393

94-
<!--
94+
<div id="optionsPane">
9595

9696
<p style="margin-top: 20px; line-height: 200%;">
9797
Options:
@@ -118,7 +118,7 @@
118118
</select>
119119
</p>
120120

121-
-->
121+
</div>
122122

123123
<p style="margin-top: 25px; font-weight: bold;">Examples to visualize</p>
124124

‎v4-cokapi/static/js/cokapi.js‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ function executeCode(forceStartingInstr, forceRawInputLst) {
6969
py_crazy_mode: ($('#pythonVersionSelector').val() == '2crazy'),
7070
origin: originFrontendJsFile};
7171

72-
var surveyObj = getSurveyObject();
73-
if (surveyObj) {
74-
backendOptionsObj.survey = surveyObj;
75-
}
76-
7772
var startingInstruction = forceStartingInstr ? forceStartingInstr : 0;
7873

7974
var frontendOptionsObj = {startingInstruction: startingInstruction,
@@ -107,6 +102,7 @@ function executeCode(forceStartingInstr, forceRawInputLst) {
107102

108103

109104
$(document).ready(function() {
105+
$("#optionsPane").hide();
110106

111107
// canned examples
112108

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

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2828

2929
// include this file BEFORE any OPT frontend file
3030

31-
var python2_backend_script = 'web_exec_py2.py';
32-
var python3_backend_script = 'web_exec_py3.py';
33-
3431
var isExecutingCode = false; // nasty, nasty global
3532

3633
var appMode = 'edit'; // 'edit' or 'display'. also support
@@ -58,7 +55,6 @@ function initDeltaObj() {
5855
function initAceEditor(height) {
5956
pyInputAceEditor = ace.edit('codeInputPane');
6057
var s = pyInputAceEditor.getSession();
61-
s.setMode("ace/mode/python");
6258
// tab -> 4 spaces
6359
s.setTabSize(4);
6460
s.setUseSoftTabs(true);
@@ -75,6 +71,22 @@ function initAceEditor(height) {
7571
pyInputAceEditor.on('change', function(e) {
7672
$.doTimeout('pyInputAceEditorChange', 1000, snapshotCodeDiff); // debounce
7773
});
74+
75+
// don't do real-time syntax checks:
76+
// https://github.com/ajaxorg/ace/wiki/Syntax-validation
77+
s.setOption("useWorker", false);
78+
79+
setAceMode();
80+
}
81+
82+
function setAceMode() {
83+
var mod = 'python';
84+
if ($('#pythonVersionSelector').val() === 'js') {
85+
mod = 'javascript';
86+
}
87+
assert(mod === 'python' || mod === 'javascript');
88+
var s = pyInputAceEditor.getSession();
89+
s.setMode("ace/mode/" + mod);
7890
}
7991

8092
function snapshotCodeDiff() {
@@ -301,9 +313,7 @@ function genericOptFrontendReady() {
301313
$("#executeBtn").attr('disabled', false);
302314
$("#executeBtn").click(executeCodeFromScratch);
303315

304-
// for Versions 1 and 2, initialize here. But for version 3+, dynamically
305-
// generate a survey whenever the user successfully executes a piece of code
306-
//initializeDisplayModeSurvey();
316+
$('#pythonVersionSelector').change(setAceMode); // update syntax highlighting mode
307317
}
308318

309319

@@ -532,7 +542,7 @@ function updateAppDisplay(newAppMode) {
532542
function executeCodeFromScratch() {
533543
// don't execute empty string:
534544
if ($.trim(pyInputGetValue()) == '') {
535-
setFronendError(["Type in some Python code to visualize."]);
545+
setFronendError(["Type in some code to visualize."]);
536546
return;
537547
}
538548

0 commit comments

Comments
 (0)