westdc-zf1/htdocs/static-sanji/js/navi.js

27 lines
861 B
JavaScript
Raw Permalink Normal View History

2018-02-04 07:05:06 +00:00
var mainMenu = 'main-menu';
function extractPageName(hrefString) {
var arr = hrefString.split('/');
var result=(arr.length<3) ? hrefString : arr[3].toLowerCase();
if (result === 'search' || 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)
{
arr[i].parentNode.className = "active";
break;
}
}
}
function setPage() {
var hrefString = document.location.href ? document.location.href : document.location;
if (document.getElementById(mainMenu) !== null)
setActiveMenu(document.getElementById(mainMenu).getElementsByTagName("a"), extractPageName(hrefString));
}