diff --git a/ide.py b/ide.py
index b6dc074..7517dbc 100644
--- a/ide.py
+++ b/ide.py
@@ -30,6 +30,7 @@ def index():
#Run code
code = request.form['code']
input = request.form['input'].replace('\r\n', '\n')
+ if input is None: input = ""
print('Got code:', code, 'input:', input)
print('Running O code...')
p = Popen(['./oide', '-e', code], stdout=PIPE, stderr=PIPE, stdin=PIPE, universal_newlines=True)
@@ -45,14 +46,15 @@ def index():
return render_template('primary.html')
@app.route('/link/')
-@app.route('/link/')
-def link(link='code="Error in linking code"o&input='):
+@app.route('/link//')
+@app.route('/link//')
+def link(code="IkVycm9yJTIwbGlua2luZyUyMGNvZGUibw==", input=""):
url_for('static', filename='logo.ico')
- print('Link:', link)
- return render_template('link.html', link=link)
+ print('Link:', code, input)
+ return render_template('link.html', code=code, input=input)
if __name__ == '__main__':
print('Compiling O...')
compileO()
print('Starting server...')
- app.run(debug='-d' in sys.argv[1:])
\ No newline at end of file
+ app.run(port=80, debug='-d' in sys.argv[1:])
\ No newline at end of file
diff --git a/static/o.js b/static/o.js
index 5132ae9..f920bf5 100644
--- a/static/o.js
+++ b/static/o.js
@@ -140,27 +140,13 @@ function updateUtils() {
updateUtils();
$(document).ready(function() {
- $('#code').on('keydown', function() {
- var code = $("#code").val();
- var key = event.keyCode || event.charCode;
- var c = String.fromCharCode(event.which);
- var pos = $("#code").getCursorPosition()-1;
- if( key == 8 || key == 46 ){ //delete text
- console.log("Delete: " + c + " " + pos + " :: " + event.which);
- if(c == "(" && code.charAt(pos+1) == ")") code.replaceAt(pos+1, "");
- if(c == "{" && code.charAt(pos+1) == "}") code.replaceAt(pos+1, "");
- } else {
- //if()
- }
- $("#code").val(code);
- });
$("#permalink").click(function() {
/*var code = $.param({
code : $('#code').val().replace(" ", "%20"),
input : $('#input').val()
});*/
- var code = "code=" + $('#code').val().replace(/ /g, "%20")
- + "&input=" + $('#input').val().replace(/ /g, "%20");
+ // var code = "code=" + window.btoa($('#code').val().replace(/ /g, "%20")) + "&input=" + window.btoa($('#input').val().replace(/ /g, "%20"));
+ var code = window.btoa($('#code').val().replace(/ /g, "%20")) + "/" + window.btoa($('#input').val().replace(/ /g, "%20"));
prompt("Permalink:", "http://" + window.location.hostname + "/link/" + code);
window.location.pathname = "/link/" + code;
});
diff --git a/templates/link.html b/templates/link.html
index 5ed3da7..23450ba 100644
--- a/templates/link.html
+++ b/templates/link.html
@@ -7,9 +7,8 @@