| « Protocol Buffers | Python Onsen » |
Javascript Interpreter
I wanted a convenient way to test out some javascript by running it in a browser and being able to play with it via an interpreter like python has. As it turns out the almighty Bob created a nice interpreter for playing around with Mochikit but I wanted something a bit more generic that would allow me to import any kind of javascript and play with it. It turns out this is really easy so I added one simple function to the interpreter.js file called importjs.
You just call importjs like so
| importjs(url) |
This will import a javascript file from the url given. It's a very simple function that just adds a script tag to the document wrapped in div tag. You can load up the interpreter and type "importjs" to see the code.
| function (jssource) { | |
| importdiv = DIV(); | |
| importdiv.innerHTML = "Importing " + jssource + " <script type='text/javascript' src='" + jssource + "'></script>"; | |
| writeln(importdiv); | |
| } |
Check out the slightly modified interpreter here
2 comments
It's pretty fun to play around with a terminal though.