#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    Hudson, WI
    Posts
    2
    Rep Power
    0

    DollarDollarParen ?


    If I remember correctly, the dollar sign in "$(..." simply serves as the program name so that you can easily rename the program without having to change all of the named occurrences, and that changing all of the $( to nameofprogram( will still allow the program to work. Right?

    If so, then what is dollar-dollar-( "$$(" for? See it in code about 2/3rds down.

    RLS


    REQUIRED_PROTOTYPE: '1.6.0.3',
    load: function() {
    function convertVersionString(versionString) {
    var v = versionString.replace(/_.*|\./g, '');
    v = parseInt(v + '0'.times(4-v.length));
    return versionString.indexOf('_') > -1 ? v-1 : v;
    }

    if((typeof Prototype=='undefined') ||
    (typeof Element == 'undefined') ||
    (typeof Element.Methods=='undefined') ||
    (convertVersionString(Prototype.Version) <
    convertVersionString(Scriptaculous.REQUIRED_PROTOT YPE)))
    throw("script.aculo.us requires the Prototype JavaScript framework >= " +
    Scriptaculous.REQUIRED_PROTOTYPE);

    var js = /scriptaculous\.js(\?.*)?$/;
    $$('script[src]').findAll(function(s) {
    return s.src.match(js);
    }).each(function(s) {
    var path = s.src.replace(js, ''),
    includes = s.src.match(/\?.*load=([a-z,]*)/);
    (includes ? includes[1] : 'builder,effects,dragdrop,controls,slider,sound'). split(',').each(
    function(include) { Scriptaculous.require(path+include+'.js') });
    });
  2. #2
  3. c0der
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2005
    Location
    Vancouver
    Posts
    664
    Rep Power
    159
    $$ is a function defined in Prototype, which script.ac.u.ou...s (not sure if I got the dots right) depends on. Here's the function's definition:

    Code:
    window.$$ = function() {
      var expression = $A(arguments).join(', ');
      return Prototype.Selector.select(expression, document);
    };
    What that's doing is passing a list of CSS selectors to Prototype's "select" function. I could explain what exactly I mean by that but pointing to the docs is probably easier.

    In the code you posted, the "dollar-dollar" function is returning a list of all script elements that have a src attribute.

    Comments on this post

    • randylsmith agrees
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    Hudson, WI
    Posts
    2
    Rep Power
    0
    Awesome response, Mr. Taylor. Thank you!
    RLS

IMN logo majestic logo threadwatch logo seochat tools logo