Tuesday, June 28, 2005

MS rolling out Ajax toolkit

Looks like Microsoft will be rolling out an Ajax-enabling toolkit called Atlas.

Microsoft's Atlas is a "Web client framework" designed to make the job of building AJAX-style applications simpler, said Charles Fitzgerald, the company's general manager for platform technologies.

"People who do (AJAX development) are rocket scientists," Fitzgerald said. "In some ways, this papers over the mess that is JavaScript development. It's easy-to-build 'spaghetti' code."

Atlas--which is a downloadable piece of JavaScript code--gives developers a more structured environment for building applications, providing time-saving services such as an object model and debugging, he said. It will work across any Web browser that supports AJAX technologies.

The "rocket science" quote is funny, 'cause one of the questions posed at the Ajax Summit I attended last month was along the lines of "is Ajax rocket science?" Answer: only if you want to build rockets.

Friday, June 24, 2005

Don't do these anymore

Six JavaScript features we do not need any longer. I still see plenty of instances of "javascript:" in modern JS code. My favorite is seeing it used in an event handler, like this:

<a href="#" onclick="JavaScript:doThis();">Do This!</a>

With capitalization, even. Hello?

Thursday, June 23, 2005

Spot The WTF: JavaScript edition

The Daily WTF has a doozy of a JavaScript challenge: the most jaw-dropping test for alphanumeric characters, evar. Wow.

Wednesday, June 22, 2005

I made some science

Take the MIT Weblog Survey

Thursday, June 16, 2005

TiddlyWiki hack: exporting tiddler HTML

I was trying to figure out how to export rendered HTML from a TiddlyWiki tiddler so I could paste it into an MS Word document. Since there doesn't seem to be a supported way to do this in TiddlyWiki, I found two methods that seem to work:

  • If you're using Firefox, just highlight the tiddler text, then right-click your selection and choose "View Selection Source." I dunno why this works, but it does.
  • Otherwise, I threw together the Ugliest TiddlyWiki Hack Ever!

I may be reinventing the wheel here, but whatever.

Save a backup of your TiddlyWiki file, then open it in a text editor and search for the createTiddlerToolbar function. In that function, look for the section that adds buttons to the non-editor toolbar and add the following lines to that block:

insertSpacer(theToolbar);
createTiddlyButton(
  theToolbar,
  "html",
  "show/hide HTML of this tiddler",
  onClickToolbarShowHTML
);

Now add the following function somewhere in the page, preferably near where the other button handlers live:

function onClickToolbarShowHTML(e)
{
  hideMessage();
  if(this.parentNode.id) {
    var viewer = 
      document.getElementById("viewer" + this.parentNode.id.substr(7));
    if (!viewer.isHTMLView) {
      viewer.innerHTML = viewer.innerHTML.replace(/\</g,"&lt;");
      viewer.isHTMLView = true;
    } else {
      viewer.isHTMLView = false;
      displayTiddler(
        null,this.parentNode.id.substr(7),1,null,null,false
      );
    }
  }
}

This is admittedly a gross hack: we're just grabbing the HTML of the viewer tiddler and replacing all the left angle brackets with HTML entities, then stuffing the HTML back into the tiddler. Since calling displayTiddler refreshes the tiddler content, we can use that to undo the damage without manipulating the string again.

This has been pretty useful to me, since I love the simple TiddlyWiki table markup for doing spec work, but usually have to cut and paste it into a report written in HTML or Word. Now, I just hit that "html" tiddler button, copy/paste the HTML, then toggle it back.

Saturday, June 11, 2005

Proposed event sourcing in HTML 5

From the Ajaxian blog, a rundown of proposed HTML 5 features from WHAT-WG. They also link to Hixie's slides, which don't work in Firefox. Feh.

There's a lot of interesting stuff that walks the line between semantic vs. presentational, etc. My favorite, though, is this the proposal for event sources:

<event-source src="/some/path" onevent="process(event)"/>

This is exciting to me because mod-pubsub comes extremely close to this implementation with their JavaScript/DOM engine, which allowed HTML elements to process and display remote server events with just a few non-standard attributes:

<div kn_topic="/some/path" kn_onmessage="process(event)"></div>

Of course we had a very freakishly large and complex JavaScript engine to handle all the Ajaxy goodness. At the time, we called it a microserver, since the idea was that the JS engine could serve events from client to server as well as to other parts of the client. A web application could comprise of several mini-applications tied together with a JS message bus — which isn't so different from desktop OS programming.

At one point it was generally agreed that the notion of a microserver wouldn't be exciting for much longer, since it seemed to make sense that this "JS message bus" would eventually be baked into the browser — if only people would see the usefulness of it! (This was in 2001; Google Suggest and Google Maps were a few years away.)

For something like WHAT-WG's event-source to work, there has to be support for such functionality in the browser. But I'm glad to see this development, and am looking forward to the time when we won't have to drag around additional JS libraries to implement event-driven web apps.

Tuesday, June 07, 2005

Dig!

Great Athena! It's DHTML Lemmings!