Browse by Month RSS Feed
  • September 2010
  • August 2010
  • July 2010
  • May 2010
  • April 2010
  • March 2010

  • Filed under: Code, JavaScript @ 1:41 pm

    Touted as the "Ultimate getElementsByClassName" function, this helpful little function does exactly what you'd expect it to, plugging the rather conspicuous gap in Javascript's built-in functions. Written by Jonathan Snook.

    /*
        Written by Jonathan Snook, http://www.snook.ca/jonathan
        Add-ons by Robert Nyman, http://www.robertnyman.com
    */

    function getElementsByClassName(oElm, strTagName, strClassName){
      var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
        var arrReturnElements = new Array();
        strClassName = strClassName.replace(/\-/g, "\\-");
        var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
        var oElement;
        for(var i=0; i<arrElements.length; i++){
            oElement = arrElements[i];     
            if(oRegExp.test(oElement.className)){
                arrReturnElements.push(oElement);
            }   
        }
        return (arrReturnElements)
    }

    Comments (0)


    Life, WorkOctober 30, 2006
    Filed under: Life, Software @ 8:57 pm

    I just had the pleasure of doing a small job for the United Palestinian Appeal, Inc. as the end client, rigging up my form emailer script for their online donation form. I'm very glad I got the opportunity - partly because it's such a worthy cause and partly because it led me to find a small bug in the script...!

    On another subject, I spent a good chunk of the weekend working on a new website: probonomap.bc.ca (I won't link to it until it goes live; right now it's pretty rough). This new site is a Google Maps-driven site, which is kind of a continuation of another job I recently completed: probononet.bc.ca. With probonomaps, organizations register with the system, adding location information, services offered, contact information etc., and then site visitors can search and browse those organizations operating in their community. Cool stuff.

    This is my first opportunity to work with Google Maps and wow, Google's API and documentation is SUPERB. It's an absolute delight to work with. Their class library is as clear as day; the classes and methods are intuitively named, consistent and functional. It's sodding wonderful.

    Good grief, I just re-read that last paragraph. What a nerd.

    Comments (0)


    10,000 hits!October 28, 2006
    Filed under: Form Tools @ 10:37 am

    Form Tools reached 10,000 hits from Hotscripts today! Links from Hotscripts and other sites translate to around 9,000 downloads of the software to date. Although this isn't strictly the best indication of the number of users (this figure includes upgrades), it's still a very nice bar to have reached. Next stop, 100,000...!

    Comments (0)


    Filed under: Software @ 6:58 pm

    Not that I'll be working on any of these any time in the near future, but here's a list of Image Scroller feature requests.

    • Vertical scrolling!
    • Option for default target URL (not have to define it per item)
    • Additional text field(s)
    • Optional background image (URL)
    • Smoother (slow-quick-slow) scrolling option
    • Option for grayscaling out all but currently moused-over image
    • Option for colour band around currently moused-over image
    • More control over padding around elements (left & right)
    Comments (45)


    Filed under: Code, PHP @ 10:18 pm

    This is an old function I wrote a bazillion years ago for calculating the dimensions of an image (aspect-ratio-preserved) that would fit within a fixed-size box (specified by $max_width, $max_height). Still useful.

    /*----------------------------------------------------------------------------*\
      Function:    get_thumb_dimensions
      Description: examines an image and calculates thumbnail dimensions for it, based
                       on the max width and height dimensions passed in as parameters.
                       Returns an array containing the width [0] and height [1]
      Parameters: $image      - the image name and path
                       $max_width  - the max width of the thumbnail
                       $max_height - the max height of the thumbnail
    \*----------------------------------------------------------------------------*/

    function get_thumb_dimensions($image_path, $max_width, $max_height)
    {
      // find the images dimensions
      $image_dimensions = getImageSize($image_path);
      $image_width      = $image_dimensions[0];
      $image_height     = $image_dimensions[1];

      // default the thumbnail dimensions to the maximum values
      $thumb_height = $max_height;
      $thumb_width  = $max_width;

      // assume image width>= height
      $scaling_ratio = $image_width / $max_width;

      // compare the scaled height with the maximum thumb height. If it's bigger,
      // we need to find a new scaling ratio
      if (($image_height / $scaling_ratio) > $max_height)
      {
        $scaling_ratio = $image_height / $max_height;
        $thumb_width = $image_width / (float) $scaling_ratio;
      }
      else
        $thumb_height = $image_height / (float) $scaling_ratio;

      // now return the dimensions
      $thumb_dimensions = array($thumb_width, $thumb_height);

      return $thumb_dimensions;
    }

    Comments (0)


    Filed under: Software @ 9:30 pm

    Just a minor update to the Flash Image Scroller: I added a new maxNumItems option which lets you limit the number of items displayed from the incoming feed. This should be a helpful option for those of you using the program to syndicate content from feeds containing more items than you'd care to display.

    Comments (0)

    Next Page »