PhpGedView PHP Cross Reference Learning Management Systems

Source: /places/modomt.js - 199 lines - 3984 bytes - Summary - Text - Print

   1  /**

   2   * @version $Id: modomt.js 4193 2008-10-30 10:31:10Z fisharebest $

   3   * @author http://momche.net

   4   */
   5  
   6  //

   7  //  This script was created

   8  //  by Mircho Mirev

   9  //  mo /mo@momche.net/

  10  //    Copyright (c) 2004 Mircho Mirev

  11  //

  12  //    :: feel free to use it BUT

  13  //    :: if you want to use this code PLEASE send me a note

  14  //    :: and please keep this disclaimer intact

  15  //

  16  
  17  function getSubNodeByName( hNode, sNodeName )
  18  {
  19      if( hNode != null )
  20      {
  21          var nNc = 0
  22          var nC    = 0
  23          var hNodeChildren = hNode.childNodes
  24          var hCNode = null
  25          while( nC < hNodeChildren.length )
  26          {
  27              hCNode = hNodeChildren.item( nC++ )
  28              if( ( hCNode.nodeType == 1 ) && ( hCNode.nodeName.toLowerCase() == sNodeName ) )
  29              {
  30                  return hCNode
  31              }
  32          }
  33      }
  34      return null
  35  }
  36  
  37  function getPrevNodeSibling( hNode )
  38  {
  39      if( hNode != null )
  40      {
  41          do {
  42              hNode = hNode.previousSibling
  43          } while( hNode != null && hNode.nodeType != 1 )
  44          return hNode
  45      }
  46  }
  47  
  48  function getNextNodeSibling( hNode )
  49  {
  50      if( hNode != null )
  51      {
  52          do {
  53              hNode = hNode.nextSibling
  54          } while( hNode != null && hNode.nodeType != 1 )
  55          return hNode
  56      }
  57  }
  58  
  59  function getLastSubNodeByName( hNode, sNodeName )
  60  {
  61      if( hNode != null )
  62      {
  63          var nNc = 0
  64          var nC    = 0
  65          var hNodeChildren = hNode.childNodes
  66          var hCNode = null
  67          var nLength = hNodeChildren.length - 1
  68          while( nLength >=0  )
  69          {
  70              hCNode = hNodeChildren.item( nLength )
  71              if( ( hCNode.nodeType == 1 ) && ( hCNode.nodeName.toLowerCase() == sNodeName ) )
  72              {
  73                  return hCNode
  74              }
  75              nLength--
  76          }
  77      }
  78      return null
  79  }
  80  
  81  function findAttribute( hNode, sAtt )
  82  {
  83      sAtt = sAtt.toLowerCase()
  84      for( var nI = 0; nI < hNode.attributes.length; nI++ )
  85      {
  86          if( hNode.attributes[ nI ].nodeName.toLowerCase() == sAtt )
  87          {
  88              return hNode.attributes[ nI ].nodeValue
  89          }
  90      }
  91      return null
  92  }
  93  
  94  function getSubNodeByAttribute( hNode, sAtt, sAttValue )
  95  {
  96      if( hNode != null )
  97      {
  98          var nNc = 0
  99          var nC    = 0
 100          var hNodeChildren = hNode.childNodes
 101          var hCNode = null
 102          while( nC < hNodeChildren.length )
 103          {
 104              hCNode = hNodeChildren.item( nC++ )
 105              if( ( hCNode.nodeType == 1 ) && ( findAttribute( hCNode, sAtt ).toLowerCase() == sAttValue ) )
 106              {
 107                  return hCNode
 108              }
 109              nNc++
 110          }
 111      }
 112      return null
 113  }
 114  
 115  function getLastSubNodeByAttribute( hNode, sAtt, sAttValue )
 116  {
 117      if( hNode != null )
 118      {
 119          var nNc = 0
 120          var nC    = 0
 121          var hNodeChildren = hNode.childNodes
 122          var hCNode = null
 123          var nLength = hNodeChildren.length - 1
 124          while( nLength >= 0 )
 125          {
 126              hCNode = hNodeChildren.item( nLength )
 127              if( ( hCNode.nodeType == 1 ) && ( findAttribute( hCNode, sAtt ).toLowerCase() == sAttValue ) )
 128              {
 129                  return hCNode
 130              }
 131              nLength--
 132          }
 133      }
 134      return null
 135  }
 136  
 137  function getParentByTagName( hNode, sParentTagName )
 138  {
 139      while( ( hNode.tagName ) && !( /(body|html)/i.test( hNode.tagName ) ) )
 140      {
 141          if( hNode.tagName == sParentTagName )
 142          {
 143              return hNode
 144          }
 145          hNode = hNode.parentNode
 146      }
 147      return null
 148  }
 149  
 150  function getParentByAttribute( hNode, sAtt, sAttValue )
 151  {
 152      while( ( hNode.tagName ) && !( /(body|html)/i.test( hNode.tagName ) ) )
 153      {
 154          //opera strangely returns non null result sometimes

 155          var sAttr = hNode.getAttribute( sAtt )
 156          if( sAttr != null && sAttr.toString().length > 0 )
 157          {
 158              if( sAttValue !== null )
 159              {
 160                  if( sAttr == sAttValue )
 161                  {
 162                      return hNode
 163                  }
 164              }
 165              else
 166              {
 167                  return hNode
 168              }
 169          }
 170          hNode = hNode.parentNode
 171      }
 172      return null
 173  }
 174  
 175  function getParentByProperty( hNode, sProperty, sPropValue )
 176  {
 177      while( ( hNode.tagName ) && !( /(body|html)/i.test( hNode.tagName ) ) )
 178      {
 179          //opera strangely returns non null result sometimes

 180          var hProp = eval( 'hNode.'+sProperty )
 181          if( hProp != null && hProp.toString().length > 0 )
 182          {
 183              if( sPropValue !== null )
 184              {
 185                  if( hProp == sPropValue )
 186                  {
 187                      return hNode
 188                  }
 189              }
 190              else
 191              {
 192                  return hNode
 193              }
 194          }
 195          hNode = hNode.parentNode
 196      }
 197      return null
 198  }
 199  

title

Description

title

Description

title

Description

title

title

Body