infundibulum

jQuery junk

October 30th, 2007

I put up a bunch of junk in a directory with jQuery stuff. It’s largely broken experiments. JUST FOR YOU. jQuery

A wee introduction to Event Handling in Javascript

April 27th, 2006

This has been sitting around on my hard drive so I decided to finish it up:

A wee introduction to Event Handling in Javascript

As always, I’m more interested in “learnability” than… well, anything else.

Actually, I’m starting to think that it would make more sense to just start learning about this stuff by ignoring it — one could just learn how to use jQuery to do all such stuff, rather than touch event handling at all. But jQuery is still in heavy development, and anyway, you can do a fair amount of neat stuff with simple event handline.

In any case, there it is.

Simon Willison’s (Re)Introduction to Javascript

March 7th, 2006

Simon knows his stuff:

A (Re)-Introduction to JavaScript

I actually sort of understood the stuff about closures and prototypes and scope chains and other frightening things after reading through this…

Worth a look…

Javascript Array Oddness

February 26th, 2006

Weird thing about Javascript arrays:


d = [['a','1'],['b','2'],['c','3']]

for (i in d) { alert(i) }

Will pop up 0,1, and 2. That is, iterating through something returns the index of each of the elements of the array. If you want the elements themselves, you have to dereference them:


for (i in d) { alert(d[i]) }

This is nutty, as far as I can tell. I don’t know of any other programming language that does that. Why would you want to loop through the indexes of an array as the default? Python’s approach for example is what seems normal to me:


>>> d = [['a','1'],['b','2'],['c','3']]
>>> for q in d:
... print q
...
['a', '1']
['b', '2']
['c', '3']

If you want the indexes, of course, you can get them like this:


>>> for i in range(len(d)):
... print i
...
0
1
2

That is all.

Getting the font-family of selected text?

November 30th, 2005

I have the Firefox DOM Inspector doohickey (which you should have too if you do any significant amount of web design), and also a plugin called “Inspect Element.”

One cool trick you can do once you have all this set up is to highlight some text, click “Inspect element” in the context menu, and then select “Computed Style” from the dropdown in the right-hand pane of the DOM Inspector. Then you can go and look at font-family and see just what fonts are specified for the text you selected.

So, here’s my question:

It must be possible to access this info from Javascript. Then, I could make a one-click bookmarklet so I could select some text and have the font-family value pop up.

That would be fly. So… anyone know how to do it?

Bueller? Bueller?

Javascript Mailing List?

August 25th, 2005

There’s a Rails mailing list and a bunch of Python mailing lists and small industry of Perl mailing lists and so on and so forth.

So where’s the Javascript mailing list? Am I just missing it? Because it seems like something that would be useful, what with all the webappishness going around and unobtrusivity and all that.

Bueller?

☞ update

Steve Clay made a recommendation on the jQuery list about a general Javascript mailing list:

Javascript Info Page

I just signed up, we’ll see!

Sitepoint’s CSS and DHTML Books

July 25th, 2005

I’ve recently become a fan of Sitepoint’s books on programming. They’re very cleanly put together, and generally speaking seem to be quite up to date. Here are a couple of titles I went ahead and took the plunge on:

HTML Utopia: Designing Without Tables Using CSS
I like this book quite a bit. The CSS reference in the back is almost worth the price of admission… there are references online (duh) but I guess I’m just still a sucker for paper. There’s a lot of useful info on styling text, which turns out to have more tricks available than I’d ever heard of. One thing about this book that annoyed me intensely was in chapter 6, “Putting Things in Their Place,” when he gives a Javascript solution to the problem of getting columns to flow to equal heights. Admittedly, he gives an alternative, but there are a lot of pure CSS solutions to this problem out there, and one would think that if there’s a reliable one out there, that this would be the book to find it. So yeah, that bit rubbed me the wrong way.
DHTML Utopia: Modern Web Design Using JavaScript & DOM
I’ve been looking forward to this one for quite a while. At that link you can get the first four chapters for free. To be honest, I debated whether to buy the book, because judging from the table of contents, it seems that most of the stuff that I had doubts about was in the free sample chapters. But I’m a big fan of the author and editor: Stuart Langridge through the ridiculously awesome LugRadio (or listen on Odeo) and Javascript/Python guru Simon Willison. So in the end I felt pretty good about picking up a copy. Haven’t started digging in yet. One nit to pick: forty smackers is a lot to ask for a book that’s just 300 pages. Not saying it won’t turn out to be worth it in the end, but dag.
update… The sample chapters are available as HTML now: DHTML Utopia: Modern Web Design Using JavaScript & DOM. I can’t seem to get the example from this chapter to work, though, can you?

All this DHTML stuff is surprisingly fun. And I’ve mentioned before that Javascript has the right policy on Unicode, which makes me pretty happy.

Like this ☞ ☺

Especially considering the headache that is dealing with multibyte stuff in just about every other scripting language. Which makes me kind of sad.

☹ ☜ Like that.

On-the-fly ASCII to Unicode Transliteration with Javascript?

July 2nd, 2005

Here’s an interesting little script I found on the Reta Vortaro (that is, the Esperanto web dictionary).