includes/clientside/static/functions.js
changeset 740 098e744df928
parent 727 591562495e87
child 779 609e35845ec3
equal deleted inserted replaced
739:dd13aa042f34 740:098e744df928
  1017   }
  1017   }
  1018   
  1018   
  1019   return page_id;
  1019   return page_id;
  1020 }
  1020 }
  1021 
  1021 
       
  1022 /*
       
  1023     the getElementsByClassName function I pilfered from this guy.  It's
       
  1024     a useful function that'll return any/all tags with a specific css class.
       
  1025 
       
  1026     Written by Jonathan Snook, http://www.snook.ca/jonathan
       
  1027     Add-ons by Robert Nyman, http://www.robertnyman.com
       
  1028     
       
  1029     Modified to match all elements that match the class name plus an integer after the name
       
  1030     This is used in Enano to allow sliding sidebar widgets that use their own CSS
       
  1031 */
       
  1032 function getElementsByClassName(oElm, strTagName, strClassName)
       
  1033 {
       
  1034     // first it gets all of the specified tags
       
  1035     var arrElements = (strTagName == "*" && document.all) ? document.all : oElm.getElementsByTagName(strTagName);
       
  1036     
       
  1037     // then it sets up an array that'll hold the results
       
  1038     var arrReturnElements = new Array();
       
  1039 
       
  1040     // some regex stuff you don't need to worry about
       
  1041     strClassName = strClassName.replace(/\-/g, "\\-");
       
  1042 
       
  1043     var oRegExp = new RegExp("(^|\\s)" + strClassName + "([0-9]*)(\\s|$)");
       
  1044     var oElement;
       
  1045     
       
  1046     // now it iterates through the elements it grabbed above
       
  1047     for(var i=0; i<arrElements.length; i++)
       
  1048     {
       
  1049         oElement = arrElements[i];
       
  1050 
       
  1051         // if the class matches what we're looking for it ads to the results array
       
  1052         if(oElement.className.match(oRegExp))
       
  1053         {
       
  1054             arrReturnElements.push(oElement);
       
  1055         }
       
  1056     }
       
  1057 
       
  1058     // then it kicks the results back to us
       
  1059     return (arrReturnElements)
       
  1060 }
       
  1061 
  1022 /**
  1062 /**
  1023  * Equivalent to PHP's in_array function.
  1063  * Equivalent to PHP's in_array function.
  1024  */
  1064  */
  1025 
  1065 
  1026 function in_array(needle, haystack)
  1066 function in_array(needle, haystack)