LaViska.com LaViska.com

The global object model

A drawing of a cartoon man pointing upwards

Hey there! This post was written in 2008, so it may contain information that is no longer accurate or thoughts that no longer reflect how I feel. As human beings, we're constantly learning and bettering ourselves through experiences and interactions with the world and each other.

I keep posts like this around for historical purposes and to prevent link rot, so please keep this in mind as you're reading.

— Cory

Levi and I came up with a real-life equivalent to the Document Object Model (DOM). It's called the Global Object Model (GOM), and it can be used to organize, reference, and manipulate elements around the globe using simple JavaScript statements.

Where the DOM limits you to window and document, the GOM opens the door to bigger and better things. For example:

var idiot = world.countries['USA'].currentPresident();
alert( idiot.approvalRating() ); // outputs 3%

The GOM supports event handling. The following code would guarantee that I alway have Taking Back Sunday tickets as soon as the band goes on tour:

world.musicians['TakingBackSunday'].onTour = function() {
  world.people['cory'].buyTickets();
}

Error catching is easy with the GOM:

try {
  world.people['cory'].fartInPublic();
} catch {
  alert('Excuse me!');
}

I'm even working on a jQuery port so we can minimize the amount of code and the time it takes to write said code. Now, you can reference multiple people, places, and things with simple CSS selectors. To make it snow in Las Vegas, Phoenix, and Albuquerque, we say:

$('#las_vegas, #phoenix, #albuquerque').weather('snow');

To invoke uproar in every U.S. city simultaneously, we could use:

$('#USA .city').pandemonium();

Standard jQuery functions still work:

$('#reportCard').hide(); // for kids with bad grades

$('.breasts').show(); // at Mardi Gras

$('#g_w_bush').replaceWith('#mr_t'); // a better choice

And, of couse, chainability. Here's how I would wake up every morning:

$('#cory').onWake( function() {
  $(me).shower().brushTeeth().getDressed().goToWork();
});

And, in case you're wondering, within a few minutes I'll be doing something like:

$('#cory').sleep();