Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html>

<head>
  <meta charset="UTF-8">
  <title>Past, Present, Future Three Card Tarot Draw</title>
  <!-- Latest compiled and minified CSS -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

  <!-- Optional theme -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

  <!-- Latest compiled and minified JavaScript -->
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  <!-- jQuery library -->
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  <link rel="stylesheet" href="css/style.css">
  <!--JS for this webapp-->
  <script src="js/index.js"></script>
  <link href="https://fonts.googleapis.com/css?family=Satisfy" rel="stylesheet">
</head>

<body onload="autoCode()">


  <div class="container">
    <div class="jumbotron">
      <h1>Three Card Tarot Reading</h1>
      <br>
      <p id="blurb">
        The three card reading is one of the simplest tarot card spreads.<br /> The card to the left represents events in your past that may have led to the position you are in now. The Tarot card in the center position represents your outlook on your
        current state of affairs. The card furthest to the right suggests a possible outcome if no action is taken to change the current course. The future is not set in stone &amp; can be changed through action.
        <br />
        <br /> Please focus on your question &amp; click the &quot;My Reading&quot; button below when you are ready.
      </p>
      <button type="button" class="btn btn-primary btn-lg" id="pastPresentFuture" onclick="pastPresentFuture()">My Reading</button>
      <!--<button onclick="debug()">TEST</button>-->

      <table id="table">
        <tr>
          <th>
            <center>
              <h2>Past</h2></center>
          </th>
          <th>
            <center>
              <h2>Present</h2></center>
          </th>
          <th>
            <center>
              <h2>Future</h2></center>
          </th>
        </tr>
        <tr id="card-img">
          <td id="td-1">

          </td>
          <td id="td-2">

          </td>
          <td id="td-3">

          </td>
        </tr>
        <tr id="display-name">
          <td id="td-display-name-1">

          </td>
          <td id="td-display-name-2">

          </td>
          <td id="td-display-name-3">

          </td>
        </tr>
        <tr id="reversal">
          <td id="rev-1">
          </td>
          <td id="rev-2">
          </td>
          <td id="rev-3">
          </td>

        </tr>
      </table>

    </div>
  </div>

</body>

</html>
              
            
!

CSS

              
                html body {
  background-color: black;
  padding-left: 10%;
  padding-right: 10%;
}
.container {
  max-width: 100%;
  background-color: grey;
}

.jumbotron {
  margin-top: 1.5%;
  text-align: center;
  font-family: 'Satisfy', cursive;
}

#blurb {
  text-align: justify;
  font-size: 25px;
}

.invert {
  -moz-transform: rotate(180deg);
  -o-transform: rotate(180deg);
  -webkit-transform: rotate(180deg);
  transform: rotate(180deg);
}
table {
  width: 100%;
}

.back, 
.front {
  top: 0;
  max-width: 230px;
  max-height: 330px;
  padding-left: 5%;
  padding-right: 5%;
  width: 90%;  
}

#display-name td,
#reversal td {
  top: 0;
  max-width: 230px;
}
#reversal td p {
  top: 0;
  font-size: 115%;
}

              
            
!

JS

              
                //global variables
var deck = {};
var rank = "";
var suit = "";
var deckArr = [];
var backImg = "<img class='back' src='https://s-media-cache-ak0.pinimg.com/236x/c1/59/b4/c159b4738dae9c9d8d6417228024de8d.jpg' />"

//Creates a tarot card deck 

function createDeck() {
  deckArr = [];

  function deckConst(name, displayName) {
    this.name = name;
    this.displayName = displayName;
  }

  var id = 0;
  for (var a0 = 0; a0 < 4; a0++) {

    switch (a0) {
      case 0:
        suit = "cups";
        break;
      case 1:
        suit = "pentacles";
        break;
      case 2:
        suit = "swords";
        break;
      case 3:
        suit = "wands";
        break;
    }

    for (var a1 = 1; a1 < 15; a1++) {
      var rank = a1;
      switch (a1) {
        case 1:
          rank = "ace";
          break;
        case 2:
          rank = "two"
          break;
        case 3:
          rank = "three"
          break;
        case 4:
          rank = "four"
          break;
        case 5:
          rank = "five"
          break;
        case 6:
          rank = "six"
          break;
        case 7:
          rank = "seven"
          break;
        case 8:
          rank = "eight"
          break;
        case 9:
          rank = "nine"
          break;
        case 10:
          rank = "ten"
          break;
        case 11:
          rank = "page";
          break;
        case 12:
          rank = "knight";
          break;
        case 13:
          rank = "queen";
          break;
        case 14:
          rank = "king";
          break;
        default:
          break;
      }
      id++;
      // assigns the name that jives with biddy tarot's urls
      var name = rank + "_" + suit;
      // overcomplicated way to title-case & replace '_' with ' '
      var displayName = name.replace(/_/g, " of ")
        .toLowerCase()
        .split(' ')
        .map(i => i[0].toUpperCase() + i.substring(1))
        .join(' ');

      card = new deckConst(name, displayName);
      deck[id] = card;
    }
  }

  deck[57] = new deckConst('fool');
  deck[58] = new deckConst('magician');
  deck[59] = new deckConst('high_priestess');
  deck[60] = new deckConst('empress');
  deck[61] = new deckConst('emperor');
  deck[62] = new deckConst('hierophant');
  deck[63] = new deckConst('lovers');
  deck[64] = new deckConst('chariot');
  deck[65] = new deckConst('strength');
  deck[66] = new deckConst('hermit');
  deck[67] = new deckConst('wheel_of_fortune');
  deck[68] = new deckConst('justice');
  deck[69] = new deckConst('hanged_man');
  deck[70] = new deckConst('death');
  deck[71] = new deckConst('temperance');
  deck[72] = new deckConst('devil');
  deck[73] = new deckConst('tower');
  deck[74] = new deckConst('star');
  deck[75] = new deckConst('moon');
  deck[76] = new deckConst('sun');
  deck[77] = new deckConst('judgement');
  deck[78] = new deckConst('world');

  // totally over-complicated code to capitolize, space & add a 'the' to trump cards that needed it
  for (var x = 57; x <= 78; x++) {
    var capStr = deck[x].name
      .replace(/_/g, " ")
      .toLowerCase()
      .split(' ')
      .map(i => i[0].toUpperCase() + i.substring(1))
      .join(' ');
    
      
    if (x === 65 || 
        x === 68 || 
        x === 70 || 
        x === 71 || 
        x === 77) {
      deck[x].displayName = capStr;
    } else {
      deck[x].displayName = "The " + capStr;
    }
  }



  for (var t = 0; t < 78; t++) {
    deckArr.push(t + 1);
  }

  return deckArr;
  return deck;
}

//gets image i = id from createDeck()
function riderWaite(i) {
  var img = $("<img class='front' src='https://www.biddytarot.com/cards/" +
    deck[i].name + ".jpg' alt=" + deck[i].displayName + "/>");
  return img;

}

//Selects random cards & prevents doubles
function randGen() {
  var cardsLeft = deckArr.length;
  var randInt = Math.floor((Math.random() * cardsLeft));
  var randNum = deckArr[randInt];
  deckArr.splice(randInt, 1);
  return randNum;
}

//Past, Present, Future spread
function pastPresentFuture() {
  $("img, #blurb, #card-name, #rev").remove();
  $("#pastPresentFuture").html('Another Reading?');

  for (var b = 1; b <= 3; b++) {
    var rand = randGen();
    
    var randInvert = Math.floor((Math.random() * 101));
    var randCardImg = riderWaite(rand);
    var randCardDisplayName = "<p id='card-name'>"+deck[rand].displayName+"</p>"
    
    if (randInvert >= 15) {
      $("#td-" + b).html(randCardImg);
      $("#td-display-name-" + b).append(randCardDisplayName);
    } else {
      $("#td-" + b).html(randCardImg).addClass("invert");
      $("#td-display-name-" + b).append(randCardDisplayName);
      $("#rev-" + b).html('<p id="rev"><i>Reversed</i></p>');
    }
  }
}

function autoCode() {
  createDeck();

  for (var q = 1; q <= 3; q++) {
    $("#td-" + q).html(backImg);
  }
}

//Shows all cards (used in debugging)
//function debug() {
//  createDeck();

//  for (var i = 1; i < Object.keys(deck).length; i++) {
//    console.log(deck[i].displayName);
//  }
//}
              
            
!
999px

Console