Post by Peter on Apr 29, 2006 13:36:54 GMT
What this code allows you to do is reorder the proboards menu for admins, members and guests. Not only that, you can also remove items from the menu by leaving it out of the array.
<script type="text/javascript">
<!--
/*
Reorder Menu
Created By Peter
Copyright © 2005 - expertsonline.pixeldepth.net
All Rights Reserved
This code may not be redistributed without express permission from the creator.
This header must stay intact at all times.
*/
// Change the order here
var iStaffMenu = [1, 2, 3, 4, 5, 6, 7, 8];
var iMemberMenu = [1, 2, 3, 4, 5, 6, 7];
var iGuestMenu = [1, 2, 3, 4];
function reorderMenu(){
var menu = new Object();
var iCount = 0, admin = false;
var iCell = document.getElementsByTagName("td");
for(c = 0; c < iCell.length; c ++){
if(iCell.item(c).className == "menubg" && iCell.item(c).firstChild){
iCell.item(c).firstChild.id = "themenu";
var cNodes = iCell.item(c).firstChild.childNodes;
for(n = 0; n < cNodes.length; n ++){
if(cNodes.item(n).nodeType == 1){
menu[++ iCount] = {
mnode: cNodes.item(n)
};
if(cNodes.item(n).href.match(/=admin/)){
admin = true;
}
cNodes.item(n).parentNode.removeChild(cNodes.item(n));
n --;
} else {
cNodes.item(n).parentNode.removeChild(cNodes.item(n));
n --;
}
}
}
}
var nOrder = (admin)? iStaffMenu : ((document.cookie.match(/\buser=\w+/))? iMemberMenu : iGuestMenu);
var theMenu = document.getElementById("themenu");
for(o = 0; o < nOrder.length; o ++){
if(menu[nOrder[o]].mnode){
theMenu.appendChild(menu[nOrder[o]].mnode);
if(o != (nOrder.length - 1)){
theMenu.appendChild(document.createTextNode(" "));
}
}
}
}
reorderMenu();
//-->
</script>
You have 3 arrays...
var iStaffMenu = [1, 2, 3, 4, 5, 6, 7, 8];
var iMemberMenu = [1, 2, 3, 4, 5, 6, 7];
var iGuestMenu = [1, 2, 3, 4];
The variables tell you which is which. All you need to do is reorder the numbers or leave some out. So if I wanted to remove the help button from the menu for admins, then I would change it to this...
var iStaffMenu = [1, 3, 4, 5, 6, 7, 8];
Notice that number 2 is missing?
If I wanted to add the help button onto the end of the menu, I would change it to this...
var iStaffMenu = [1, 3, 4, 5, 6, 7, 8, 2];
Simple
Code goes into your global header.
<script type="text/javascript">
<!--
/*
Reorder Menu
Created By Peter
Copyright © 2005 - expertsonline.pixeldepth.net
All Rights Reserved
This code may not be redistributed without express permission from the creator.
This header must stay intact at all times.
*/
// Change the order here
var iStaffMenu = [1, 2, 3, 4, 5, 6, 7, 8];
var iMemberMenu = [1, 2, 3, 4, 5, 6, 7];
var iGuestMenu = [1, 2, 3, 4];
function reorderMenu(){
var menu = new Object();
var iCount = 0, admin = false;
var iCell = document.getElementsByTagName("td");
for(c = 0; c < iCell.length; c ++){
if(iCell.item(c).className == "menubg" && iCell.item(c).firstChild){
iCell.item(c).firstChild.id = "themenu";
var cNodes = iCell.item(c).firstChild.childNodes;
for(n = 0; n < cNodes.length; n ++){
if(cNodes.item(n).nodeType == 1){
menu[++ iCount] = {
mnode: cNodes.item(n)
};
if(cNodes.item(n).href.match(/=admin/)){
admin = true;
}
cNodes.item(n).parentNode.removeChild(cNodes.item(n));
n --;
} else {
cNodes.item(n).parentNode.removeChild(cNodes.item(n));
n --;
}
}
}
}
var nOrder = (admin)? iStaffMenu : ((document.cookie.match(/\buser=\w+/))? iMemberMenu : iGuestMenu);
var theMenu = document.getElementById("themenu");
for(o = 0; o < nOrder.length; o ++){
if(menu[nOrder[o]].mnode){
theMenu.appendChild(menu[nOrder[o]].mnode);
if(o != (nOrder.length - 1)){
theMenu.appendChild(document.createTextNode(" "));
}
}
}
}
reorderMenu();
//-->
</script>
You have 3 arrays...
var iStaffMenu = [1, 2, 3, 4, 5, 6, 7, 8];
var iMemberMenu = [1, 2, 3, 4, 5, 6, 7];
var iGuestMenu = [1, 2, 3, 4];
The variables tell you which is which. All you need to do is reorder the numbers or leave some out. So if I wanted to remove the help button from the menu for admins, then I would change it to this...
var iStaffMenu = [1, 3, 4, 5, 6, 7, 8];
Notice that number 2 is missing?
If I wanted to add the help button onto the end of the menu, I would change it to this...
var iStaffMenu = [1, 3, 4, 5, 6, 7, 8, 2];
Simple
Code goes into your global header.