Jus is an experimental webserver written in Javascript. It can be run as a Firefox extension or as a standalone program. Jus provides mechanisms for transparently calling server-side functions from client-side code.
Using one language for client and server code makes life simpler. In the same source file, you can define Javascript code segments that are executed on the server, on the client, or on both.
Example:
<script runat="server">
// this code is evaluated on the server and removed
// before the page is sent out.
function foo(a) {
// do stuff
}
Jus.proxies = [ foo ]; // define foo as callable from client
</script>
<script>
// this code runs on the client only.
// call proxy function via XmlHTTPRequest
var result = foo("bar");
</script>
Jus has been inspired by the POW Firefox extension by David Kellog and by the Jaxer webserver by Aptana, Inc.
When a request for an HTML page comes in, the file's DOM structure is parsed.
All <script> tags with the attribute runat set to "server" or "both" are evaluated in a sandbox.
The DOM structure is serialized and sent to the client, without the server-side code of course.
The client-side code can transparently call functions on the server, if these functions have been defined as “proxy functions”.
Warning: this is experimental software. It might eat your children. Also, it only has been tested on Linux with Firefox 3 and XULRunner 1.8.1.11. On Windows, Firefox 2.0.0.11 hangs when doing POST requests (although with IE 7 as the client, it works...argh!).
hg clone http://stephan.walter.name/jus/repoAfter installing, go to http://localhost:6673/index.html to see an example script. Caveats for writing your own scripts:
<html xmlns="...">.
See the example index.html.
On the other hand, a DOCTYPE definition is not necessary.