I would like to be able to add dice rolls in posts, Is that possible?
I was trying to use this code. the header said it can be posted anywhere so I was trying to get it to work here.
Code:
- <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=20;
- //Enable dice in preview? true or false
- enablePreview=false;
- 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>
The code you're using is for the Proboards software, they won't work on vForums. I think someone can edit the classes so that it does work, however![]()
well that makes sense, I am hoping i can get a dice working here it's the only thing keeping me from moving both my proboards sites over, cause as a whole this forum is alot better imo
Just checking bases here does this seem doable or is this not going to work at this time? Thank you in advance for your assistance.
I'll look at this for you a little later tonight (unless anyone else wants to do it first)
![]()
Any Luck Ross?
Hi. Sorry it's taken a little longer than expected![]()
This should work if you want to give it a go. Global or Board Footer
Code:
- <style type="text/css">
- .dicebg {background-color: FFFFFF;border:solid 2px #000000;}
- .dicefont {background-color: FFFFFF;color: 000000; font-weight:bold;}
- </style>
- <script type="text/javascript">
- //Dice Rolls In Posts v1.1
- //Copyright 4-23-2007 ~Wonder
- //May be reposted anywhere as long as this header remains in tact
- //Modified by Ross of vForums Support for vForums compatibility
- //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=20;
- //Enable dice in preview? true or false
- enablePreview=false;
- rs="";
- mainForm="";
- if(document.post_form || document.quick_reply_form) {
- if(document.post_form) {
- mainForm=document.post_form;
- if(location.href.match(/action\/modify/)){enablePreview=true;}
- ubbc_holder = document.createElement('span');
- get('ubbc_buttons', ID).firstChild.insertBefore(ubbc_holder, get('ubbc_buttons', ID).firstChild.lastChild);
- } else {
- ubbc_holder = get('quick_reply_ubbc', ID).firstChild.nextSibling;
- mainForm=document.quick_reply_form;
- }
- ubbc_holder.innerHTML+="<a href=javascript:add_ubbc(\"[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="";
- }
- }
- ///////////////////////
- if(location.href.match(/action\/(view_topic|search|recent|pm_view|post|modify|create_poll)/)) {
- td=document.getElementsByTagName("td");
- topic_summary = false;
- for(i=0;i<td.length;i++) {
- if(td.item(i).className == 'post' || topic_summary) {
- // Remove from message preview
- if(td.item(i).className == 'post' && location.href.match(/action\/(post|modify|create_poll)/) && !enablePreview) {
- td.item(i).innerHTML=td.item(i).innerHTML.replace(/\[rand\=(\d|\w|<|>|\/|\s)+\]/gi,"");
- }
- rand=td.item(i).innerHTML.match(/\[rand\=(\d|\w|<|>|\/|\s)+\]/);
- if(rand!=null)
- {
- td.item(i).innerHTML=td.item(i).innerHTML.replace(rand[0],"");
- rand=rand[0].replace(/[^\d]/g,"");
- dice=td.item(i).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;
- td.item(i).innerHTML=td.item(i).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> ");
- }
- }
- }
- } else if(td.item(i).className == 'title1' && td.item(i).innerHTML.match(/>Topic Summary</i)) {
- topic_summary = true;
- }
- }
- }
- function addRand() {
- mainForm.message.value=mainForm.message.value.replace(/(\[rand\=\d+\])/ig,"");
- if((rs.length==0 && mainForm.message.value.match(/(\[dice\=\d+(\+\d+)?\])/))) {
- 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>
No worries I appreciate the help.
I am not getting it to work, I put it in global first, didnt work. Moved it around in a diffrent order, still did not work. So I moved it to a board footer still didnt work, no UBBC button, and tried to just inout the UBBC code [dice=20] and that did not work either. Any thoughts?
http://swlounge.vforums.co.uk/
I played around with it again this morning removed all other codes and it's still not working.
It's sorta working now, part of it was my fault I have a bad habit of copy and pasting the code direct from the box instead of using the select all key...
I still have one small problem, that is it puts the dice UBBC button up but when you press it it does not do anything, if you use the dice ubbc code [dice=20] it works fine
I've copied the code directly from my test board onto your forum. That seems to have gotten it working. I can only presume that something changed in the code either when I pasted it here or you copied it from here. Eitehr way, its' working now![]()
Yup its working perfect thank you!!
It no longer works with the new WYSIWYG Beta
Hi, I just posted this in your bugs thread not realising. The actual functionality now works, it's just the layout which will need some tweaking to reposition the button where you want it.
The (updated) code:
Code:
- <style type="text/css">
- .dicebg {background-color: FFFFFF;border:solid 2px #000000;}
- .dicefont {background-color: FFFFFF;color: 000000; font-weight:bold;}
- </style>
- <script type="text/javascript">
- //Dice Rolls In Posts v1.1
- //Copyright 4-23-2007 ~Wonder
- //May be reposted anywhere as long as this header remains in tact
- //Modified by Ross of vForums Support for vForums compatibility
- //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=20;
- //Enable dice in preview? true or false
- enablePreview=false;
- rs="";
- mainForm="";
- if(document.post_form || document.quick_reply_form) {
- if(document.post_form) {
- mainForm=document.post_form;
- if(location.href.match(/action\/modify/)){enablePreview=true;}
- ubbc_holder = document.createElement('span');
- get('ubbc_buttons', ID).appendChild(ubbc_holder);
- } else {
- ubbc_holder = get('quick_reply_ubbc', ID);
- mainForm=document.quick_reply_form;
- }
- ubbc_holder.innerHTML+="<a href=javascript:add_ubbc(\"[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. ; rs=(/\[rand\=/.test(rs))?rs:"";
- if(location.href.match(/quote\/\d+/))
- {
- mainForm.message.value=mainForm.message.value.replace(/(\[dice\=\d+\])/ig,"");
- rs="";
- }
- }
- ///////////////////////
- if(location.href.match(/action\/(view_topic|search|recent|pm_view|post|modify|create_poll)/)) {
- td=document.getElementsByTagName("td");
- topic_summary = false;
- for(i=0;i<td.length;i++) {
- if(td.item(i).className == 'post' || topic_summary) {
- // Remove from message preview
- if(td.item(i).className == 'post' && location.href.match(/action\/(post|modify|create_poll)/) && !enablePreview) {
- td.item(i).innerHTML=td.item(i).innerHTML.replace(/\[rand\=(\d|\w|<|>|\/|\s)+\]/gi,"");
- }
- rand=td.item(i).innerHTML.match(/\[rand\=(\d|\w|<|>|\/|\s)+\]/);
- if(rand!=null) {
- td.item(i).innerHTML=td.item(i).innerHTML.replace(rand[0],"");
- rand=rand[0].replace(/[^\d]/g,"");
- dice=td.item(i).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;
- td.item(i).innerHTML=td.item(i).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> ");
- }
- }
- }
- } else if(td.item(i).className == 'title1' && td.item(i).innerHTML.match(/>Topic Summary</i)) {
- topic_summary = true;
- }
- }
- }
- function addRand() {
- tinyMCE.triggerSave(true, true);
- mainForm.message.value=mainForm.message.value.replace(/(\[rand\=\d+\])/ig,"");
- if((rs.length==0 && mainForm.message.value.match(/(\[dice\=\d+(\+\d+)?\])/))) {
- 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>
I swapped out the codes and it still does not seem to be working for me. I tried just using the dice code since there was no button and that did not show up.
I swapped out the codes and it still does not seem to be working for me. I tried just using the dice code since there was no button and that did not show up.
You shouldn't of had to touch the code. I had already modified the version on your forum. And when I left it, it was working fine.
It does not appear to be working, I figured the button was not showing because it need to be positioned or what not but just typing in the code for it still does not work.
The code I had posted seemed to get broken when you pasted it into your footer (not that you should have in the first place). I have changed it on your forum - it works. I'd recommend not touching it for now.
I wont touch it, it was not clear from your post on the last page you had swapped it over...sorry for the misunderstanding. And thank you for your assistance. You do bring up a good point, nearly everytime I copy a code over and paste it into my headers or footers it seems to have some issue even if it is exactly the same thing you had there. You have had to address my codes numerous times now and I am unsure on what is the issue. Since I have never had any problem like this before. While this is my first Vforum it is my 5th site.