Before going in to work today I have managed to fix one of the
JavaScript problems (it causes MSIE to report ‘one error
on page’), but only half-fixed the other (which causes
artists’ names with links to vanish when you cycle through
the panels). In the latter case, the name no longer vanishes,
but, alas! the link does.
I think need a JavaScript
debugger—in other words, to install Mozilla on my
PowerBook (the only computer I own with enough welly for
Mozilla). Ho hum.
I have added JavaScript to the upload form Picky Picky Game on
caption.org to optionally remember your details for next
time (using a cookie). This way you don’t have to enter
your URL each time you upload a new panel.
Debugging JavaScript without a JavaScript debugger is a real
pain in the arse, and illustrates how subtle aspects of language
design affect the experience of working in that language. There
is one crucial difference between Python and JavaScript. In
Python, a variable is implicitly created the first time you
assign to it; in JavaScript, it is created the first time you
refer to it. This means that the following fragment is valid
JavaScript:
var cookieHeader = this.$document.cookie;
var m = myRegexp.exec(cookiesHeader);
if (m) {
... use the match info to process the cookies ...
}
The equivalent Python looks like this:
cookieHeader = self._document.cookie
m = myRegexp.search(cookiesHeader)
if m:
... use the match info to process the cookies ...
In the JavaScript version, the regexp (used to extract one
cookie from the Cookies
header) will mysteriously never match
and you will spend ages scrutinizing the regexp and flipping
though the documentation on what is and is not valid regexp
syntax in JavaScript. In Python you will get an error message
telling you that the variable cookiesHeader
is
referred to before it is assigned to—and immediately
realise its name is misspelled in the second line.
The tedious thing about testing the ‘remember me’
option is that it involves repeatedly doing the very thing it is
supposed to be saving me from: entering my URL and details
on the picture-upload form. Luckily I was testing on Safari,
which has a form auto-completion feature that makes repeatedly
filling in the form less annoying—but which also makes the
‘Remember me’ feature almost entirely redundant
;-)
The image-cycling feature of the
Picky Picky Game
prototype depends on using JavaScript to load images. If
you click on the Cycle button before the images have been
prloaded, then nothing visible happens—it appears to have
failed. There is no way for the user to see whether the images
have loaded or not. I have attempted to add such an indication,
only to be thwarted by what appear to be bugs in the web
browsers I have tried it on.
Read more