Post by Todge on Feb 14, 2009 9:33:10 GMT -8
This code will add 5 random cards to the top of a post, basically allowing members to play a simple game of poker.
The code places an extra button beside , clicking it will select 5 random cards and the button will disappear. The images will be shown in the post, you can not see them before then.
It goes in the Footer of the board you want it to work on, or the Global Footer if you want it available on all boards.
You need to edit the top of the forum.
Red is the URL of the image you want as the button on the posting page.
Blue is the URL of the cards image up to the number. (file.walagata.com/forumimages/pokercards/card1.gif)
Orange is the file type the cards are saved as. (http://file.walagata.com/forumimages/pokercards/card1.gif)
Greg has been kind enough to supply some images, here are links to the .zip files..
You can use those images or images of your own, though you will obviously have to host them yourselves.. If you use your own images, you need to name them all the same and numbered 1 to 52.
E.g...
card1.gif
card2.gif
card3.gif
etc.
The code places an extra button beside , clicking it will select 5 random cards and the button will disappear. The images will be shown in the post, you can not see them before then.
It goes in the Footer of the board you want it to work on, or the Global Footer if you want it available on all boards.
<script type="text/javascript">
<!--
/*
Poker Hand
by Todge
Copyright © 2009
Please keep this header intact
*/
// Edit Below....
var dealButton = 'URL OF BUTTON IMAGE';
var theDeck = new Array('URL OF CARDS UP TO THE CARD NUMBER','IMAGE TYPE');
// Edit Above....
function dealCards()
{
var card = new Array('[c0]','[c0]','[c0]','[c0]','[c0]');
for(c=0; c<5; c++)
{
card[c] = '[c'+Math.floor ( Math.random ( ) * 52 + 1 )+']';
if(card.join('').split(card[c]).length != 2)
{
c--;
}}
var hand = '[hand]'+card.join('')+'[/hand]';
document.postForm.onsubmit = function(){document.postForm.message.value = hand + document.postForm.message.value;}
deal.style.display = 'none';
return;
}
if(document.postForm)
{
var deck = new Array();
var deal = document.createElement('a');
var dButton = new Image();
dButton.src = dealButton;
dButton.border = '0';
deal.onclick = function(){ dealCards(); }
deal.appendChild(dButton);
document.postForm.color.parentNode.appendChild(deal);
var posted = document.postForm.message.value;
var hand = posted.substring(0,6);
if(hand == '[hand]')
{
hand = posted.split('[/hand]')[0]+'[/hand]';
posted = posted.replace(hand,'');
document.postForm.message.value = posted;
deal.style.display = 'none';
document.postForm.onsubmit = function(){ document.postForm.message.value = hand+document.postForm.message.value; }
}}
if(location.href.match(/action=display/) || document.title.match(/- Preview/))
{
var del = document.images;
for(d=0; d<del.length; d++)
{
if(del[d].alt == '[Delete]')
{
del[d].style.display = 'none';
}}
var posts = document.getElementsByTagName('font');
for(p=0; p<posts.length; p++)
{
if(posts[p].innerHTML.match(/\[\/hand\]/) && posts[p].innerHTML.match(/google_ad_section_start/))
{
posts[p].innerHTML = posts[p].innerHTML.replace(/\[hand\]/g,'<center>');
posts[p].innerHTML = posts[p].innerHTML.replace(/\[\/hand\]/g,'</center>');
for(c=1; c<53; c++)
{
if(posts[p].innerHTML.match(new RegExp('(\\[c'+c+'\\])')))
posts[p].innerHTML = posts[p].innerHTML.replace(RegExp('\\[c'+c+'\\]','g'),'<img src="'+theDeck[0]+c+theDeck[1]+'">');
}
}}}
// -->
</script>
You need to edit the top of the forum.
var dealButton = 'URL OF BUTTON IMAGE';
var theDeck = new Array('URL OF CARDS UP TO THE CARD NUMBER','IMAGE TYPE');
Red is the URL of the image you want as the button on the posting page.
Blue is the URL of the cards image up to the number. (file.walagata.com/forumimages/pokercards/card1.gif)
Orange is the file type the cards are saved as. (http://file.walagata.com/forumimages/pokercards/card1.gif)
Greg has been kind enough to supply some images, here are links to the .zip files..
Mirror 1
Mirror 2
You can use those images or images of your own, though you will obviously have to host them yourselves.. If you use your own images, you need to name them all the same and numbered 1 to 52.
E.g...
card1.gif
card2.gif
card3.gif
etc.