The Best Agrees

General — Barry on October 29, 2007 at 9:33 pm

Maddox sez there’s a connection between crocs and NASCAR. There must be, since he’s always right.

I slightly disagree with him on babydoll tops. (Is that what they are called? Why do I even know this shit?) They look okay on girls who are a little chubby. And by the way ladies, it’s okay to be a little chubby, depending on your body type.

Maddox didn’t rant about ugg boots and big ass sunglasses though. He must be dating someone who wears them simultaneously. It’s fucking tragic when a really cute girl does that. TRAGIC!

JavaScript “with” Cheesy Hack

Nerdy — Barry on October 24, 2007 at 6:25 pm

The quotation marks around with are not unnecessary because this is about the JavaScript keyword.

Douglas Crockford said in his “The JavaScript Programming Language” video lecture not to use with, because the scope gets all confused. Or something. But since I’m not a senior JavaScript Architect at Yahoo!, I can cheesy hack all I want.

Here is the relevant code:

with(this) {
  GEvent.addListener(polygon,
                     'click',
                     function(point) { clicked(OMap.getMap(), point); }
  );
}

That code is in a public class method (drawPolygon). I need with for the clicked method used in the anonymous function for handling the click event.

Without with, clicked won’t resolve to anything. I can’t use this.clicked, since this will be referring to the clicked polygon, not the object drawPolygon and clicked belong to.

Some of you might be thinking “well, have you tried copying clicked into drawPolygon’s scope with something like var clicked = this.clicked;“? Well done, sir. You’ve just won some internets for your trouble.

Unfortunately, that doesn’t work in this case. It fixes the scope with clicked in the anonymous function. But the problem is that this is used in the clicked method, and clicked’s this will reference the wrong object. FAIL.

I wonder: What Would Doug Do?

My God!

General — Barry on October 19, 2007 at 7:30 pm

NASCAR Ladies Pump:

Well, it’s still better than fucking ugg boots and crocs.

Next Page »
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. | chenb•log