Post by GamerChick on Sept 24, 2009 5:51:15 GMT -8
Brianne, welcome as the new admin. I understand that I am every admins worst nightmare... I promise to be less so. Maybe down-graded to just a vague feeling of being unsettled?
In your BBRPG thread you have a member requesting to upload a third party die roller. Though you may know and like this member, the answer should be "no" because ProBoards already has an official add-on for rolling dice and has since 2005. And because, as my daughter-in-law, said member should know better than to ask about third party code uploads.
--Gille
Basic Source Code
support.proboards.com/index.cgi?board=codedatabase&action=display&n=1&thread=70421
Member "Wonder" writes:
Dice Rolls In Posts v1.1 [CB]
« Thread Started on Nov 3, 2005, 2:25am »
--------------------------------------------------------------------------------
This script will add this icon or the icon of your choosing to your post page. When clicked, a dice roll will be added to the message in the following format:
[dice=X] or [dice=X+Y]
Where X is any number indicating the number of sides of the dice and Y is a number added to the dice roll. When posted, a random dice roll will appear where the dice ubbc code was. It will look something like this: (image)
This dice roll will appear the exact same to every member. No member can modify their dice roll, it will always be the same as long as the number of sides do not change and the ubbc code is in the message. You can have up to around 60 dice in a post before you get an error. This code will work with regular posts, PMs, and Quick Reply. It will not work properly in signatures, personal text, or anything other than a post/PM. Please do NOT PM me for support or requests, that's what the coding boards are for. Edit where indicated in the script and you can modify the style sheet if you really want to. Enjoy.
Put script in Global Footer if you want every board to have dice rolls as well as PMs or Footer of board you want dice rolls in.
Code for base is:
But wait! You may want more. For instance, the ability to have the dice icons stack horizontally instead of vertically (or more likely) the ability to roll modifiers on your d20 babies. For that you'll need this sweet meat:
Alternate Source Code to allow horizontal alignment and modifiers:
In your BBRPG thread you have a member requesting to upload a third party die roller. Though you may know and like this member, the answer should be "no" because ProBoards already has an official add-on for rolling dice and has since 2005. And because, as my daughter-in-law, said member should know better than to ask about third party code uploads.
--Gille
Basic Source Code
support.proboards.com/index.cgi?board=codedatabase&action=display&n=1&thread=70421
Member "Wonder" writes:
Dice Rolls In Posts v1.1 [CB]
« Thread Started on Nov 3, 2005, 2:25am »
--------------------------------------------------------------------------------
This script will add this icon or the icon of your choosing to your post page. When clicked, a dice roll will be added to the message in the following format:
[dice=X] or [dice=X+Y]
Where X is any number indicating the number of sides of the dice and Y is a number added to the dice roll. When posted, a random dice roll will appear where the dice ubbc code was. It will look something like this: (image)
This dice roll will appear the exact same to every member. No member can modify their dice roll, it will always be the same as long as the number of sides do not change and the ubbc code is in the message. You can have up to around 60 dice in a post before you get an error. This code will work with regular posts, PMs, and Quick Reply. It will not work properly in signatures, personal text, or anything other than a post/PM. Please do NOT PM me for support or requests, that's what the coding boards are for. Edit where indicated in the script and you can modify the style sheet if you really want to. Enjoy.
Put script in Global Footer if you want every board to have dice rolls as well as PMs or Footer of board you want dice rolls in.
Code for base is:
<style type="text/css">
.dicebg {background-color: FFFFFF;border:solid 2px #000000;}
.dicefont {background-color: FFFFFF;color: 000000; font-weight:bold;}
</style>
<script>
//Dice Rolls In Posts v1.1
//Copyright 4-23-2007 ~Wonder
//May be reposted anywhere as long as this header remains in tact
//Do you want the dice to line of horizontally(true) or vertically(false)
diceAlignment=true;
//Enter URL of the image you want to appear as the dice ubbc button
UBBCdiceImage="http://img100.imageshack.us/img100/6118/diceicon9rx.gif";
//Enter the default # of sides
defaultSides=6;
//Enable dice in preview? true or false
enablePreview=true;
rs="";mainForm="";
if(document.postForm)
{
mainForm=document.postForm;
if(location.href.match(/action\=modifypost/)){enablePreview=true;}
mainForm.color.parentNode.innerHTML+="<a href=javascript:add(\"[dice="+defaultSides+"]\",\"\")><img src=\""+UBBCdiceImage+"\" alt=\"Insert Dice Roll\" border=\"0\"></a>";
mainForm.onsubmit=addRand;
mainForm.message.value=mainForm.message.value.replace(/(\[rand\=\d+\])/ig,"");
rs=RegExp.$1; rs=(/\[rand\=/.test(rs))?rs:"";
if(location.href.match(/quote\=\d+/))
{
mainForm.message.value=mainForm.message.value.replace(/(\[dice\=\d+\])/ig,"");
rs="";
}
}
else if(location.href.match(/action\=display/))
{
ta=document.getElementsByTagName("textarea");
if(ta.length>0 && ta[0].name=="message")
{
mainForm=ta[0].parentNode;
mainForm.onsubmit=addRand;
}
}
///////////////////////
if(location.href.match(/action\=(display|pmview|recent|userrecentposts|gotopost|search|calendarview)/) || (!location.href.match(/action\=/) && document.postForm && enablePreview))
{
hr=document.getElementsByTagName("hr");
for(i=0;i<hr.length;i++)
{
if(typeof(hr[i].parentNode)!="undefined" && hr[i].parentNode.tagName=="TD" && typeof(hr[i].parentNode.lastChild)!="undefined" && typeof(hr[i].parentNode.lastChild.lastChild)!="undefined" && hr[i].parentNode.lastChild.lastChild.nodeType!=1)
{
n=hr[i].parentNode.lastChild;
rand=n.innerHTML.match(/\[rand\=\d+\]/);
if(rand!=null)
{
n.innerHTML=n.innerHTML.replace(rand[0],"");
rand=rand[0].replace(/[^\d]/g,"");
dice=n.innerHTML.match(/\[dice\=\d+(\+\d+)?\]/ig);
if(dice!=null)
{
for(k=0;k<dice.length;k++)
{
numb=dice[k].match(/\d+(\+\d+)?/);
numb=numb[0].split("+");
addon=numb.length>1?parseInt(numb[1],10):0;
numb=parseInt(numb[0],10);
roll=Math.round((parseFloat(rand.substring(k,k+2)+"."+rand.substring(k+2,rand.length))/100)*(numb-1))+1+addon;
n.innerHTML=n.innerHTML.replace(dice[k],"<table "+(diceAlignment?"style=\"display:inline\"":"")+" border=0 cellpadding=0 cellspacing=0><tr><td><table class=dicebg cellpadding=1 cellspacing=0><tr><td><center><font class=dicefont size=\"+1\"><b>"+roll+"</b><br><font size=\"1\">"+numb+" sides"+(addon>0?"+"+addon:"")+"</font></font></center></td></tr></table></td></tr></table> ");
}
}
}
}
}
}
function addRand()
{
mainForm.message.value=mainForm.message.value.replace(/(\[rand\=\d+\])/ig,"");
if((rs.length==0 && mainForm.message.value.match(/(\[dice\=\d+(\+\d+)?\])/)) && (enablePreview==true || (enablePreview==false && mainForm.nextaction.value=="post")))
{
mainForm.message.value+="[rand="+(Math.random()+"").replace(/0\./,"")+(Math.random()+"").replace(/0\./,"")+(Math.random()+"").replace(/0\./,"")+( Math.random()+"").replace(/0\./,"")+"]";
}
else
{
mainForm.message.value+=rs;
}
disable(mainForm);
}
</script>
But wait! You may want more. For instance, the ability to have the dice icons stack horizontally instead of vertically (or more likely) the ability to roll modifiers on your d20 babies. For that you'll need this sweet meat:
Alternate Source Code to allow horizontal alignment and modifiers:
<style type="text/css">
.dicebg {background-color: FFFFFF;border:solid 2px #000000;}
.dicefont {background-color: FFFFFF;color: 000000; font-weight:bold;}
</style>
<script>
//Dice Rolls In Posts v1.1
//Copyright 4-23-2007 ~Wonder
//May be reposted anywhere as long as this header remains in tact
//Do you want the dice to line of horizontally(true) or vertically(false)
diceAlignment=true;
//Enter URL of the image you want to appear as the dice ubbc button
UBBCdiceImage="http://img100.imageshack.us/img100/6118/diceicon9rx.gif";
//Enter the default # of sides
defaultSides=6;
//Enable dice in preview? true or false
enablePreview=true;
rs="";mainForm="";
if(document.postForm)
{
mainForm=document.postForm;
if(location.href.match(/action\=modifypost/)){enablePreview=true;}
mainForm.color.parentNode.innerHTML+="<a href=javascript:addMult()><img src=\""+UBBCdiceImage+"\" alt=\"Insert Dice Roll\" border=\"0\"></a>";
mainForm.onsubmit=addRand;
mainForm.message.value=mainForm.message.value.replace(/(\[rand\=\d+\])/ig,"");
rs=RegExp.$1;
if(location.href.match(/quote\=\d+/))
{
mainForm.message.value=mainForm.message.value.replace(/(\[dice\=\d+\])/ig,"");
rs="";
}
}
else if(location.href.match(/action\=display/))
{
ta=document.getElementsByTagName("textarea");
if(ta.length>0 && ta[0].name=="message")
{
mainForm=ta[0].parentNode;
mainForm.onsubmit=addRand;
}
}
///////////////////////
if(location.href.match(/action\=(display|pmview|recent|userrecentposts|gotopost|search|calendarview)/) || (!location.href.match(/action\=/) && document.postForm && enablePreview))
{
hr=document.getElementsByTagName("hr");
for(i=0;i<hr.length;i++)
{
if(isset(hr[i].parentNode) && isset(hr[i].parentNode.lastChild) && isset(hr[i].parentNode.lastChild.lastChild) && hr[i].parentNode.lastChild.lastChild.nodeType!=1)
{
n=hr[i].parentNode.lastChild;
rand=n.innerHTML.match(/\[rand\=\d+\]/);
if(rand!=null)
{
n.innerHTML=n.innerHTML.replace(rand[0],"");
rand=rand[0].replace(/[^\d]/g,"");
dice=n.innerHTML.match(/\[dice\=\d+\]/ig);
if(dice!=null)
{
for(k=0;k<dice.length;k++)
{
numb=parseInt(dice[k].match(/\d+/),10);
roll=Math.round((parseFloat(rand.substring(k,k+2)+"."+rand.substring(k+2,rand.length))/100)*(numb-1))+1;
n.innerHTML=n.innerHTML.replace(dice[k],"<table "+(diceAlignment?"style=\"display:inline\"":"")+" border=0 cellpadding=0 cellspacing=0><tr><td><table class=dicebg cellpadding=1 cellspacing=0><tr><td><center><font class=dicefont size=\"+1\"><b>"+roll+"</b><br><font size=\"1\">"+numb+" sides</font></font></center></td></tr></table></td></tr></table> ");
}
}
}
}
}
}
function addMult()
{
numb=prompt("How many dice?");
sides=prompt("How many sides per die?");
for(i=0;i<numb;i++)
add("[dice="+sides+"]","");
}
function addRand()
{
mainForm.message.value=mainForm.message.value.replace(/(\[rand\=\d+\])/ig,"");
if((rs.length==0 && mainForm.message.value.match(/(\[dice\=\d+\])/)) && (enablePreview==true || (enablePreview==false && mainForm.nextaction.value=="post")))
{
mainForm.message.value+="[rand="+(Math.random()+"").replace(/0\./,"")+(Math.random()+"").replace(/0\./,"")+(Math.random()+"").replace(/0\./,"")+( Math.random()+"").replace(/0\./,"")+"]";
}
else
{
mainForm.message.value+=rs;
}
disable(mainForm);
}
function isset(varname){return(typeof(varname)!='undefined');}
</script>