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

              
                
              
            
!

CSS

              
                
html {
  height: 100%;
  width: 100%;  
}

body {
  background: #a7cfdf;
  background: -moz-linear-gradient(top, #a7cfdf 0%, #23538a 100%);
  background: -webkit-linear-gradient(top, #a7cfdf 0%, #23538a 100%);
  background: linear-gradient(to bottom, #a7cfdf 0%, #23538a 100%);
  filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='#a7cfdf', endColorstr='#23538a', GradientType=0);
  padding: 25px;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
}

.gameBoard .cardHolder>div,
.gameBoard .LBG {
  background: #cedbe9;
  background: -moz-linear-gradient(top, #cedbe9 0%, #aac5de 17%, #6199c7 50%, #3a84c3 51%, #419ad6 59%, #4bb8f0 71%, #3a8bc2 84%, #26558b 100%);
  background: -webkit-linear-gradient(top, #cedbe9 0%, #aac5de 17%, #6199c7 50%, #3a84c3 51%, #419ad6 59%, #4bb8f0 71%, #3a8bc2 84%, #26558b 100%);
  background: linear-gradient(to bottom, #cedbe9 0%, #aac5de 17%, #6199c7 50%, #3a84c3 51%, #419ad6 59%, #4bb8f0 71%, #3a8bc2 84%, #26558b 100%);
  filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='#cedbe9', endColorstr='#26558b', GradientType=0);
}

.gameBoard .cardHolder>div:empty,
.gameBoard .score,
.gameBoard .button,
.gameBoard .DBG {
  background: #7db9e8;
  background: -moz-linear-gradient(top, #7db9e8 0%, #207cca 49%, #2989d8 50%, #1e5799 100%);
  background: -webkit-linear-gradient(top, #7db9e8 0%, #207cca 49%, #2989d8 50%, #1e5799 100%);
  background: linear-gradient(to bottom, #7db9e8 0%, #207cca 49%, #2989d8 50%, #1e5799 100%);
  filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='#7db9e8', endColorstr='#1e5799', GradientType=0);
}

.gameBoard {
  position: relative;
  font-family: helvetica, sans-serif;
  color: white;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 1);
  border: 5px solid #003c7b;
  text-align: center;
  padding: 150px;
  border-radius: 50%;
  max-width: 1000px;
  max-height: 800px;
  min-width: 305px;
  margin: auto;
  background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/40041/bgFF.svg') #0C4779;
  /*background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/40041/bgFF.svg') #3a84c3;*/
  background-repeat: repeat;
  background-position: center center;
  -webkit-box-shadow: 0 1px 24px 1px rgba(0, 0, 0, 0.48);
  -moz-box-shadow: 0 1px 24px 1px rgba(0, 0, 0, 0.48);
  box-shadow: 0 1px 24px 1px rgba(0, 0, 0, 0.48);
}

.gameBoard .score {
  position: absolute;
  text-align: center;
  margin: auto;
  font-size: 45px;
  height: 50px;
  line-height: 50px;
  width: 75px;
  padding: 20px;
  border: 2px solid white;
  -webkit-box-shadow: inset 0 1px 24px 1px rgba(0, 0, 0, 0.48);
  -moz-box-shadow: inset 0 1px 24px 1px rgba(0, 0, 0, 0.48);
  box-shadow: inset 0 1px 24px 1px rgba(0, 0, 0, 0.48);
}
.gameBoard .score#boardScore {
  height: 75px;
  line-height: 75px;
  width: 125px;
  font-size: 65px;
  left: 0;
  right: 0;
  top: 20px;
}
.gameBoard .score#team1 {
  left: 10px;
  top: 0;
  bottom: 0;
}
.gameBoard .score#team2 {
  right: 10px;
  top: 0;
  bottom: 0;
}

.gameBoard .questionHolder {
  width: 94%;
  margin: auto;
  height: 100px;
  line-height: 100px;
  text-align: center;
  font-size: 30px;
  color: #003c7b;
  text-shadow: initial;
  text-align: center;
  border: 1px solid black;
  background: #deeeff;
  padding: 10px;
  margin-bottom: 15px;
  border: 1px solid black;
  -webkit-box-shadow: inset 0 1px 24px 1px rgba(0, 0, 0, 0.48);
  -moz-box-shadow: inset 0 1px 24px 1px rgba(0, 0, 0, 0.48);
  box-shadow: inset 0 1px 24px 1px rgba(0, 0, 0, 0.48);
}
.gameBoard .questionHolder span {
  display: inline-block;
  vertical-align: middle;
  line-height: normal;
}

.gameBoard .colHolder {
  background: black;
  padding: 4px;
}
.gameBoard .colHolder>div {
  display: block;
  width:100%;
  -webkit-box-shadow: 0 1px 24px 1px rgba(0, 0, 0, 0.48);
  -moz-box-shadow: 0 1px 24px 1px rgba(0, 0, 0, 0.48);
  box-shadow: 0 1px 24px 1px rgba(0, 0, 0, 0.48);
}
.gameBoard .cardHolder {
  display: inline-block;
  position: relative;
  vertical-align: top;
  height: 50px;
  margin: 4px;
  width: 95%;
  background: black;
  border: 4px solid white;
}
.gameBoard .cardHolder:not(.empty){
  cursor: pointer;
}
.gameBoard .cardHolder b {
  position: absolute;
  right: 0;
  width: 45px;
  text-align: center;
  border-left: 2px solid #003c7b;
}
.gameBoard .cardHolder span {
  margin: 10px;
}
.gameBoard .cardHolder>div {
  top: -2px;
  left: -2px;
  margin: 0px;
  padding: 0px;
  position: absolute;
  width: 100%;
  line-height: 100%;
  height: 100%;
  border: 2px solid #003c7b;
  line-height: 50px;
}
.gameBoard .cardHolder .back {
  font-size: 25px;
  text-align: left;
  height: 50px;
  line-height: 50px;
}
.gameBoard .cardHolder .back span {
  text-align: left;
  display: inline-block;
  vertical-align: middle;
  line-height: normal;
}
.gameBoard .cardHolder .front {
  text-align: center;
}
.gameBoard .cardHolder .front span {
  font-size: 30px;
  position: absolute;
  border-radius: 50%;
  line-height: 35px;
  height: 35px;
  width: 45px;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  display: block;
  margin: auto;
  border: 2px solid #003c7b;
}

.gameBoard .btnHolder{
  position: absolute;
  margin: auto;
  left:0;
  right:0;
  bottom:45px
}
.gameBoard .btnHolder .button{
  cursor: pointer;
  display:inline-block;
  font-size: 20px;
  margin:10px;
  height:50px;
  line-height:50px;
  width:175px;
  border:3px solid white;
  -webkit-box-shadow: 0 1px 24px 1px rgba(0, 0, 0, 0.48);
  -moz-box-shadow: 0 1px 24px 1px rgba(0, 0, 0, 0.48);
  box-shadow: 0 1px 24px 1px rgba(0, 0, 0, 0.48);
}
.gameBoard .btnHolder .button#awardTeam1{
  border-radius: 50px 0 0 50px;
}
.gameBoard .btnHolder .button#awardTeam2{
  border-radius: 0 50px 50px 0;
}

@media screen and (min-width: 780px) {
  .gameBoard .colHolder>div{
    display: inline-block;
    width:50%;
  }
}

              
            
!

JS

              
                var app = {
  version: 1,
  currentQ: 0,
  jsonFile:"https://s3-us-west-2.amazonaws.com/s.cdpn.io/40041/FF3.json",
  board: $("<div class='gameBoard'>"+
           
             "<!--- Scores --->"+
             "<div class='score' id='boardScore'>0</div>"+
             "<div class='score' id='team1' >0</div>"+
             "<div class='score' id='team2' >0</div>"+
           
             "<!--- Question --->"+
             "<div class='questionHolder'>"+
               "<span class='question'></span>"+
             "</div>"+
           
             "<!--- Answers --->"+
             "<div class='colHolder'>"+
               "<div class='col1'></div>"+
               "<div class='col2'></div>"+
             "</div>"+
           
             "<!--- Buttons --->"+
             "<div class='btnHolder'>"+
               "<div id='awardTeam1' data-team='1' class='button'>Award Team 1</div>"+
               "<div id='newQuestion' class='button'>New Question</div>"+
               "<div id='awardTeam2' data-team='2'class='button'>Award Team 2</div>"+
             "</div>"+
           
           "</div>"),
  // Utility functions
  shuffle: function(array){
    var currentIndex = array.length, temporaryValue, randomIndex;
    while (0 !== currentIndex) {
      randomIndex = Math.floor(Math.random() * currentIndex);
      currentIndex -= 1;
      temporaryValue = array[currentIndex];
      array[currentIndex] = array[randomIndex];
      array[randomIndex] = temporaryValue;
    }
    return array;
  },
  jsonLoaded: function(data){
    console.clear()
    app.allData   = data
    app.questions = Object.keys(data)
    app.shuffle(app.questions)
    app.makeQuestion(app.currentQ)
    $('body').append(app.board)
  },
  // Action functions
  makeQuestion: function(qNum){
    var qText  = app.questions[qNum]
    var qAnswr = app.allData[qText]

    var qNum = qAnswr.length
        qNum = (qNum<8)? 8: qNum;
        qNum = (qNum % 2 != 0) ? qNum+1: qNum;
    
    var boardScore = app.board.find("#boardScore")
    var question   = app.board.find(".question")
    var col1       = app.board.find(".col1")
    var col2       = app.board.find(".col2")
    
    boardScore.html(0)
    question.html(qText.replace(/&x22;/gi,'"'))
    col1.empty()
    col2.empty()

    for (var i = 0; i < qNum; i++){
      var aLI     
      if(qAnswr[i]){
        aLI = $("<div class='cardHolder'>"+
                  "<div class='card'>"+
                    "<div class='front'>"+
                      "<span class='DBG'>"+(i+1)+"</span>"+
                    "</div>"+
                    "<div class='back DBG'>"+
                      "<span>"+qAnswr[i][0]+"</span>"+
                      "<b class='LBG'>"+qAnswr[i][1]+"</b>"+
                    "</div>"+
                  "</div>"+
                "</div>")
      } else {
        aLI = $("<div class='cardHolder empty'><div></div></div>")
      }
      var parentDiv = (i<(qNum/2))? col1: col2;
      $(aLI).appendTo(parentDiv)
    }  
    
    var cardHolders = app.board.find('.cardHolder')
    var cards       = app.board.find('.card')
    var backs       = app.board.find('.back')
    var cardSides   = app.board.find('.card>div')

    TweenLite.set(cardHolders , {perspective:800});
    TweenLite.set(cards       , {transformStyle:"preserve-3d"});
    TweenLite.set(backs       , {rotationX:180});
    TweenLite.set(cardSides   , {backfaceVisibility:"hidden"});

    cards.data("flipped", false)
    
    function showCard(){
      var card = $('.card', this)
      var flipped = $(card).data("flipped")
      var cardRotate = (flipped)?0:-180;
      TweenLite.to(card, 1, {rotationX:cardRotate, ease:Back.easeOut})
      flipped = !flipped
      $(card).data("flipped", flipped)
      app.getBoardScore()
    }
    cardHolders.on('click',showCard)
  },
  getBoardScore: function(){
    var cards = app.board.find('.card')
    var boardScore = app.board.find('#boardScore')
    var currentScore = {var: boardScore.html()}
    var score = 0
    function tallyScore(){
      if($(this).data("flipped")){
         var value = $(this).find("b").html()
         score += parseInt(value)
      }
    }
    $.each(cards, tallyScore)      
    TweenMax.to(currentScore, 1, {
      var: score, 
      onUpdate: function () {
        boardScore.html(Math.round(currentScore.var));
      },
      ease: Power3.easeOut,
    });
  },
  awardPoints: function(num){
    var num          = $(this).attr("data-team")
    var boardScore   = app.board.find('#boardScore')
    var currentScore = {var: parseInt(boardScore.html())}
    var team         = app.board.find("#team"+num)
    var teamScore    = {var: parseInt(team.html())}
    var teamScoreUpdated = (teamScore.var + currentScore.var)
    TweenMax.to(teamScore, 1, {
      var: teamScoreUpdated, 
      onUpdate: function () {
        team.html(Math.round(teamScore.var));
      },
      ease: Power3.easeOut,
    });
    
    TweenMax.to(currentScore, 1, {
      var: 0, 
      onUpdate: function () {
        boardScore.html(Math.round(currentScore.var));
      },
      ease: Power3.easeOut,
    });
  },
  changeQuestion: function(){
    app.currentQ++
    app.makeQuestion(app.currentQ)
  },
  // Inital function
  init: function(){
    $.getJSON(app.jsonFile, app.jsonLoaded)
    app.board.find('#newQuestion' ).on('click', app.changeQuestion)
    app.board.find('#awardTeam1'  ).on('click', app.awardPoints)
    app.board.find('#awardTeam2'  ).on('click', app.awardPoints)
  }  
}
app.init()
//http://www.qwizx.com/gssfx/usa/ff.htm
              
            
!
999px

Console