129
Mary had a cool boombox
The loudest in the town
And everywhere that Mary went
They said to turn it down
Mary had a cool boombox
The loudest in the town
And everywhere that Mary went
They said to turn it down
Oh and I almost forgot! Today we learned that the period of a pulsar is 1.337 seconds. That 1337E-3, not very 1337 at all really.
There are loads of prototype tutorials out in the wild. I couln’t find a suitable one for this though.
The Problem:
~~~~~~~~~
I had a bulleted-list of links which needed 3 javascript event handlers: onclick, onmouseover and onmouseout.
I beleive firmly in the separation of design, content and behaviour and dislike proprietry triggers. So I could not simply do this:
<a onclick="somefunc">Link text</a>
Or
<a linkevents="true">Link text</a>
Instead I used the title and class attributes which were already in place. Shown here:
<ul id="navlist"> <li><a href="About%20Whaletattoo....htm" id="nav1" class="navlink" title="About Whaletattoo...">About Whaletattoo...</a></li> <li><a href="Web%20Design.htm" id="nav2" class="navlink" title="Web Design">Web Design</a></li> </ul>
This shows a small excerpt of regular html links, no javascript yet. Each link has the class “navlink”. The title is the suffix “nav” followed by an incremented number. (We have to preceed the number with alphabetic characters according to the xhtml spec.)
To attach the handlers we can do the following:
Event.observe(window, 'load', addListeners, false); function addListeners(){ var navList = document.getElementsByClassName("navlink"); for (key in navList) { Event.observe(navList[key], 'click', function(e){ loadPage(Event.element(e).id.substring(3)); Event.stop(e); }, true); Event.observe(navList[key], 'mouseover', function(e){ doMouseOver(Event.element(e).title); Event.stop(e); }, true); Event.observe(navList[key], 'mouseout', function(e){ undoMouseOver(); Event.stop(e); }, true); } }
The first line specifies to run addListeners when the page loads.
An array called navList is created and populated by prototypes getElementsByClassName with all the links we wrote out earlier.
“For” iterates the items and attaches three functions to them: loadPage, doMouseOver and undoMouseOver. To pass the title to the receiving function we can use prototypes “Event.element(e)” and specify “.title”. To return the numeric value of the link we need to prune away the “nav” that we added: “Event.element(e).id.substring(3)”.
Next we need to prevent the default action from taking place. Prototype supplies the wherewithall for this too: “Event.stop(e)”.
The last argument is just a personal preference of mine, as true it specifies that we wish to use event capturing. Unless you need to this is probably safest as uncaptured events can trigger handlers higher in the chain and cause unexpedted results.
Tested in IE6 and FFx. Hope this helps someone.
So I killed my internet.
Needed to open a port in my firewall, but some twat, probably me, had changed the password on the router/firewall/nat thing.
Found a site which recommended a hard reset; “Fine” thinks I, and does as advised. Only upon reboot it has forgotten all the connection details.
Original documentation nowhere to be found.
The internet, my normal first port of call when seeking help, is, of course, down.
Cue me sitting in a queue to talk to a BT operator for approx 4 hours…
Not amused.
On a lighter note I’ve been offered a place at Sussex to do Cognitive Neuroscience. All they want is 2 As and a B…
AOL are planning to allow mass-mailers pay to bypass their spam filters: The Register: AOL email tax
Surely this will only appeal to spammers, unless they are admitting faults in their filter system…
And what about charities? How will they afford to email donors now? How will not-for-profit organisations, mailing lists or clubs get email to their users?
What will the threshold for ‘mass-mail’ be? If I send an email to 10 AOL users will it block me?
This is leading to privitisation of email and encroaches on the free nature of the internet.
I told you AOL was evil.