October 4th, 2005


Tag autocomplete in JavaScript

Two exciting things...

Tag auto-complete working in IE:
Please check out the tag autocomplete demo:


Known to work in Firefox 1.0.x, Firefox 1.5.x, and IE 6.0.
Won't work in Safari due to Safaril limitations.

Let me know if it works in anything else (Opera?) or if you find any problems in any of the known-working browsers.

Six Apart and open source
Also of note: my employer, Six Apart, has agreed to open source the following JavaScript libraries:


Cooperatively they form a sort of compatibility layer for all major browsers to behave as the W3C says they should.

Ben's historically put a bunch of stuff on CPAN but I believe this is the first time that they've open sourced JavaScript (or any non-Perl) code. I argued that open sourcing JavaScript is the easiest possible decision because you can't control its spread anyway (the browser needs it to run), so you might as well reap the benefits of open source anyway, as long as you're making it available.

The three files above aren't really documented, but are pretty useful. I started using them in this tagcomplete project, but not as much as I could.... still got some reading/tinkering to do until I learn all the stuff in them.

The IE support in tagcomplete, though, (finding the selected region of a text input) was accelerated greatly by using some code from selectionrange.js. It didn't work for me as is, so I forked it for now, but I'll figure it out and get patches back to Randy to include in future version.

That's actually how getting Six Apart to open source these came out: I was asking Randy how to find the selection range of a text input in IE and showed him some ghetto code I'd started playing with (duplicating text ranges and sliding them around and comparing them) and he smiled and said, "Yup. That's right." and told me he'd already done it (in selectionrange.js). Then I decided I didn't want to waste my time doing something that'd already been done so I asked him and Ben if we could open source the above files, and uh, there they are. Enjoy.


Last night, with lisa:
-- beer, food, and open mic at Utah

Matthew joining, but not skating:
-- ice skating (only fell 4 times!). also did the whitaker dance on ice... Matthew got a video

Mischa, David, and Dina joining:
-- bowling. I rolled 180... 5 strikes (including a turkey), and 2 spares. ahh yea'. [video]

Overall, good night. We decided it should be the Monday night tradition.

Today I stayed at home and worked. It's the only day this week with an empty calendar, so I figured I'd take advantage of it.

InputComplete: my very first JS "library"

I wrote my very first JavaScript "library". Whereby library I mean:

-- doesn't trample the "window" object's namespac
-- doesn't trample your existing event handlers, and adding your own doesn't break things
-- easily reusable by others for other purposes

Here's the InputComplete (and InputCompleteData) class file, object oriented and MVC:


View the source for how to use it:


Create a data model (the word list to autocomplete), and create autocomplete objects for each input element, using that model.