you call that scaring readers?
Pfft. I can produce way more boring posts than that.
To wit: I just got done adding a Drupal module to the company's open source offerings. Now, not only is it likely that none of you who aren't coworkers know what Drupal is, but any of you who do will probably find this module astoundingly useless. It creates a live tag cloud. Which, for anything but a huge flurry of folksonomic activity, will look a lot like an, um, normal tag cloud.
But! In the course of massively over-engineering this thing, I actually ended up using the Prototype Javascript library. And since the number of you who occasionally write JS may be non-zero, I should take a moment to sing its praises. I thought it was just an AJAX library, but no — it really makes a lot of things much, much easier (and with basically guaranteed compatibility). Some people say it's too large, but to them I say: shhh.
Its biggest problem is that it seems to be somewhat sparsely documented compared to its offspring Scriptaculous. But this article does a decent job of showing off its basic features, and providing enough code for you to get started.
Finally: I've mentioned it before, but if you're applying lots of event handlers to elements, consider Behaviour.
UPDATE: From the linked article, JQuery also looks pretty promising. And I might as well include the code for one of my all-time favorite JS functions, a method for safely adding OnLoad functions. It's behind the cut. Apologies to whoever the original author is.
// *** begin safeOnLoad functionisMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
NS4 = (document.layers) ? true : false;
IEmac = ((document.all)&&(isMac)) ? true : false;
IE4plus = (document.all) ? true : false;
IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
ver4 = (NS4 || IE4plus) ? true : false;
NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;// Body onload utility (supports multiple onload functions)
var gSafeOnload = new Array();
function SafeAddOnload(f)
{
if (IEmac && IE4) // IE 4.5 blows out on testing window.onload
{
window.onload = SafeOnload;
gSafeOnload[gSafeOnload.length] = f;
}
else if (window.onload)
{
if (window.onload != SafeOnload)
{
gSafeOnload[0] = window.onload;
window.onload = SafeOnload;
}
gSafeOnload[gSafeOnload.length] = f;
}
else
window.onload = f;
}
function SafeOnload()
{
for (var i=0;i<gSafeOnload.length;i++)
gSafeOnload[i]();
}// *** end safeOnLoad function

Comments
well done. ;)
Aside from appealing to OO prejudice, what's so great about a "times" method on numbers that takes a closure compared to a for loop?
Off-topic, but still nerdy so it counts: how do you get a screen shot on a Mac? I just started using one at work, and I'm now sympathetic to your previous post on Mac issues. Specifically, I want to do the Mac equivalent of what Alt + Print Screen does on a PC: copy the active window to the clipboard. But the google results aren't working.
Ben, I agree -- that feature seems fairly useless. But $()? or $$()? Pretty fantastic.
Stanley: hit shift-apple-4. That'll turn your cursor into a crosshairs. You can drag it around an area and the snapshot will show up on your desktop. If you want the entire window, hit the spacebar once you have the crosshairs, then click on the window you want. Again, the shot (a .png) will show up on your desktop.
I've been telling myself "I should really check out Prototype" for a while now, but $() and $$() are too awesome to wait any longer. Man, did my life just get easier.
Ben, I agree -- that feature seems fairly useless. But $()? or $$()? Pretty fantastic.
Not really knowing from javascript or web programming, I can't really appreciate their fantasy. I don't really think an integer.times method even makes very much sense; the message is, what, "do this yourself number of times"? A foreach method on a list, that makes sense.
Thanks!
Post A Comment