function parselist()

in content/js/selectnav.js [71:126]


		function parselist(list){

			// go one level down
			level++;
	
			var length = list.children.length,
				html = '',
				prefix = '',
				k = level-1
				;
	
			// return immediately if has no children
			if (!length) return;
		
			if(k) {
				while(k--){
					prefix += indent;
				}
				prefix += " ";
			}
			
			for(var i=0; i < length; i++){	
		
				var link = list.children[i].children[0];
				var text = link.innerText || link.textContent;		
				var isselected = '';
		
				if(activeclass){
					isselected = link.className.search(activeclass) !== -1 || link.parentElement.className.search(activeclass) !== -1 ? selected : '';	
				}
		
				if(autoselect && !isselected){
					isselected = link.href === document.URL ? selected : '';
				}
				
				html += '<option value="' + link.href + '" ' + isselected + '>' + prefix + text +'</option>';
		
				if(nested){
					var subElement = list.children[i].children[1];
					if( subElement && islist(subElement) ){
						html += parselist(subElement);
					}
				}
			}
			
			// adds label
			if(level === 1 && label) html = '<option value="">' + label + '</option>' + html;
		
			// add <select> tag to the top level of the list
			if(level === 1) html = '<select class="selectnav" id="'+id(true)+'">' + html + '</select>';
	
			// go 1 level up
			level--;
	
			return html;
		}