Code:
but I don't get the whole idea of why tool[ev.type] is an array
In JavaScript, objects are
associative arrays.
Code:
var myObject = { "name": "Bob" };
// can be referred to as either
myObject['name'] // or
myObject.name
But functions are also objects and can be assigned as attributes (properties) of an object:
Code:
myObject.func = function () { alert("Hello!") };
var anOther.func = myObject['func'];
anOther.func(); // Hello!
ev is the event object which, I assume, will have the 'type' of onclick, onmouseover, etc.. which is, in turn, a function. So,
triggers the event-handler of this name (handing over the current event object as a parameter).
These are general details - I didn't examine the page in detail.