Ultimate Library Stub for Javascript

February 6th, 2007

Combining the power of hot buzzwords such as "closures", "private and privileged scoping", "anonymous functions", and "object namespacing", I present a framework for future Javascript libraries.

Read full entry »

Javascript: All grown up!

October 8th, 2006

Remember the days when Javascript was just a way to get things to move around on the page, and had to be coded completely separately for each browser? I'm amazed at how far the language has come. Now we've got closures, prototypal inheritance, and associative arrays, but without the usual slowdowns and complexity that usually result from extending a language. I just find it amazing that the language has truly improved over time, instead of becoming mired in bloat. Well done.

Excess GMail invites? Script them away!

October 6th, 2006

Amazingly, people are still looking for free GMail invites. (You'd think there'd be enough floating around, but apparently not.) There are several sites that accept invites and spool them back out to anyone who asks, my favorite of which is ByteTest. Sending invite after invite to ginvites@xn0.org is not my idea of fun, but I still like the anonymizing effect of the spooler, and I wanted to help. So, I hacked together a clod of javascript to automate the process.

Read full entry »

Introducing DynamicStyle.js – modify arbitrary global CSS

September 27th, 2006

While working on a project for school, I discovered that there was no easy way to add, modify, and remove global CSS. There are three well-known ways of dynamically modifying the CSS in a page: 1) Set the style of individual named elements, 2) set the class of the <body> element to invoke CSS predefined for the circumstance, or 3) add or remove links to existing stylesheets. None of these address the issue of adding arbitrary global CSS at an arbitrary time.

After several attempts (including modifying the contents of a text node inside a <style> node), I found a working solution using data: protocol URLs in <link> nodes. Here, for your coding pleasure, is DynamicStyle-0.4.js:

The DynamicStyle library is ridiculously easy to use, since initialization and cleanup are handled automatically. Here are some sample calls to the DynamicStyle library:

DynamicStyle.setStyle('search-hilite', 'span.search-1 { background-color: yellow; }');
DynamicStyle.getStyle('search-hilite');
DynamicStyle.removeStyle('search-hilite');

The code is available under both the Creative Commons Attribution Share-Alike license and the GPL.

Update: Newer versions and change log.

Proposal: JSON for scripting-ready page metadata

August 4th, 2006

I'm proposing a new standard: JSON used to enrich regular web pages with scripting-ready metadata. No more theme-dependent HTML parsing -- just grab the needed data out of a namespaced global object. Read on for details.

Read full entry »