Sorry, Apple Inc., I’ve met something I like more than you

I first used a Mac in about 1993 — a Quadra I think it might’ve been, or a Performa. I’d come from DOS and Amiga and didn’t really know anything about anything — I didn’t even know there was anything to be known. I remember hearing someone talking about Windows, and assuming they just meant those rectangles one could drag about on the screen. A computer to me was a fun sort of thing which could usually be made to do (boring… but strangely compelling) things with textual input and output, thanks to variants of a ‘basic‘ language (AmigaBasic, QBasic, etc.). When I found AppleScript — and when I started using it for CGI programs (don’t ask!) — it seemed that all that one needed was an idea and some time, and the machines could be made to do anything!

Anyway, it was on System 7 that I spent most of my time (and its successors), thanks to my stepfather’s loyalty to Apples — and I loved it. I loved the whole Apple thing, really — this odd feeling that somehow, just by choosing this particular OS, one could be calmer, more focussed, write better (code or prose), and still spend one’s spare time rock climbing (as I did). That couldn’t be the case with those horrid business machines running Windows, that was for sure! I even got a reply from Douglas Adams himself once (a Mac person, as if you didn’t know), to my pedantic email with the subject “Macs are PCs too, you know” (he said, no, they’re not, that argument has been won, and Macs are something more than Personal Computers). I remember sitting in a bookshop reading the Apple Human Interface Guidelines, and thinking how much amazingly careful thought had gone in to everything — the distance between buttons in a dialog window, for example, or the algorithm for changing the length of the ‘thumb’ in a scroll bar as the content length changed.

Why on Earth was there such an element of personal identification with these computers?! I was an ‘Apple person’; otherwise known these days, more appropriately, as a fanboi! Which has lasted nearly twenty years… but I can’t keep it up. I’ve been through five or six Macs in that time — I’m typing this on my MacBook5,1 — but it’s time to move on. I’ve enjoyed them all, especially the feeling that they are reliable: physically solid and unlikely to break in my backpack. But I won’t be buying another. I’m losing faith.

No, I’ve lost my faith. I lost my faith as Apple wanted to control everything more and more — the whole ‘ecosystem’, as they say, of OS and programs and data and sources — and as my awareness of the value of open standards grew. Obviously, I’m not saying that one can’t work perfectly well with open standards on Mac OS, because I have been doing so for years and years. It’s just that the OS as a whole is not geared to helping people do that. I shudder to think of people who know no better and are tying up their entire digital archives in formats that offer no security for future access! (But don’t let me get sidetracked into that discussion…)

I’ll no longer align my computing life (which is a rather large part of my life, for better or worse) with a corporation who’s aims are less than honourable: so I’ve bought a Lenovo X220, and shall be running Ubuntu exclusively. (I would’ve done this years ago, except for the fact that my current hardware has been running well since 2008, and I hate the idea of discarding a useful machine. Also, I do most of my computing on Linux anyway; the local machine is just a gateway, really.)

Goodbye Mac OS! I’ve enjoyed the ride and learnt lots, but ultimately have been thwarted in learning on too many occasions. It’s time for a system that, should I come up against its limitations, can be changed to suit my needs.

So long and thanks for all the fish. ;-)

Preventing duplicate rows in a tabular HTML form

I am working on a bespoke issue-tracking system at the moment (not for code issue-tracking, in case anyone thinks we’re cloning Redmine; although there certainly are overlaps…) in which each issue has a list of personnel, each of whom have a role on the issue.

The task at hand is to prevent people selecting the same combination of role and person more than once. Of course, the application and database will reject such an occurence; this is to fix the UI so that users can’t easily submit the duplicates. For the purposes of this explanation, we’re working only in HTML and Javascript (jQuery).

The UI looks something like the screenshot to the right (there is also a means of adding new rows to the table—that doesn’t change how this validation works, but it is why we’re using .live() below):

The Problem

In an HTML table full of form elements,
where new rows can be added (dynamically),
we want to prevent duplicate rows being selected.

The Plan

After changing a value in any row,
get a list of the values in that row
and then go through all of the rows
and see if those values are there.
If we find more than one instance of them,
tell the user
and return the changed value to what it was before.

The Solution

The final code is below (it was built using jQuery 1.6.1 and jQuery UI 1.8.5), and a demonstration is available elsewhere.