Archive for May, 2005

05.10.05

Realtor.com Greasemonkey script

Posted in Uncategorized at 12:25 pm by UnwashedMeme

Jason and I just collaborated to create our first Greasemonkey script: GreaseMonkey script repository. RealtorGoogleMapLinker.user.js

This simply adds a link to Google maps immediately below the address on the details page of a house.

05.05.05

JS Namespaces redux

Posted in Uncategorized at 5:11 pm by UnwashedMeme

Ryan blogged about a Suggestion for Emulating Namespaces in JavaScript that Daniel dug up for me.

One of the things Ryan is afraid of, and the one of the first things I thought of when I read the suggestion on namespaces, is that . is all figured out at runtime (this being javascript there tends not to be much other time). As Ryan mentioned though, you can get a reference to make it cheaper. For example (his example):

// CD.Music must be loaded already. Create the constructor.
CD.Music.Classical = function () {}

// Inherit from CD.Music.
CD.Music.Classical.prototype = CD.Music.prototype; // Inheritance.

// Add to the class and/or override as necessary.
CD.Music.Classical.prototype.composer  = null;
CD.Music.Classical.prototype.orchestra = null;
CD.Music.Classical.prototype.conductor = null;
CD.Music.Classical.prototype.soloist   = null;

Is (AFAIK) equivalent to:

// CD.Music must be loaded already. Create the constructor.
CD.Music.Classical = function () {}

// Inherit from CD.Music.
CD.Music.Classical.prototype = CD.Music.prototype; // Inheritance.
// Add to the class and/or override as necessary.
cmcp = CD.Music.Classical.prototype;
cmcp.composer  = null;
cmcp.orchestra = null;
cmcp.conductor = null;
cmcp.soloist   = null;

Which should help reduce that penalty. But to answer your question directly: “No, the client doesn’t have anything better to do than evaluate our inefficient code.” ;-)