Deported to India

Programming
Comments Off on Deported to India

We have a little saying around the office, “If that patch isn’t committed to the cvs by noon we’re deporting you to India.

Tonight I decided to get cute and implement some visual effects. I’m ashamed that the stuff below took 25 minutes to produce:

$style = ( $i % 2 ? ‘altrow’ : ‘row’); $i++;
echo “<tr class=\”$style\”
onClick=\”window.location.href=’
/view.asp?item=ticket&ticketid=$tickets[ticketid]’\”
onMouseOver=\”this.className=’hrow’;\”
onMouseOut=\”this.className=’$style’;\”>”;

I’ve posted it in its entirety so I can be ridiculed at a later date. What took so long? Stupidity as usual, but the longer you go in a stupid direction the longer it takes to figure out just what went wrong in the first place.

The top line just determines which style gets applied to the row in a listing. The idea is to alternate styles so that the table is easier to read. There are two styles here, row and altrow – pretty simple. As I list data I’m using the modulus (remainder after /2) to determine which style gets applied. There are two events that fire – namely when the mouse hovers over the row and when it leaves it. When it hovers, the style ought to be switched to hrow which is my highlighted row. After it leaves, reset the style back to what it was previously.

Then I decided to get cute. I wanted the row color to change as I scrolled up and down the list. I also wanted to be able to click on any inactive space in the row and still take the default action. Again, programming 101. Where I lost the ball game was on the this.style part – this.style takes on all sorts of things like color for example – all except stylesheet name. It took me good 20 minutes to figure out why/where/how before I finally went back to look it up. I suck.