OT Adam D Ruppe's web stuff

Adam D. Ruppe destructionator at gmail.com
Thu Feb 9 19:32:04 PST 2012


On Tuesday, 7 February 2012 at 20:00:26 UTC, Adam D. Ruppe wrote:
> I'm taking this to an extreme with this:
>
> http://arsdnet.net:8080/


hehehe, I played with this a little bit more tonight.

http://arsdnet.net/dcode/sse/

needs the bleeding edge dom.d from my github.
https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff

Here's the code, not very long.
http://arsdnet.net/dcode/sse/test.d

The best part is this:

  document.mainBody.addEventListener("click", (Element thislol, 
Event event) {
    event.target.style.color = "red";
    event.target.appendText(" clicked! ");
    event.preventDefault();
  });


A html onclick handler written in D!



Now, like I said before, probably not usable for real work. What
this does is for each user session, it creates a server side DOM
object.

Using observers on the DOM, it listens for changes and forwards 
them
to Javascript. You use the D api to change your document, and it
sends them down. I've only implemented a couple mutation events,
but they go a long way - appendChild and setAttribute - as they
are the building blocks for many of the functions.

On the client side, the javascript listens for events and forwards
them to D.

To sync the elements on both sides, I added a special feature
to dom.d to put an attribute there that is usable on both sides.
The Makefile in there shows the -version needed to enable it.


Since it is a server side document btw, you can refresh the 
browser
and keep the same document. It could quite plausible gracefully 
degrade!



But, yeah, lots of fun. D rox.


More information about the Digitalmars-d mailing list