Skip to content

Commit 3c53c33

Browse files
committed
bam
1 parent a0dc7a0 commit 3c53c33

3 files changed

Lines changed: 50 additions & 27 deletions

File tree

‎v3/bottle_server.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
def web_exec(name):
2525
return 'OK'
2626

27-
@route('/web_exec_LIVE_<name:re:.+>.py')
28-
def web_exec_live(name):
27+
@route('/LIVE_exec_<name:re:.+>.py')
28+
def live_exec(name):
2929
return 'OK'
3030

3131

‎v3/js/opt-live.js‎

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3939
File "<string>", line 1
4040
x~=1
4141
^
42+
- for slower frontends, add an unobtrusive "running ..." indicator
43+
4244
- make Ace editor resizable width-wise using jQuery resizable
4345
(stackoverflow has some tips for how to do that)
4446
@@ -47,7 +49,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4749
4850
- make sure server logging works properly, esp. session and user IDs,
4951
and slider interactions
50-
- have separate web_exec_live executor scripts for logging live mode
5152
5253
- add "Generate permanent link" button, but no need for iframe embed btn
5354
@@ -81,20 +82,20 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8182
// -rwxr-xr-x 1 pgbovine pgbovine 2.5K Jul 5 22:46 web_exec_py2.py*
8283
// (most notably, only the owner of the file should have write
8384
// permissions)
84-
//var python2_backend_script = 'web_exec_LIVE_py2.py';
85-
//var python3_backend_script = 'web_exec_LIVE_py3.py';
85+
//var python2_backend_script = 'LIVE_exec_py2.py';
86+
//var python3_backend_script = 'LIVE_exec_py3.py';
8687

8788
// uncomment below if you're running on Google App Engine using the built-in app.yaml
8889
var python2_backend_script = 'exec';
8990
var python3_backend_script = 'exec';
9091

9192
// empty dummy just to do logging on the Apache's server
92-
var js_backend_script = 'web_exec_LIVE_js.py';
93-
var ts_backend_script = 'web_exec_LIVE_ts.py';
94-
var java_backend_script = 'web_exec_LIVE_java.py';
95-
var ruby_backend_script = 'web_exec_LIVE_ruby.py';
96-
var c_backend_script = 'web_exec_LIVE_c.py';
97-
var cpp_backend_script = 'web_exec_LIVE_cpp.py';
93+
var js_backend_script = 'LIVE_exec_js.py';
94+
var ts_backend_script = 'LIVE_exec_ts.py';
95+
var java_backend_script = 'LIVE_exec_java.py';
96+
var ruby_backend_script = 'LIVE_exec_ruby.py';
97+
var c_backend_script = 'LIVE_exec_c.py';
98+
var cpp_backend_script = 'LIVE_exec_cpp.py';
9899

99100

100101
var originFrontendJsFile = 'opt-live.js';
@@ -265,10 +266,6 @@ function initAceEditor(height) {
265266
pyInputAceEditor = ace.edit('codeInputPane');
266267

267268
var s = pyInputAceEditor.getSession();
268-
s.setMode("ace/mode/python");
269-
// tab -> 4 spaces
270-
s.setTabSize(4);
271-
s.setUseSoftTabs(true);
272269

273270
// disable extraneous indicators:
274271
s.setFoldStyle('manual'); // no code folding indicators
@@ -389,13 +386,42 @@ function optliveExecuteCodeAndCreateViz(codeToExec,
389386
assert(false);
390387
}
391388

392-
$.get(backendScript,
393-
{user_script : codeToExec,
394-
raw_input_json: rawInputLst.length > 0 ? JSON.stringify(rawInputLst) : '',
395-
options_json: JSON.stringify(backendOptionsObj),
396-
user_uuid: supports_html5_storage() ? localStorage.getItem('opt_uuid') : undefined,
397-
session_uuid: sessionUUID},
398-
execCallback, "json");
389+
if (backendScript === js_backend_script ||
390+
backendScript === ts_backend_script ||
391+
backendScript === java_backend_script ||
392+
backendScript === ruby_backend_script ||
393+
backendScript === c_backend_script ||
394+
backendScript === cpp_backend_script) {
395+
// hack! should just be a dummy script for logging only
396+
$.get(backendScript,
397+
{user_script : codeToExec,
398+
options_json: JSON.stringify(backendOptionsObj),
399+
user_uuid: supports_html5_storage() ? localStorage.getItem('opt_uuid') : undefined,
400+
session_uuid: sessionUUID},
401+
function(dat) {} /* don't do anything since this is a dummy call */, "text");
402+
403+
// the REAL call uses JSONP
404+
// http://learn.jquery.com/ajax/working-with-jsonp/
405+
assert(jsonp_endpoint);
406+
$.ajax({
407+
url: jsonp_endpoint,
408+
// The name of the callback parameter, as specified by the YQL service
409+
jsonp: "callback",
410+
dataType: "jsonp",
411+
data: {user_script : codeToExec,
412+
options_json: JSON.stringify(backendOptionsObj)},
413+
success: execCallback,
414+
});
415+
} else {
416+
// Python 2 or 3
417+
$.get(backendScript,
418+
{user_script : codeToExec,
419+
raw_input_json: rawInputLst.length > 0 ? JSON.stringify(rawInputLst) : '',
420+
options_json: JSON.stringify(backendOptionsObj),
421+
user_uuid: supports_html5_storage() ? localStorage.getItem('opt_uuid') : undefined,
422+
session_uuid: sessionUUID},
423+
execCallback, "json");
424+
}
399425
}
400426

401427
function executeCode(forceStartingInstr, forceRawInputLst) {
@@ -430,9 +456,11 @@ $(document).ready(function() {
430456
genericOptFrontendReady();
431457

432458
$('#pythonVersionSelector').change(function() {
459+
setAceMode();
433460
// force a recompile on a toggle switch
434461
executeCode();
435462
});
436463

464+
setAceMode(); // set syntax highlighting at the end
437465
$("#pyOutputPane").show();
438466
});

‎v3/opt-live.html‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,7 @@
6767
<select id="pythonVersionSelector">
6868
<option value="2">Python 2.7</option>
6969
<option value="3">Python 3.3</option>
70-
<option value="java">Java 7</option>
7170
<option value="js">JavaScript ES6</option>
72-
<option value="ts">TypeScript 1.4</option>
73-
<option value="ruby">Ruby 2.2</option>
74-
<option value="c">C (gcc 4.8, C11) EXPERIMENTAL</option>
75-
<option value="cpp">C++ (gcc 4.8, C++11) EXPERIMENTAL</option>
7671
</select>
7772
</div>
7873

0 commit comments

Comments
 (0)