Post by BigBoss on Jun 29, 2005 15:55:48 GMT -8
can someone help me out with this code?
<script type="text/javascript">
<!--
/*
Remove moderator rank outside board - global footers
Created by Peter
This code cannot be reposted anywhere other than SSDesigns or ProBoards Support.
This header must stay intact.
*/
// Base image url, so we can add the stars
var imgBase = "1. www.4d5.net/v4images/";
// This is the moderator star
var modStar = "stargreen.gif";
// List all mods and the board id they are moderator of, and rank name
// So like...["peter", "coding", "JS CoDer"]
var iMods = [
["kb", "chat", "Moderator"],
["USERNAME", "BOARD ID", "GROUP"],
["USERNAME", "BOARD ID", "GROUP"]
];
// So we can give them a proper rank, list your ranks
// Works like this...["RANK", POSTS, STARS, "STAR IMAGE"]
var iRanks = [
["Human", 0, 49, "http://www.proboards8.com/v4images/star.gif"],
["Sayain", 99, 50, "http://www.proboards8.com/v4images/star.gif"],
["Super Sayain 1", 249, 100, "http://www.proboards8.com/v4images/star.gif"],
["Super Sayain 2", 399, 250, "http://www.proboards8.com/v4images/star.gif"],
["Super Sayain 3", 999, 400, "http://www.proboards8.com/v4images/star.gif"],
[“Super Sayain 4", 4999, 1000, “http://www.proboards8.com/v4images/star.gif”],
[“You Have No Life”, 10000, 5000, “http://www.proboards8.com/v4images/stargreen.gif”]
];
// No need to edit anything below
var iCell = document.getElementsByTagName("td");
function doRank(posts){
var starObj = {
stars: 0,
starimg: iRanks[0][3]
}
var starFragment = document.createDocumentFragment();
var nSpan = document.createElement("span");
var tBR = document.createElement("br");
if(posts){
var posts = parseInt(posts);
for(r = 0; r < iRanks.length; r ++){
var cloneSpan = nSpan.cloneNode(true);
if(r == (iRanks.length - 1) && posts >= iRanks[r][1]){
cloneSpan.innerHTML = iRanks[r][0];
starFragment.appendChild(cloneSpan);
starFragment.appendChild(tBR);starObj.stars = iRanks[r][2];
starObj.starimg = iRanks[r][3];
} else {
if(posts >= iRanks[r][1] && posts < iRanks[r + 1][1]){
cloneSpan.innerHTML = iRanks[r][0];
starFragment.appendChild(cloneSpan);
starFragment.appendChild(tBR);
starObj.stars = iRanks[r][2];
starObj.starimg = iRanks[r][3];
}
}
}
var starImg = document.createElement("img");
for(s = 1; s <= starObj.stars; s ++){
var starClone = starImg.cloneNode(true);
starClone.src = imgBase + starObj.starimg;
starFragment.appendChild(starClone);
}
}
return starFragment;
}
function stripModRank(obj, posts){
var cellObj = obj;
var brCount = firstbr = 0;
for(n = 0; n < cellObj.childNodes.length; n ++){
if(firstbr == 1){
if(cellObj.childNodes.item(n + 1).nodeType == 1){
if(cellObj.childNodes.item(n + 1).innerHTML.match(new RegExp(">?" + iMods[m][2] + "<?"))){
cellObj.replaceChild(doRank(posts), cellObj.childNodes.item(n + 1));
}
}
}
if(cellObj.childNodes.item(n).nodeValue == iMods[m][2]){
cellObj.replaceChild(doRank(posts), cellObj.childNodes.item(n));
}
if(cellObj.childNodes.item(n).nodeName.toLowerCase() == "img"){
if(cellObj.childNodes.item(n).src.match(new RegExp("\/" + modStar + "$"))){
cellObj.removeChild(cellObj.childNodes.item(n));
n --;
}
}
if(cellObj.childNodes.item(n).nodeName.toLowerCase() == "br"){
if(brCount == 3){
cellObj.removeChild(cellObj.childNodes.item(n));
n --
}
brCount ++;
}
firstbr ++;
}
}
function miniRank(loc){
var iNum = 1;
switch(loc){
case "pmview" :
boardID = true;
iNum = 0;
break;
case "viewprofile" :boardID = true;
iNum = 0;
break;
case "display" :
boardID = boardID;
break;
default :
boardID = false;
}
for(c = 0; c < iCell.length; c ++){
if(iCell.item(c).width == "20%" && iCell.item(c).className.match(/windowbg/) && iCell.item(c).innerHTML.match(/Posts: (\d+(,?\d+)*)/)){
var userPosts = RegExp.$1.replace(/,/g, "");
var userLink = iCell.item(c).getElementsByTagName("a").item(iNum).href;
for(m = 0; m < iMods.length; m ++){
if(boardID != false){
if(boardID != iMods[m][1] || boardID == true){
if(userLink.match(new RegExp("=" + iMods[m][0] + "$"))){
stripModRank(iCell.item(c), userPosts);
}
}
}
}
}
}
}
if(location.href.match(/=(display|pmview|viewprofile)/)){
var curLoc = RegExp.$1;
var boardID = (location.href.match(/board=(\w+)/i))? RegExp.$1 : "";
miniRank(curLoc);
}
//-->
</script>
What this code does is remove the moderator rank outside the board that the user is a moderator of. It will give them a correct rank as well. Pretty simple to change, just read the comments in the top of the script.
(if you need any information let me know)
I tried it out on my board and it didn't work.. i was wondering if i did something wrong
<script type="text/javascript">
<!--
/*
Remove moderator rank outside board - global footers
Created by Peter
This code cannot be reposted anywhere other than SSDesigns or ProBoards Support.
This header must stay intact.
*/
// Base image url, so we can add the stars
var imgBase = "1. www.4d5.net/v4images/";
// This is the moderator star
var modStar = "stargreen.gif";
// List all mods and the board id they are moderator of, and rank name
// So like...["peter", "coding", "JS CoDer"]
var iMods = [
["kb", "chat", "Moderator"],
["USERNAME", "BOARD ID", "GROUP"],
["USERNAME", "BOARD ID", "GROUP"]
];
// So we can give them a proper rank, list your ranks
// Works like this...["RANK", POSTS, STARS, "STAR IMAGE"]
var iRanks = [
["Human", 0, 49, "http://www.proboards8.com/v4images/star.gif"],
["Sayain", 99, 50, "http://www.proboards8.com/v4images/star.gif"],
["Super Sayain 1", 249, 100, "http://www.proboards8.com/v4images/star.gif"],
["Super Sayain 2", 399, 250, "http://www.proboards8.com/v4images/star.gif"],
["Super Sayain 3", 999, 400, "http://www.proboards8.com/v4images/star.gif"],
[“Super Sayain 4", 4999, 1000, “http://www.proboards8.com/v4images/star.gif”],
[“You Have No Life”, 10000, 5000, “http://www.proboards8.com/v4images/stargreen.gif”]
];
// No need to edit anything below
var iCell = document.getElementsByTagName("td");
function doRank(posts){
var starObj = {
stars: 0,
starimg: iRanks[0][3]
}
var starFragment = document.createDocumentFragment();
var nSpan = document.createElement("span");
var tBR = document.createElement("br");
if(posts){
var posts = parseInt(posts);
for(r = 0; r < iRanks.length; r ++){
var cloneSpan = nSpan.cloneNode(true);
if(r == (iRanks.length - 1) && posts >= iRanks[r][1]){
cloneSpan.innerHTML = iRanks[r][0];
starFragment.appendChild(cloneSpan);
starFragment.appendChild(tBR);starObj.stars = iRanks[r][2];
starObj.starimg = iRanks[r][3];
} else {
if(posts >= iRanks[r][1] && posts < iRanks[r + 1][1]){
cloneSpan.innerHTML = iRanks[r][0];
starFragment.appendChild(cloneSpan);
starFragment.appendChild(tBR);
starObj.stars = iRanks[r][2];
starObj.starimg = iRanks[r][3];
}
}
}
var starImg = document.createElement("img");
for(s = 1; s <= starObj.stars; s ++){
var starClone = starImg.cloneNode(true);
starClone.src = imgBase + starObj.starimg;
starFragment.appendChild(starClone);
}
}
return starFragment;
}
function stripModRank(obj, posts){
var cellObj = obj;
var brCount = firstbr = 0;
for(n = 0; n < cellObj.childNodes.length; n ++){
if(firstbr == 1){
if(cellObj.childNodes.item(n + 1).nodeType == 1){
if(cellObj.childNodes.item(n + 1).innerHTML.match(new RegExp(">?" + iMods[m][2] + "<?"))){
cellObj.replaceChild(doRank(posts), cellObj.childNodes.item(n + 1));
}
}
}
if(cellObj.childNodes.item(n).nodeValue == iMods[m][2]){
cellObj.replaceChild(doRank(posts), cellObj.childNodes.item(n));
}
if(cellObj.childNodes.item(n).nodeName.toLowerCase() == "img"){
if(cellObj.childNodes.item(n).src.match(new RegExp("\/" + modStar + "$"))){
cellObj.removeChild(cellObj.childNodes.item(n));
n --;
}
}
if(cellObj.childNodes.item(n).nodeName.toLowerCase() == "br"){
if(brCount == 3){
cellObj.removeChild(cellObj.childNodes.item(n));
n --
}
brCount ++;
}
firstbr ++;
}
}
function miniRank(loc){
var iNum = 1;
switch(loc){
case "pmview" :
boardID = true;
iNum = 0;
break;
case "viewprofile" :boardID = true;
iNum = 0;
break;
case "display" :
boardID = boardID;
break;
default :
boardID = false;
}
for(c = 0; c < iCell.length; c ++){
if(iCell.item(c).width == "20%" && iCell.item(c).className.match(/windowbg/) && iCell.item(c).innerHTML.match(/Posts: (\d+(,?\d+)*)/)){
var userPosts = RegExp.$1.replace(/,/g, "");
var userLink = iCell.item(c).getElementsByTagName("a").item(iNum).href;
for(m = 0; m < iMods.length; m ++){
if(boardID != false){
if(boardID != iMods[m][1] || boardID == true){
if(userLink.match(new RegExp("=" + iMods[m][0] + "$"))){
stripModRank(iCell.item(c), userPosts);
}
}
}
}
}
}
}
if(location.href.match(/=(display|pmview|viewprofile)/)){
var curLoc = RegExp.$1;
var boardID = (location.href.match(/board=(\w+)/i))? RegExp.$1 : "";
miniRank(curLoc);
}
//-->
</script>
What this code does is remove the moderator rank outside the board that the user is a moderator of. It will give them a correct rank as well. Pretty simple to change, just read the comments in the top of the script.
(if you need any information let me know)
I tried it out on my board and it didn't work.. i was wondering if i did something wrong