OK, so a different standard from the one we usually talk about I have this page http://positionrelative.com/snippets/jstest.htm
Now if you visit the site you should see a huge list of suburbs, to which I am adding some letter headers for each letter. Sounds simple enough except that it takes far too long for the JS to work, and I'm stuck as to how to improve it.
My js function is
function recurseNodes(aNodes) {
for (var i=0; i<aNodes.length; i++) {
if (aNodes[i].nodeType == 1) {
if (aNodes[i].tagName.toLowerCase() == "label") {
//label found
//get first character
var c = aNodes[i].innerHTML.charAt(0);
if (c != currentLetter) {
//insert node for for new letter heading
var newNode = document.createElement("h2");
newNode.innerHTML = c.toUpperCase();
aNodes[i].parentNode.parentNode.insertBefore(newNode, aNodes[i].parentNode);
//for safari
//var newNode2 = document.createElement("a");
//newNode2.setAttribute("name", sPrefix + c.toLowerCase());
//aNodes[i].parentNode.parentNode.insertBefore(newNode, aNodes[i].parentNode);
//set current letter
currentLetter = c;
}
}
//recurse
if (aNodes[i].hasChildNodes) {
recurseNodes(aNodes[i].childNodes);
}
}
}
}
The safari bit was for another additional function which has now been curtailed (I have very much the moving goalposts on this one!)
If anyone could think of a better way to do this, or even an efficiency tweak I would be very grateful.
p.s. this page is just a snippet so may be a little messy...apologies
thanks
scottbp
*****************************************************
The discussion list for http://webstandardsgroup.org/
*****************************************************
