This commit is contained in:
Paul Tagliamonte 2012-12-26 23:08:09 -05:00
parent 4ae596c0f7
commit 4433592b5b
3 changed files with 74 additions and 53 deletions

View File

@ -12,6 +12,11 @@ def index():
return render_template('index.html') return render_template('index.html')
@app.route('/popup')
def popup():
return render_template('popover.html')
@app.route('/translate', methods=['POST']) @app.route('/translate', methods=['POST'])
def translate(): def translate():
lines = request.form['code'] lines = request.form['code']

View File

@ -2,64 +2,21 @@
<html> <html>
<head> <head>
<title>{% block title %}{% endblock %} | hy</title> <title>{% block title %}{% endblock %} | hy</title>
<link rel="stylesheet" href = "{{ url_for('static', filename='css/debuild.css') }}" ></link> <link rel = "stylesheet" href = "{{ url_for('static', filename='css/debuild.css') }}" ></link>
<script src = '{{ url_for('static', filename='jquery.min.js') }}' ></script> <script src = '{{ url_for('static', filename='jquery.min.js') }}' ></script>
<script type="text/javascript"> <script type="text/javascript">
function reload() {
var input = $("#repl-input").val();
console.log("Input: " + input);
$('#repl-output').load(
'/translate',
{"code": input}
);
}
$(document).ready(function() { $(document).ready(function() {
$("#repl-input").keyup(function(e) { $("#try").click(function() {
reload(); $('#popshim').load(
'/popup'
);
return false;
}); });
reload();
}); });
</script> </script>
</head> </head>
<body> <body>
<div class = 'popover' > <div id = 'popshim' ></div>
<div class = 'focus' >
<div class = 'repl' >
<textarea id = 'repl-input' class = 'repl-left repl-pane' >
(import "os")
(print (os.path.abspath "."))
; something like /home/tag
(defn square [x]
(* x x))
(defn factorial (n)
(if (&lt;= n 1)
1
(* n (factorial (- n 1)))))
(defn fib (n)
(if (&lt; n 2)
n
(+ (fib (- n 1)) (fib (- n 2)))))
(print (fib 2))
; 1
(print "4! =" (factorial 4))
; 4! = 24
</textarea>
<pre id = 'repl-output' class = 'repl-right repl-pane' ></pre>
</div>
</div>
</div>
<div class = 'headblock' > <div class = 'headblock' >
<div class = 'spacer' ></div> <div class = 'spacer' ></div>
</div> </div>
@ -67,7 +24,7 @@ $(document).ready(function() {
<div class = 'banner' > <div class = 'banner' >
<ul> <ul>
<li><a href = '#' >Home</a></li> <li><a href = '#' >Home</a></li>
<li><a href = '#' >Try it</a></li> <li><a id = 'try' href = '#' >Try it</a></li>
<li><a href = '#' >Source</a></li> <li><a href = '#' >Source</a></li>
</ul> </ul>
</div> </div>

View File

@ -0,0 +1,59 @@
<script type="text/javascript">
function reload() {
var input = $("#repl-input").val();
console.log("Input: " + input);
$('#repl-output').load(
'/translate',
{"code": input}
);
}
$(document).ready(function() {
$("#repl-input").keyup(function(e) {
reload();
});
reload();
$(document).keyup(function(e) {
if (e.keyCode == 27) {
$("#popshim").html("");
}
});
});
</script>
<div class = 'popover' >
<div class = 'focus' >
<div class = 'repl' >
<textarea id = 'repl-input' class = 'repl-left repl-pane' >
(import "os")
(print (os.path.abspath "."))
; something like /home/tag
(defn square [x]
(* x x))
(defn factorial (n)
(if (&lt;= n 1)
1
(* n (factorial (- n 1)))))
(defn fib (n)
(if (&lt; n 2)
n
(+ (fib (- n 1)) (fib (- n 2)))))
(print (fib 2))
; 1
(print "4! =" (factorial 4))
; 4! = 24
</textarea>
<pre id = 'repl-output' class = 'repl-right repl-pane' ></pre>
</div>
</div>
</div>