little. yellow. different. A weblog by Ernie Hsiung

Posted
30 December 2004 @ 12am

Tagged
tech

coding / codeine

True story - A couple months ago, after another long night at work, I got pulled over by the CHP doing 75 on the freeway. “You’re up pretty late,” he said. “What were you doing tonight?”

“Coding,” I replied, as I handed him my license and registration.

He looked startled for a second. “Coding?”

“Yeah, coding.” Another pause. “I’m a computer programmer.” I began to wiggle my fingers for him, like I was typing a giant imaginary keyboard. My parents would make the same motion bragging to their friends that their son played the piano - Oh, our son has played for thirteen years! He’s like Mozart, they would say. Commence finger wiggling.

Oh. The policeman rolled his eyes as he walked back to the patrol car to relay my information. “Coding.” It was only after I drove off with a warning that I realized that the policeman didn’t think I was coding, but I was on codeine.

I’ve been doing a lot more coding lately, both in and out of work. You still won’t see write a lot about technical matters on this weblog, though. I figure that while I’m… hmm… adequate at programming, I have no right to write about it - there are thousands of other techie geeks, writing about standards and code practices and detailed how-to articles that everyone else can read and learn from. Me, I’m good at writing about how the lady at Chaat Cafe can’t get my name right.

That being said, I’ve been playing around with both PHP and DOM-based Javascript a bit more lately. The tool tips on the right hand side, for example - if you’re using Firefox, you’ll notice that the catty mouseover comments I wrote for each link had previously cut off after a certain amount of characters. I could have gone into my mini-blog weblog templates and changed the structure of how I wanted things to display, but that would have seemed like a giant overhaul. Could I do something where all I had to do was to insert a JS file and the title descriptions would automatically display? Turns out I could, thanks to the Document Object Model.

It helped that I had some old code to work from. A year ago I had written up this half-assed article on Help Tips. The plan was to show everyone how r0×0r I was at web development during my Yahoo! interview, with mixed success. After a little bit of tweaking, the code I use to enable tool tips is here.

The onload=init statement means that the init function kicks in once the document loads, and does two things: dynamically creates an empty tool tip, and collects all the a tags in the mini-blog section, where the id is set to textcontent1. The elements are stored into objTag, where mouse handlers are applied depending on whether you’ve hovered over the link or not. (It should be said that I had some help on positioning the tool tip from a similar project at WebFX. Why recreate the wheel, right?)

It shouldn’t be that difficult to implement on your pages either, provided that you have a little bit of experience with DOM. All you’d have to do is make sure that objTags is pulling the correct links and make sure you a CSS id of tooltip exists and you should be alright.

(My next post will be zanier, I promise)


13 Comments

Posted by
Xkot
30 December 2004 @ 1am

Thanks for fixing the hover text. Much better now in Firefox.


Posted by
Jess
30 December 2004 @ 7am

Funny, but “coding” means something else when you work in a hospital. As in, “that poor old lady who came into the ER this morning coded.” Believe me, coding that way will get you out of a speeding ticket, but you’d be better off with the ticket! ;)


Posted by
Scott
30 December 2004 @ 8am

Yay! I’m glad I can finally read the hover text in the mini blog without opening IE.


Posted by
Stan
30 December 2004 @ 12pm

Keep on talking about coding. it keeps me warm.


Posted by
Donny O
30 December 2004 @ 1pm

***YAWN*** Bring on zany!!! :)


Posted by
Charles
30 December 2004 @ 11pm

Oh yeah, that’s right, you’re a top, aren’t you? So now you just need to find someone into SUB-based JavaScript and you’ll be all set.


Posted by
ernie
31 December 2004 @ 12am

Only someone reading this weblog could make a sexual based joke based on the Document Object Model.

That’s why I [heart] you guys!


Posted by
ren
31 December 2004 @ 1pm

Thank goodness. Now I don’t have to view source anymore to get the full comments.


Posted by
fred
4 January 2005 @ 1pm

I one got pulled over making a delivery for a Pharmacy I worked part-time for. He asked me If I had any Alcohol Drugs or Weapons in the car. I said “I have drugs. and lots of them” he didnt think it was that funny


Posted by
Carla
5 January 2005 @ 7pm

I’m stopping by to say hi since it’s de-lurker day… so hi and Happy New Year!


Posted by
Eric in Seattle
6 January 2005 @ 10am

Ern!

The little hovering things don’t work properly in Safari when the content is scrolled; the things appear in the original location of the link instead of the scrolled location.

So if you scroll the window down to see some content that was previously below the bottom edge of the window, the hovering thing appears at the original location of the content - and out of bounds of the window and therefore invisible.

Got it? :)
Eric in Seattle


Posted by
Cindy
9 January 2005 @ 4pm

Haha, I thought the same thing that Jess did up there about the “coding”. I dunno if the term “coding” varies from hospital to hospital, but at the one that I volunteered at, to “code” means to have a “code red” alert. And what’s a “code red” alert? Cardiac arrest. So I’m sure you can imagine the panic that goes on if a patient is “coding.” Yikes.


Posted by
jluster.org
22 January 2005 @ 12am

Bingo, Joyce

Joyce (who’ll be sharing a panel with me, Tantek, and Ernie at SXSW)