Posts Tagged “work”

Yesterday, during my daily read of Dave Winer’s own RSS feed, I discovered that it was RSS Awareness Day. I really wanted to blog it there and then but hadn’t the time because, ironically, I was working hard at the coalface, hacking away (I like this metaphor) at a client’s RSS-driven microsite.

So in lieu I now declare today “RSS Awareness Day” Awareness Day, because I’m very aware that yesterday was RSS Awareness Day.

During yesterday’s frenzied session I was reminded poignantly that not all of the data in an RSS feed is as reliably parseable as the XML itself. In this case, I was extracting tags from a comma-separated list and putting them into a database.

In my infinite wisdom I put an index on the table which forbade duplicate tags within an item. While parsing 50 items in a test feed nothing went awry but, of course, the very first item on the client’s real feed contained sloppy repetition of tags, exposing my lack of foresight with a nasty SQL duplicate key error.

I live and I learn.

Comments

Today I’ve been working on a very long form which needs client-side validation (as well as server-side validation, of course) and tooltips for most of the fields. For users without JavaScript, the tooltips are all shown next to each field. When JavaScript is enabled, however, the tooltips are all hidden at onload and then appear when a field gains focus. When a field loses focus, its value is validated with JavaScript and if this fails, an error message is shown next to that field.

I started doing this the way I usually do events, by putting onfocus and onblur events in the HTML on each field. It worked, but there are so many fields and it became a pain to put this in every field. I find that lots of JavaScript often decreases the readability of HTML, too.

I thought, “there must be a way to use JavaScript itself to add these events to each field”. It turns out that there is:

fields = document.getElementsByTagName('input');
for (i=0; i<fields.length; i++) {
 fields[i].onfocus = function() { … };
 fields[i].onblur = function() { … };
}

Now the events code is unobtrusive in the HTML. Users without JavaScript don’t have to download the events code, the HTML is more readable and I need to do a lot less copying and pasting!

Comments

I’m finally using Apple Mail in work again after using the utterly crap Entourage 2004 for months. My favourite things about Apple Mail are:

  • Integration with Address Book
  • Opening attachments without a confirmation dialogue every time
  • Dragging-and-dropping attachments straight onto applications
  • The connection status window doesn’t open itself every time mail is received
  • Number of unread messages is displayed on dock icon
Things I don’t like about Apple Mail:
  • Horizontal, letterboxed layout is less efficient than a column layout on a widescreen monitor
Thankfully there is a plugin available to turn Mail’s interface into a column layout. (That one is for Leopard only; there’s something similar available which works with older versions of OS X.)

Comments