# HG changeset patch # User Dan # Date 1226791333 18000 # Node ID 098e744df928663bec8aae1a89b77b704eef35f5 # Parent dd13aa042f34626bacede160eb2a817b73efa7b1 Moved getElementsByClassName to functions.js (dependency issues) diff -r dd13aa042f34 -r 098e744df928 includes/clientside/static/functions.js --- a/includes/clientside/static/functions.js Sat Nov 15 18:21:35 2008 -0500 +++ b/includes/clientside/static/functions.js Sat Nov 15 18:22:13 2008 -0500 @@ -1019,6 +1019,46 @@ return page_id; } +/* + the getElementsByClassName function I pilfered from this guy. It's + a useful function that'll return any/all tags with a specific css class. + + Written by Jonathan Snook, http://www.snook.ca/jonathan + Add-ons by Robert Nyman, http://www.robertnyman.com + + Modified to match all elements that match the class name plus an integer after the name + This is used in Enano to allow sliding sidebar widgets that use their own CSS +*/ +function getElementsByClassName(oElm, strTagName, strClassName) +{ + // first it gets all of the specified tags + var arrElements = (strTagName == "*" && document.all) ? document.all : oElm.getElementsByTagName(strTagName); + + // then it sets up an array that'll hold the results + var arrReturnElements = new Array(); + + // some regex stuff you don't need to worry about + strClassName = strClassName.replace(/\-/g, "\\-"); + + var oRegExp = new RegExp("(^|\\s)" + strClassName + "([0-9]*)(\\s|$)"); + var oElement; + + // now it iterates through the elements it grabbed above + for(var i=0; i