Richard Suchenwirth 2007-11-18 - For experimenting with Tcl in Javascript, I hacked up the following HTML file which, loaded into a browser, allows some interactive experimenting. Make sure the files jquery-1.2.1.js and tcl.js are in the same directory.
You get a kind of entry widget on top, in which you can type Tcl commands. On <Return>, they are evaluated by the browser's Javascript engine, and both the command and its result are displayed further down the window. Use <Down> to clear the entry.
Known bug: some commands are not echoed, even though their result is. I'm not sure why, seems like it has to do with quotes...
<html><head>
<script language="javascript" src="jquery-1.2.1.js" type="text/javascript"></script>
<script language="javascript" src="tcl.js" type="text/javascript"></script>
<script language="javascript">
var i = new TclInterp();
function go(event,value) {
if(window.event) { // Windows IE
keynum = event.keyCode
} else if(event.which) {keynum = event.which} // Netscape/Firefox/Opera
if(keynum==40) document.f.e.value = "";
if(keynum != 13) return true;
i.eval('puts {% '+ value.replace('"','\\"') +'}');
var res = i.eval(value);
try {
i.eval('puts {'+ res +'}');
} catch(e) {i.eval('puts {' + e + '}');}
return false;
}
</script>
</head><body>
<form name="f">
<input type="text" name="e" size="80" onKeyDown="return go(event,document.f.e.value)"/>
</form>
</body></html>