jQuery

I was happy to see on the jQuery blog that Nokia and Microsoft are moving towards supporting jQuery. It’s a sweet little library that I use a lot to speed up JS development. Adobe CS4 boasts jQuery integration as well now, and if the number of job ads I’ve see which include a line like “familiarity with JS frameworks (like jQuery)….”, it all makes it look like jQuery is the must have toolkit of the moment.

I don’t know how long jQuery UI has been out, but it looks like it can help me out as well. I have a couple of pages that contain both jQuery and SPRY code, and I’d like to minimize the number of libraries I use on any given project. The fewer libraries, the less chance of conflicts.

Comments (2)

Of Chrome and Names

What’s in a name? that which we call a rose
By any other name would smell as sweet;

I don’t like making fields mandatory in web forms. Some people seem to love it. Forcing the user to complete every single field. But in most cases, I just don’t see the point.

So the client says to me: “we must make GST mandatory!”

So I make it mandatory.

But that means we now *need* to be able to delete rows from the claim form, where before we could safely ignore them.

No worries. I just use that handy JavaScript regex replace method to adjust all the fields ID’s so they are right after removing a line.

It all seemed to be working so well.

But when the fields ended up on the server side, all the names were wrong.

Why, oh why, didn’t I think to adjust the fields name attributes as well as the IDs?

I’d gotten so hung up on using ID’s in the DOM for manipulation with JavaScript, that I’d forgotten that the form data set that a browser builds is based on the fields NAME, not it’s ID.

Doh!

So once I’d been reminded of that, thanks to the patient people on the CFCDEV list, it was a trivial matter to fix it.

BTW, I’m trying out Google chrome to posts this. Where are all my WYSIWIG controls in the edit area in Wordpress? Bummer :(

Comments

Functions

I love functions

Smaller and smaller

decomposing

(My haiku for the day)

Comments

pirate day?

September 19th is international talk like pirate day.

I was looking forward to some pirate fun, but I’m not sure the world is going to make it to the 19th. The Large Hadron Collider is due to be switched on September 10th, and it will destroy the world.

It’s been nice knowing you all ;)

Comments

i <3 jQuery

I’m still loving jQuery.

I have a little job to do at work where we have a document that the client wants to have little hot spots where people can click on and a little window will pop up giving detailed explanations for that section of the document.

For whatever reason, I was told not to use Flash (which would have been my first choice), and so chose DHTML instead.

After a bit of head scratching, it seemed like a very simple solution would do the trick. I have an image of the document using a good old fashioned image map. The hot spots in the image map are primed and ready for clicking on. I highlighted the clickable areas in the actual image so people would know where to click. There didn’t seem to be any sense to using CSS for this. Just placed a block of colour at 20% opacity in the same region the hotspot would be (Fireworks makes this very easy).

Then I added a DIV to the page with an id (”thePopUp”). No point is having separate DIVS for each region since only one will be visible at a time. I styles the DIV with a little CSS so it looked nice, and made it’s positioning absolute so that I could place it anywhere on top of the image.

Then there was just the Javascript left to do. jQuery makes it laughably easy to grab stuff out of the page, so I grabbed all the AREA elements (which correlate to my hotspots), and attached a click event to them. I may improve this later to trigger on focus or something like that to make the page keyboard navigable.

The click event grabs the COORD attribute from the AREA element and runs it through a regex to extract the X andY coordinates of the hot spot, and sets the LEFT and TOP attributes of my DIV with them. It then grabs the text stored in the AREAs LONGDESC attribute and uses it to set the content of the DIV.

Then I use the fade effect in jQurey to make the DIVappear.

So Easy :)

I’m amazed at how few lines of Javascript I needed to do this.

Sample code below so you can follow along at home. Of course this is a smaller version, since the real one has a much larger image and many more image map areas. But this is enough to get the idea…

  1.  
  2. <style type=“text/css” media=“screen”>
  3. #thePopUp
  4. {
  5. background-color:#FFFF00;
  6. color:#CC0000;
  7. border:3px solid #FF6600;
  8. width:300px;
  9. font-family:Geneva, Arial, Helvetica, sans-serif;
  10. font-size:1.1em;
  11. position:absolute;
  12. top:0px;
  13. left:0px;
  14. display:none;
  15. padding:0.5em 0.3em 0.8em 0.3em;
  16. }
  17. #boo
  18. {
  19. position:absolute;
  20. top:0;
  21. left:0;
  22. }
  23.  
  24. #imgContainer
  25. {
  26. position:absolute;
  27. }
  28.  
  29. #small
  30. {
  31. font-size:0.7em;
  32. font-style:italic;
  33. }
  34.  
  35. #small:hover
  36. {
  37. text-decoration:underline;
  38. }
  39. </style>
  40.  
  41. <div id=“imgContainer”>
  42. <img name=“boo” src=“boo.jpg” width=“375″ height=“500″ border=“0″ id=“boo” usemap=“#m_boo” alt=“” />
  43. <map name=“m_boo” id=“m_boo”>
  44. <area shape=“rect” coords=“146,210,224,272″ href=“” alt=“” id=“heart” tabindex=“1″ longdesc=“some text here”/>
  45. <area shape=“rect” coords=“91,45,251,153″ href=“” alt=“” id=“smile” tabindex=“2″ longdesc=“some other text here”/>
  46. </map>
  47. <div id=“thePopUp”>place holder</div>
  48. </div>
  49.  
  50. <script type=“text/javascript” src=“jquery-1.2.6.js”></script>
  51. <script type=“text/javascript”>
  52. var speed = 500; // set fade in/out speed
  53. re = /(d*),(d*),(d*),(d*)/; // regex for disecting coords
  54.  
  55. $(document).ready(function()
  56. {
  57. $("area").click(showIt);
  58. $("#thePopUp").click(function(){$(this).fadeOut(speed)});
  59. });
  60. function showIt()
  61. {
  62. var co = this.coords;
  63. var bits = re.exec(co);
  64. $("#thePopUp").css("left", bits[1]+"px");
  65. $("#thePopUp").css("top", bits[2]+"px");
  66. $("#thePopUp").html(’<p>‘ + this.attributes[’longdesc’].value + ‘</p><p id=“small”>Click here to close this little window.</span></p>‘);
  67. $("#thePopUp").fadeIn(speed);
  68. return false;
  69. }
  70. </script>
  71.  
  72. </body>

Comments

Warming to SQL

I never have loved SQL. But I respect it.

I just managed to save ~30% page load time per page load by writing a better query. That’s pretty reasonable.

Using a self join meant I was able to get all the information I needed in a single query.

The lesson I’ve been learning lately, apart from learning about SQL joins, is to work with the database, not against it.

It’s too easy to write a simplified query and let application logic crunch through it, rather than take the time to write a better query and save the application layer a lot of work. Work which the database is designed to do in the first place. It’s worth investing the time to learn how the db works.

Comments (2)

A List Apart, The Survey

i-took-the-2008-survey.gif

Comments

The hand (paw?) of Basement Cat

I wrote a quick (and dirty) script to track clicks on links from a directory page at work. It’s been running for a few weeks now.

I just looked at the current results and saw…

<ol>
	<li>Careers</li><!– #1 with 6666 clicks –><li>Human Resources Forms</li><!– #5 with 666 clicks –>
</ol>

Is this evidence of Basement Cat at work?

And is it a coincidence that HR has “666″ clicks?

Comments

The Coup

First there was Project Mayhem.

Now there is The Coup.

Ok. Perhaps we need a better name. Feel free to suggest one.

But for some time there have been mumblings and grumblings about the future of ByteClub. Although it pains me to admit it, patronage has been in a steady decline for some time, and now only a few hardy souls remain here. And ITS, who have taken over the running of the ICT infrastructure etc, are not happy with Tyler being on their network.

But Clinton and I aren’t ready to give up.

Some time in the next 6 months, we hope to buy the byteclub.net domain back from the ICT faculty and start hosting ByteClub somewhere else.

Yes, this means the end of Tyler :(
(should we have a wake?)

But it also means more control by Clinton and myself and, hopefully, exciting new opportunities. The first of these, I hope, will be installing WordpressMU so we can host our blogs with more individual control.

In related new, I just got word from my domain registrar that byteclub.net.au and byteclub.com.au were both up for grabs, so I registered both domains. I’m just going to park them for a while, but at some point we should be in a position to point byteclub.net, byteclub.net.au and byteclub.com.au all at the same server.

Having the .com address is just a defensive manoeuvre. I/we have no plans to go commercial with this site.

Comments (5)

dreaming of version control

I see a beta for Dreamweaver CS4 is out. I haven’t looked at it yet, but it claims to have native SVN integration. That’s a big step forward. Of course it would only be useful if somebody would set up an SVN repository here at work. I’d do it myself, but I don’t have authority to go installing stuff on our servers :(

In the mean time, I’m stuck with CS-RCS. It’s taken me a little time to get my head around this tool, after using SVN, but I guess it does the job.

I know there’s all kinds of features that other versioning tools, even CVS, have to offer that beat CS-RCS, but for the most part, those features are above and beyond my needs as a humble web developer. It would be nice to be able to fork a project (can CS-RCS do this? I haven’t checked.), because I have three projects that share about 80% of their code base, yet these projects are all maintained seperatley. But for the bulk of what I do, CS-RCS works. (Hey, any version control is better than none.)

The main thing that urks me about CS-RCS is the lack of integration with Dreamweaver. I’m using Dreamweaver CS3 and I have to say it’s no great shakes. I actually chose to go back to using Dreamweaver MX on my home machine because it seems to do everything CS3 does, but without the bloat, meaning it runs faster.

There is a Dreamweaver plugin for CS-RCS, but it only works on the MX version, and since I’m using CS3 at work, this is a pain. I have to keep switching back into the CS-RCS tool to check the status of files. Switching apps isn’t going to kill me, but it’s a pain, and it’s a productivity drain, especially when CS3 seems to have some kind of memory leak issue that causes it to run slower and slower the longer I use it, which is especially noticeable when I’m switching apps.

So my wish list for now is:
* Somebody up in IT gets around to installing SVN on the server, and
* Dreamweaver CS4 SVN integration works, and
* Dreamweaver CS4 is an actual improvement over Dreamweaver MX

Comments

« Previous entries ·