upshots.org
HTML5 Audio – show duration before load

If you’re trying to display current time / time remaining / total time of an HTML5 audio element before it’s loaded, you can use the loadedmetadata listener. You can usually use the same listener that’s being used for the timeupdate handler.

Generally, framework event management should be fine as well, but I haven’t tried […]

MooTools – fireEvent passing a single array as a parameter

The MooTools fireEvent method allows us to pass extra parameters pretty simply. To pass a single parameter:

To pass multiple parameters, we have to use an array:

However, what if you want to pass a single parameter that happens to be an array? For example, if you have this callback:

And it […]

MooTools: Long-range dispatcher

While working on a very large ajax-y application, I found myself facing the following scenario: 1. Tons of custom (non-DOM) events. 2. These events are firing from very deeply-nested classes. 3. I wanted these events to communicate with “long-range” instances, far outside the currently executing scope block. 4. I wanted to preserve the scope of […]

JavaScript (jQuery + MooTools) Simple Swipe Event

As popular as mobile browsing has become lately, I haven’t found a much in the way of solid swipe management libraries, for any of the major frameworks. Fortunately, the logic is pretty simple. The basic idea is this: 1. When the mouse/finger goes down, measure where it hit. 2. When the mouse/finger goes back up, […]

JavaScript (jQuery + MooTools) get WordPress Posts from RSS as JSON

The url is structured like so: http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=10&q=[encoded URL of RSS feed] Replace [encoded URL of RSS feed] with the URL of the WP blog you want to fetch posts from. I’ll use mine (http://upshots.org/feed) for the samples. With either method, you’ll get back an object with the following keys: responseData responseDetails responseStatus responseData has a […]

JavaScript (jQuery + MooTools) get tweets from twitter feed

The url is structured like so: http://api.twitter.com/1/statuses/user_timeline/[twitter handle].json Replace [twitter handle] with the user whose tweets you’re requesting. I’ll use mine for the samples. With either method, you’ll get back an indexed array of objects (so the most recent tweet would be data[0]). Each object has the following keys: in_reply_to_user_id in_reply_to_user_id_str contributors in_reply_to_status_id created_at user […]

MooTools – get currentTarget method

Consider the following example (which comes up a lot in my style of writing Moo): You create a new Class and use the Binds property to fix the scope of it’s methods to the Class instance. You have a DOM element with some data .stored, and a mouse event handler that is a method Bound […]

JavaScript Color Class

UPDATE 09/02/11: This project is now available on github: https://github.com/moagrius/Color. Generally, the most recent updates will be found there – I’ll try to keep this page updated as well, but consider the repo linked to be ‘official’. Also proposing this as the new AMD module for the next major MooTools release (https://github.com/moagrius/Color-1). If you’ve seen […]

MooTools – copy all styles (copyCSS)

port from the jQuery version here.

Note the try/catch and direct style assignation in the IE block – I was getting back an error from MooTools setStyle when setting some returned style values. At some point, I’ll probably try and narrow it down and get rid of the try/catch.

MooTools – hitTest and hitTestObject