diff options
Diffstat (limited to 'clojurescript/test.html')
-rw-r--r-- | clojurescript/test.html | 57 |
1 files changed, 46 insertions, 11 deletions
diff --git a/clojurescript/test.html b/clojurescript/test.html index bc3c2a31..92cd1f32 100644 --- a/clojurescript/test.html +++ b/clojurescript/test.html @@ -1,7 +1,12 @@ <html> <body> - <textarea rows="24" cols="80" id="ta"></textarea> - <form onsubmit="run(); return false" id="f"> + <textarea rows="24" cols="80" id="ta"></textarea><br /> + <span style="font-family: monospace">user=></span> + <textarea id="text" rows="6" cols="80" + style="vertical-align: top"></textarea> + <div id="status"></div> + <!-- + <form onsubmit="jsrepl.runtest(); return false"> <select id="t"> <option>t01.js</option> <option>t02.js</option> @@ -12,16 +17,46 @@ </select> <input type="submit" value="Run test" /> </form> + --> <script type="text/javascript"> - var ta = document.getElementById( 'ta' ); - function print( x ) { ta.value += x + "\n"; } - var f = document.getElementById( 'f' ); - var t = document.getElementById( 't' ); - function run() { - var s = document.createElement('script'); - s.src = t.value; - document.body.appendChild( s ); - } + jsrepl = { + ta: document.getElementById( 'ta' ), + t: document.getElementById( 't' ), + text: document.getElementById( 'text' ), + status: document.getElementById( 'status' ), + runtest: function() { + var s = document.createElement('script'); + s.src = jsrepl.t.value; + document.body.appendChild( s ); + }, + posttext: function() { + print( "user=> " + jsrepl.text.value.replace("\n","\n ")); + jsrepl.text.value = ""; + }, + state: function(s,m) { + jsrepl.status.innerHTML = s; + switch( s ) { + case 'error': + jsrepl.posttext(); + print( m ); + break; + case 'compiled': + jsrepl.posttext(); + break; + } + jsrepl.ta.scrollTop = jsrepl.ta.scrollHeight; + } + }; + jsrepl.text.onkeypress = function(e) { + e = e || event; + if( e.keyCode == 13 ) { + var s = document.createElement('script'); + s.src = "http://localhost:8081/" + + escape(jsrepl.text.value).replace(/\+/,'%2b'); + document.body.appendChild( s ); + } + }; + function print( x ) { jsrepl.ta.value += x + "\n"; } </script> <script type="text/javascript" src="clj.js"></script> <script type="text/javascript" src="boot.js"></script> |