Post by blank on Apr 11, 2007 22:08:36 GMT -5
<style type="text/css">
.dicebg {background-color: FFFFFF; border:solid 2px #000000;}
.dicefont {color: 000000; font-weight:bold;}
</style>
<script>
//Dice Rolls In Posts v1.0
//Copyright 11-02-2005 ~Wonder
//May be reposted anywhere as long as this header remains in tact
//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;
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))
{
td=document.getElementsByTagName("td");
for(i=0;i<td.length;i++)
{
if(td.width=="20%" && td.className.match(/windowbg/))
{
rand=td.nextSibling.innerHTML.match(/\[rand\=\d+\]/);
if(rand!=null)
{
td.nextSibling.innerHTML=td.nextSibling.innerHTML.replace(rand[0],"");
rand=rand[0].replace(/[^\d]/g,"");
dice=td.nextSibling.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;
td.nextSibling.innerHTML=td.nextSibling.innerHTML.replace(dice[k],"<table class=dicebg cellpadding=1 cellspacing=0><tr><td><center><font class=dicefont size=\"+1\"><b>"+roll+"</b></font></center></td></tr><tr><td><center><font class=dicefont size=\"1\">"+numb+" sides</font></center></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+\])/)) && (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>
.dicebg {background-color: FFFFFF; border:solid 2px #000000;}
.dicefont {color: 000000; font-weight:bold;}
</style>
<script>
//Dice Rolls In Posts v1.0
//Copyright 11-02-2005 ~Wonder
//May be reposted anywhere as long as this header remains in tact
//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;
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))
{
td=document.getElementsByTagName("td");
for(i=0;i<td.length;i++)
{
if(td.width=="20%" && td.className.match(/windowbg/))
{
rand=td.nextSibling.innerHTML.match(/\[rand\=\d+\]/);
if(rand!=null)
{
td.nextSibling.innerHTML=td.nextSibling.innerHTML.replace(rand[0],"");
rand=rand[0].replace(/[^\d]/g,"");
dice=td.nextSibling.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;
td.nextSibling.innerHTML=td.nextSibling.innerHTML.replace(dice[k],"<table class=dicebg cellpadding=1 cellspacing=0><tr><td><center><font class=dicefont size=\"+1\"><b>"+roll+"</b></font></center></td></tr><tr><td><center><font class=dicefont size=\"1\">"+numb+" sides</font></center></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+\])/)) && (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>