Some notes on DOM features of Konqueror that make AJAX hard

I’m trying to get the GPLv3 comment interface working on Konqueror, and I’ve made some interesting discoveries about what Konqueror’s KHTML doesn’t support,  though Safari’s supports some of them. Among these:

getElementById(): XHTML elements whose tags are not part of HTML cannot be gotten by getElementById(). I.e., I have <section id=”foo.p1.s3″> and <sent id=”bar.p3.s1″>, and FireFox will getElementById these for me without complaint or warning, and the w3 validator doesn’t have a problem with these elements having these attributes. Konqueror (and I think Safari, too, so, KHTML), on the other hand, won’t get them unless I rename all of them to <span id=”foo.p1.s3″> instead. My file doesn’t quite validate as XHTML1.1 transitional, though, so there’s a chance it’s better for perfectly-valid XHTML. But I doubt it.

document.getSelection(): Firefox and the DOM recommendation give you a selection object with all sorts of useful attributes: anchorNode (the node where the selection begins), focusNode (where the selection ends), other goodies. Konqueror gives you the selected text and nothing else.
So it’s time for me to write an alternate submission mechanism for stet, a Mason script that takes one argument: the selection. Then it looks in the master text for your selection, and if it finds it, it asks you to type the rest of your comment, otherwise gives an error. This could still be pretty ajaxy, though at some point someone is also going to need a plain old simple HTML form, and I might as well implement these two at the same time.

serializing xml: ha ha you sucker, just use the DOM laboriously for even the simplest task. Actually what I need to do is write my own serializer, which will just go through all the children and copy all their children and attributes recursively. So straightforward, it boggles that KHTML haven’t already implemented it/ported it from Safari.

Zen and the Art of Avoiding Solicitors

Last week, walking through Union Square, I accidentally made eye contact with a guy who was soliciting for donations to a charity. He extended a hand for a handshake. For some reason, I am a sucker for handshakes. Before we disengaged, he had begun:

Him: If you and I, today, could do one thing to make the world a better place, what would it be?

Of all the questions he could ask me.

Me: I’m doing it!

Him, taken aback: …Really? What are you doing? (genuinely interested).

Me: Well, um. I’m working on this new software license? That’ll protect software for people who want to share their software? It’s… really important. So, [reading his shirt] what is Dialogue Direct? You’re a company contracted to do fundraising for [I forget the name of the charity on his shirt]?

Him: Yeah, we’re this service for charities that handle all their fundraising for them, etc. etc.

The really thrilling thing about this exchange was that this guy’s opener — intended, obviously, to make me uncertain, “gee, I dunno, what do you suggest?” was, instead, exactly the question I needed to hear to make me feel good about myself. I’d been nervous about leaving my old job and anxious about the particular combination of money, responsibilities, and the transition to full-time contract work that my new contract job required, especially since we were still in negotiation. I knew very well, but kept somewhere in the back of my mind, that I wanted to do this new task because it is perfectly in line with some things that are very important to me. But the excitement of doing something really important was overshadowed by my doubts and worries.

But when this charity guy asked me his question, I remembered all the good stuff, all at once. For the past year, at my old job and my new one, I’ve chosen my work in such a way that every day, even when I don’t want to go to work, even when I’d rather sleep in, or read RSS feeds for the first 90 minutes of my day — every day I’m actively engaged in doing something concrete to make the world a better place.

This actually sounds obnoxiously self-congratulatory, as I write it, but the insight this exchange gave me, ultimately, was not about what a great and noble philanthropist I am. The insight is that, whatever we’re doing, we can forget the reasons why we’re doing it as we get bogged down in the drudgery of the day-to-day. There’s generally a good reason why we’re on our particular path, but we easily lose track of what it is. And the trick is to get someone to ask you the question to which the answer is, “I’m already doing exactly what I should be doing.”

And then change the subject to something unexpected, so they don’t get a chance to ask you for money to feed starving children.