Results 1 to 2 of 2

Thread: Javascript for oracle cards

  1. #1
    Join Date
    Oct 2008

    Javascript for oracle cards

    Hi, I've been working on scripts for displaying oracle cards (similar to tarot cards) have various scripts for random array, adding links (thanks to generous feedback from you guys with working code). But its all bits and pieces. there must be a simpler way or one snippet of code that can contain everything required?

    1. Randomly choose cards from a deck of cards, depending on layout can be 3 to 12 cards (Done)
    2. Once a card is chosen it cannot repeat itself
    3. Each image of the card and corrosponding text is linked to a browser window (Done)
    4. Information in the browser window contains relative info from the random card clicked on

    Is there a simpler way or would any guru suggest that can contain all 4 steps or should I keep plugging the gaps on the "bits of code strung together from here and there" till it works?

  2. #2
    Join Date
    Jan 2005
    Los Angeles, CA
    Ehh... I should have made it clear in the last thread that #2 is already covered. Reusing my prototype function defined there, you can do something like:
    <style type="text/css">
    .even td{background-color:#eeeeee;}
    .odd td{background-color:#dddddd;}
    <script type="text/javascript">
    //Author: Ultimater
    var hand=new Array(),l=this.length;
    for(var i=0;i<l;i++)hand.splice(Math.floor(Math.random()*(i+1)),0,i);
    return hand.splice(0,n);
    <script type="text/javascript">
    deck=new Array("A","K","Q","J",10,9,8,7,6,5,4,3,2);
    function newHand(){
    cards=new Array();
    for(var i=0;i<h.length;i++)cards.push(deck[h[i]]);
    return cards;
    document.write("<tr class=\""+((i&#37;2==0)?"even":"odd")+"\"><td>"+(newHand().join("</td><td>"))+"</td></tr>");
    Last edited by Ultimater; 10-13-2008 at 03:04 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles