[ANNOUNCE] London Javascript Night - May 25th
Dominic Mitchell
dom at happygiraffe.net
Thu Apr 27 15:44:18 BST 2006
On Thu, Apr 27, 2006 at 01:37:39PM +0100, Jonathan Peterson wrote:
> > > [0] <http://prototype.conio.net/>
>
> You know, if I'd written an entire library without any single solitary
> comment anywhere in the code*, I probably wouldn't open up my SVN instance
> to prove the fact. But then I'm not version 2.0 of me, so what do I know.
% grep // /usr/local/lib/ruby/gems/1.8/gems/rails-1.1.2/html/javascripts/prototype.js
* For details, see the Prototype web site: http://prototype.conio.net/
// removes whitespace-only text node children
// All *Width and *Height properties give 0 on elements with display none,
// so enable the element temporarily
// Opera returns the offset relative to the positioning context, when an
// element is position relative but top and left have not been defined
// find the first node with the given tagName, starting from the
// node the event was triggered on; traverses the DOM upwards
// set to true if needed, warning: firefox performance problems
// NOT neeeded for page scrolling, only if draggable contained in
// scrollable elements
// must be called before calling withinIncludingScrolloffset, every time the
// page is scrolled
// caches x/y coordinate pair to use with overlap
// within must be called directly before
// Safari fix
// find page position of source
// find coordinate system to use
// delta [0,0] will do fine with position: fixed elements,
// position:absolute needs offsetParent deltas
// correct by body offsets (fixes Safari)
// set position
// Safari returns margins on body which is incorrect if the child is absolutely
// positioned. For performance reasons, redefine Position.cumulativeOffset for
// KHTML/WebKit only.
There you go, it has *some* comments. Not necessarily /useful/, but
there are some.
> Actually there is a file called HEADER that _only_ contains comments, and
> no code at all. Not sure if that counts. One of the comments in this file
> isn't "This library is full of hacks to make Javascript more like Ruby,
> basically", which is a shame, because that would have been helpful.
>
> Hey ho.
On a slightly more serious note, if you do want documentation, there is
a good page which covers most of Prototype:
http://www.sergiopereira.com/articles/prototype.js.html
FWIW, I've been doing a reasonable amount of work with Prototype in the
last couple of weeks and I haven't found it at all hard. Including
delving into the source where necessary.
> [Goes off to drink more coffee and become grumpier]
>
> J
>
> * By 'code' I mean stuff like:
>
> inspect: function() {
> return "'" + this.replace(/\\/g, '\\\\').replace(/'/g, '\\\'') +
> "'";
> }
Wow. Looks like Perl. I thought he was aiming for Ruby. :-)
> Lesser mortals might have explained WTF is going on there. Perhaps a
> useful comment like:
>
> // Escaping is so badly handled by this raft of technologies that I
> // have to write garbage like this to make stuff work
>
-Dom
More information about the london.pm
mailing list