User:Lhridley/vector.js

function getElementsByClass(searchClass,node,tag) { var classElements = new Array; if ( node == null ) node = document; if ( tag == null ) tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)'); for (i = 0, j = 0; i < elsLen; i++) { if ( pattern.test(els[i].className) ) { classElements[j] = els[i]; j++; }	}	return classElements; }

function setRowNumber { var tableName; var skipRows;   // don't number header rows tableName = getElementsByClass('numberedTable'); alert(tableName.length); skipRows = 0; var row = tableName.rows[0]; var cell = row.insertCell(0); cell.innerHTML = ''; cell.innerText = ''; for( rowNbr=skipRows+1; rowNbr < tableName.rows.length ; rowNbr++) {    var cell = tableName.rows[rowNbr]; var cell = cell.insertCell(0); var cell = tableName.rows[rowNbr].cells[0]; var rowNbrText = rowNbr - skipRows; cell.innerHTML = rowNbrText; cell.innerText = rowNbrText; } }

function setRowNo{ var tableName; var skipRows;   // don't number header rows tableName = document.getElementById('numberedTable'); skipRows = 0; var row = tableName.rows[0]; var cell = row.insertCell(0); cell.innerHTML = ''; cell.innerText = ''; for( rowNbr=skipRows+1; rowNbr < tableName.rows.length ; rowNbr++) {    var cell = tableName.rows[rowNbr]; var cell = cell.insertCell(0); var cell = tableName.rows[rowNbr].cells[0]; var rowNbrText = rowNbr - skipRows; cell.innerHTML = rowNbrText; cell.innerText = rowNbrText; } }

function runOnLoad { setRowNo; setRowNumber; } addOnloadHook( runOnLoad );