MacPython Logo from __future__ import *

buy music albums Silver Apples buy mp3 albums Tarrus Riley buy tracks mp3 Kravits buy Reaper albums mp3 buy Kravits albums music buy music Evita CD online albums mp3 Silver Apples download Madonna CD music buy tracks music Kravits download music albums Silver Apples

2005-10-24

MochiKit 1.0

Filed under: AJAX, MochiKit, javascript — bob @ 7:44 pm

I've been putting in a lot of time into MochiKit lately getting it ready for this release: 1.0 [download]. This version number carries a certain connotation, but honestly MochiKit's first release was beyond 1.0 quality compared to the rest of what's out there in this space. It's stable, and we just tagged the latest MochiBot release with what's currently in there (which was a couple checkins before 1.0).

The first thing MochiKit 1.0 brings is a bunch of little bugfixes. There weren't all that many to begin with, but I think they're basically all covered at this point. The rounded corners code still has some rough edges (hah), but it works if you use it as intended and MochiKit isn't about bling at this point.

Everyone loves examples, so here's the new ones:

Interpreter:
An interactive JavaScript interpreter, much like python when run with no arguments. Very useful!
MochiRegExp:
A "live" RegExp explorer, good for debugging those gnarly JavaScript RegExps. RegExps without named groups or a verbose flag suck, you need this.

One API change has been made though (basically a bugfix): MochiKit.Async's sendXMLHttpRequest and anything that uses it will now call the errback chain under ANY error. This means that if the web server is down or if the user has gone to another page or started closing the browser, then you'll get an error. From what I've seen, the error under both of these conditions is going to be an XMLHttpRequestError with undefined status. That's right, you won't be able to discern one from the other, so don't do anything obtrusive (like an alert) if you see an XMLHttpRequestError in your errback! The best thing to do is just log or ignore these errors.

MochiKit.Base has a new updatetree(self, obj[, ...]) function to update an object tree, in order to support new MochiKit.DOM updateNodeAttributes functionality (below).

MochiKit.DOM's updateNodeAttributes now uses updatetree if it sees object values, so you can now set style attributes inline:

var div = DIV({"style": {"display": "block"}}, "div contents here...");

MochiKit.DateTime's isoTimestamp now uses one of the ugliest regexps I've ever written in order to parse ANY ISO 8601 timestamp. It doesn't attempt to validate, so it will accept a large subset of incorrectly formatted ISO 8601-ish timestamps. RegExps in JavaScript are so bad that I had to write MochiRegExp to get this right!

MochiKit.Format grew a couple new functions:

  • truncToFixed(aNumber, precision): Truncate a number to the given precision (does NOT round).

  • roundToFixed(aNumber, precision): Round a number to the given precision (because Safari's Number methods are mostly broken)

  • numberFormatter(pattern, placeholder="", locale="default") and formatLocale(locale="default") brings Java style number formatting to JavaScript:

    assert( percentFormat(1.234567) == "123.46%" );
    assert( numberFormatter("###,###%")(125) == "12,500%" );
    assert( numberFormatter("##.000")(1.25) == "1.250" );
    

1 Comment »

  1. Congrats on hitting 1.0 (even though it’s sorta arbitrary).

    It’s weird that Apple devs woulnd’t have looked at the 0.5 test case for Number.toFixed().

    And I really, really like the style of the interpreter (i.e. blue “>>>” prompt and black output) and how there is the up/down arrow functionality; it really lends an air of familiarity. It’s also sweet how MochiRegExp bolds the matching part of “input”.

    Too many people blow off details like those as some kind of “fluff”, but usability matters. The fact it’s a polished release and you’ve developed those tools makes it that much more likely to be adopted.

    Nice job.

    Comment by Joe Grossberg — 2005-10-25 @ 8:25 am

RSS feed for comments on this post.

Leave a comment

Protected by WP-Hashcash.

Powered by WordPress