westdc-zf1/htdocs/js/navi.js

31 lines
1.1 KiB
JavaScript
Executable File

function extractPageName(hrefString)
{
var arr = hrefString.split('/');
var result=(arr.length<3) ? hrefString : arr[3].toLowerCase();
if (result=='water' || result=='heihe' || result=='glacier' || result=='yrnmr' || result=='hiwater') result='data';
if (result=='admin' && arr.length>=4) result+="/"+arr[4];
return result;
}
function setActiveMenu(arr, crtPage)
{
for (var i=0; i<arr.length; i++)
{
if(extractPageName(arr[i].href) == crtPage)
{
if (arr[i].parentNode.tagName != "DIV")
{
arr[i].className = "active";
arr[i].parentNode.className = "active";
}
}
}
}
function setPage()
{
hrefString = document.location.href ? document.location.href : document.location;
if (document.getElementById("mainmenu")!=null)
setActiveMenu(document.getElementById("mainmenu").getElementsByTagName("a"), extractPageName(hrefString));
}