Chickenfoot for Firefox: Rewrite the Web

User Interface Design Group

Library: prototype.js

Prototype is "a JavaScript framework that aims to ease development of dynamic web applications." It serves as the basic for both the and Rico AJAX libraries.

The prototype.js file included with Chickenfoot is nearly identical to the one available on the web site, but it has one important tweak that improves its integration with Chickenfoot:

function $() {
  var results = [], element;
  for (var i = 0; i < arguments.length; i++) {
    element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    // added for better Chickenfoot integration
    else if (Chickenfoot.instanceOf(element, Chickenfoot.Match))
      element = element.element;

  return results.length < 2 ? results[0] : results;
Although $() was designed as a convenient shorthand for getElementById(), we have amended it so it can convert a Chickenfoot Match into an Element as well. This is helpful because this enables all of the functions that depend on $() to accept a Match. See the description of scriptaculous.js for more details.

©2004-2006 Massachusetts Institute of Technology