css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <!-- LOADER!!! -->
<div id="intro" class="flexContainer centered">
  <div class="titleText">
    <p>Random Quote Guessing Game</p>
  </div>
</div>

<div id="loader-frame" class="loader-frame">
  <div id="loader1" class="loader1">
  </div>
  <div id="loader2" class="loader2">
  </div>
</div>


<div id="startButton" class="flexContainer" style="display:none">
  <button type="button" class="btn btn-secondary startButton">Begin</button>
</div>
  
<div id="xerxes"> by Xerxes Clayton </div>


<!-- Main Div -->
<div id="screen" style="display:none" class="screen container-fluid">
  <!--<div id="backup" style="display:none" class="backup">
  <img id="background" src=""> </img>-->
  <div class="title">
  </div>

  <!-- Quote Box Div -->
  <div class="flexContainer">
    <div id="quoteBox" style="display: none" class="quoteBox center-block">
      <div id="score" class="score">0</div>
      <div id="authorHint"> - ??? </div>
      <div id="infoBoxScore" style="display:none" class="infoBox infoBoxScore">
        <div id="" class="infoText">Score
        </div>
      </div>
      <!--<div id="quotePic">
      <img src="https://www.northernhonda.com/wp-content/uploads/sites/109/2016/09/quotation-marks-left-300x241.png" style="width:30px;,height:30px;"> </img>
    </div>-->
      <div id="quoteText" class="message">
        <p></p>
      </div>

      <button id="refreshButton" class="btn btn-lg">
       <span class="glyphicon glyphicon-repeat"></span>
        <div id="infoBoxRefresh" style="display:none" class="infoBox infoBoxRefresh">
          <div class="infoText">New Quote</div>
     </button>

      <button id="infoButton" class="btn btn-lg">
      <span class="glyphicon glyphicon-info-sign"></span>
    </button>

      <div id="tweetButton">
        <img src="https://www.shareicon.net/data/2015/08/20/88253_blue_512x512.png" style="width:25px;height:25px;"></div>

    </div>
  </div>

  <!-- Author Box Div -->
  <div id="authorBox" class="centered">
    <div>
      <button id="answer0" style="display: none" class="answer btn btn-secondary"> Test </button>
    </div>
    <div>
      <button id="answer1" style="display: none" class="answer btn btn-secondary"> Test </button>
    </div>
    <div>
      <button id="answer2" style="display: none" class="answer btn btn-secondary"> Test </button>
    </div>
  </div>

  <div id="infoBoxPhoto" style="display:none" class="infoBox infoBoxPhoto">
    <div id="" class="infoText">Photographer
    </div>
  </div>

  <!-- Photographer Credit -->
  <div>
    <a id="anchor" href="https://google.com" target="_blank">
      <button id="photographerCredit" style="display:none" class="btn btn-secondary"></button>
      <a id="backupAnchor" href="https://google.com" target="_blank">
        <button id="backupPhotographerCredit" style="display:none" class="btn btn-secondary"></button>
      </a>
    </a>
  </div>
</div>
            
          
!
            
              html, body {
  margin: 0px;
  height: 100%;
  max-width: 100%;
  overflow-y: hidden;
  background-color: rgb(230,230,230);
}

#intro {
  //border: 2px solid blue;
  margin: 10% 15% 0px 15%;
  padding: 0px;
  font-family: Brush Script MT;
  font-size: 10vmin;
  color: rgb(47, 79, 79);
  z-index: 0;
  display: flex;

@media screen and (max-width: 400px) {
    font-size: 40px;
}
}

#background {
  background-size: cover;
  background-position: center;
  width: 100%;
  height: 100%;
  padding-bottom: 0px;
 }

.screen {
  //background-color: rgb(0, 0, 100);
  background-image: url("");
  background-size: cover;
  background-position: center;
  overflow-y: auto;
  width: 100%;
  height: 100%;
  padding-bottom: 0px;
  overflow-x: hidden;
}

.backup {
  //background-color: rgb(0, 0, 100);
  background-image: url("");
  background-size: cover;
  background-position: center;
  overflow: auto;
  width: 100%;
  height: 100%;
  padding-bottom: 0px;
  overflow-x: hidden;
}

.title {
  margin: 0px 0px 0px 0px;
  padding: 15px 0px 100px 0px;
  //border: 2px solid blue;
  }

#quotePic {
  //transform: translateY();
  z-index: -2;
  position: relative;
  top: 200px;
  left: 200px;
}

.quoteBox {
  //border: 2px solid blue;
  z-index: 1;
  min-width: 300px;
  border-radius: 15px;
  background: rgba(255,255,255,0.75);
  position: relative;
  padding: 30px 20px 35px 20px;
  margin: 0% 30% 40px 30%;
  display: flex;
  flex-direction: row;
}

#quoteText {
  //border: 2px solid red;
  text-align: center;
  margin: auto !important;
  font-size: 18px;
  padding: 0px;
}

.infoBox {
  z-index: 2;
  //min-width: 250px;
  border-radius: 6px;
  background: rgba(122, 154, 154, 0.7);
  color: white;
}

// new info box targetting refresh button
.infoBoxRefresh {
  position: absolute;
  top: -29px;
  right: -27px;
}

.infoBoxScore {
  position: absolute;
  top: -54px;
  left: 3px;
}

.infoBoxPhoto {
  position: absolute;
  bottom: 1px;
}

.infoBoxRefresh::after {
    content: " ";
    position: absolute;
    top: 100%; /* At the bottom of the tooltip */
    left: 50%;
    margin-left: -10px;
    border-width: 10px;
    border-style: solid;
    border-color: rgba(122, 154, 154, 0.7) transparent transparent transparent;
}

.infoBoxScore::after {
    content: " ";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -8px;
    border-width: 8px;
    border-style: solid;
    border-color: rgba(122, 154, 154, 0.7) transparent transparent transparent;
}

.infoBoxPhoto::after {
    content: " ";
    position: absolute;
    top: 50%;
    left: 100%; /* To the right of the tooltip */
    margin-top: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: transparent transparent transparent rgba(122, 154, 154, 0.7);
}

.infoText {
  //border: 2px solid blue;
  font-size: 14px !important;
  margin: auto;
  padding: 2px 5px;
  //display: flex;
  //flex-direction: column;
  //justify-content: center;
}

#infoButton {
  //border: 2px solid green;
  background-color: transparent;
  outline: none !important;
  color: black;
  padding: 5px;
  position: absolute;
  bottom: -3px;
  left: 3px;
}

#tweetButton {
  background-color: transparent;
  outline: none !important;
  position: absolute;
  bottom: 5px;
  right: 8px;
}

#refreshButton {
  background-color: transparent;
  outline: none !important;
  color: black;
  padding: 5px;
  position: absolute;
  top: 3px;
  right: 4px;
  display: flex;
}

.answer {
  text-align: center;
  outline: none !important;
  margin: 10px;
  padding: 5px 13px 5px 13px;
  border: 2px solid black;
  border-radius: 12px;
  font-size: 20px;
  background-color: rgba(200,200,255,0.8);
  animation-delay: 0.4s;
  transition-duration: 0.5s;
}

.answer:hover {
  background-color: rgba(160,160,255,0.8);
  }

#photographerCredit {
  color: black;
  position: absolute;
  bottom: 0px;
  right: 0px;
  padding: 2px 5px;
  border: 1px solid black;
  background-color: rgba(160,160,255,0.8);
}

#backupPhotographerCredit {
  color: black;
  position: absolute;
  bottom: 0px;
  right: 0px;
  padding: 2px 5px;
  border: 1px solid black;
  background-color: rgba(160,160,255,0.8);
}

.centered {
  text-align: center;
}

.correct {
  background-color: rgb(27,156,8) !important;
}

.incorrect {
  background-color: rgba(216,42,7,0.8) !important;
}

.loader-frame {
  width: 70px;
  height: 70px;
  //border: 2px solid blue;
  margin: 5% 0px 0px -35px;
  //z-index: 1;
  position: absolute;
  top: 50%;
  left: 50%;
}

.loader1, .loader2 {
  position: absolute;
  border: 5px solid transparent;
  border-radius: 50%;
}

.loader1 {
  width: 70px;
  height: 70px;
  border-top: 5px solid rgb(150,150,255);
  border-bottom: 5px solid rgb(150,150,255);
  animation: clockwisespin 2.5s linear infinite;
}

.loader2 {
  width: 60px;
  height: 60px;
  border-left: 5px solid rgb(97, 129, 129);
  border-right: 5px solid rgb(97, 129, 129);
  top: 5px;
  left: 5px;
  animation: counterclockwisespin 2.5s linear infinite;
}

@keyframes clockwisespin {
  0% {transform: rotate(0deg);}
  100% {transform: rotate(360deg);}
}

@keyframes counterclockwisespin {
  0% {transform: rotate(0deg);}
  100% {transform: rotate(-360deg);}
}

.flexContainer {
  display: flex;
  justify-content: center;
}

.startButton {
  width: 15%;
  height: 10%;
  min-width: 100px;
  max-width: 150px;
  min-height: 50px;
  max-height: 100px;
  outline: none !important;
 //border: 2px solid rgb(150,50,255);
  font-size: 20px;
  font-weight: bold;
  color: white;
  position: absolute;
  top: 56%;
  background-color: rgb(97, 129, 129) !important;
}

.score {
  background: rgba(255,255,255,0.75);
  border-radius: 8px 8px 0px 0px;
  //border: 2px solid green;
  font-size: 15px;
  font-weight: bold;
  position: absolute;
  top: -21px;
  left: 13px;
  margin: auto !important;
  padding: 0px 10px 0px 10px;
  }

#xerxes {
  position: absolute;
  bottom: 0px;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  font-family: Brush Script MT;
  font-size: 5vmin;
  color: rgb(47, 79, 79);
}

#authorHint {
  position: absolute;
  bottom: 7px;
  left: 50%;
  transform: translate(-50%);
  margin: auto;
  font-size: 16px;
}
            
          
!
            
              $(document).ready(function() {
  var randomImage = "";
  var randomImage2 = "";
  var realAuthor = "";
  var author = "";
  var randomNum = "";
  var myArr = [];
  var photoObj = {};
  var score = 0;
  var testVar;
  var firstClick = 0;

  function loadingPage() {
    testVar = setTimeout(showPage, 3000);
  }

  function showPage() {
    $(".loader-frame").fadeOut("slow", function() {
      $("#startButton").fadeIn("slow", function() {});
    });
  }

  function newImage() {
    var getPhoto = new XMLHttpRequest();
    getPhoto.open(
      "GET",
      "https://api.unsplash.com/photos/random/?client_id=165c0af0ea6f8f70a5c8f016a1df258ee7f957abfdb6d565cf0ec365a8561c6a&collections=140375"
    );

    function properCase(photographer) {
      var convertToArray = photographer.toLowerCase().split(" ");
      var result = convertToArray.map(function(val) {
        return val.replace(val.charAt(0), val.charAt(0).toUpperCase());
      });
      return result.join(" ");
    }

    getPhoto.onload = function() {
      var backgroundPhoto = JSON.parse(getPhoto.responseText);
      randomImage = backgroundPhoto["urls"]["full"];
      var photographer = backgroundPhoto["user"]["name"];
      var portfolioURL = backgroundPhoto["user"]["portfolio_url"];
      $(".screen").css("background-image", "url('" + randomImage + "')");
      $("#anchor").attr("href", portfolioURL);
      $("#photographerCredit").text(properCase(photographer));
    };
    getPhoto.send();
  }

  function nextQuote() {
    //newImage();
    jsonQuote(author, Math.floor(Math.random() * 100000));
    jsonQuote(author, Math.floor(Math.random() * 100000));
    jsonQuote(author, Math.floor(Math.random() * 100000));
  }

  function doubleAuthor() {
    if (
      myArr[0][0] == myArr[1][0] ||
      myArr[0][0] == myArr[2][0] ||
      myArr[2][0] == myArr[1][0]
    ) {
      nextQuote();
    }
  }

  function jsonQuote(author, randomNum) {
    var url =
      "https://api.forismatic.com/api/1.0/?method=getQuote&key=" +
      randomNum +
      "&lang=en&format=jsonp&jsonp=?";

    $.getJSON(url, function(json) {
      author = json.quoteAuthor;
      if (author == "" || author == " ") {
        author = "Anonymous";
      }
      myArr.push([author, randomNum]);

      if (myArr.length === 3) {
        doubleAuthor();
        var jsonQuote = json.quoteText;
        realAuthor = author;

        // Sort Authors randomly
        myArr.sort(function(a, b) {
          return a[1] - b[1];
        });

        $("#authorButton").fadeIn(1500);

        // Add quotes and author buttons
        $(".message").text(jsonQuote);
        $("#answer0").text(myArr[0][0]);
        $("#answer1").text(myArr[1][0]);
        $("#answer2").text(myArr[2][0]);
        myArr = [];
      }
    });
  }

  function tweetQuote() {
    window.open(
      "https://twitter.com/intent/tweet?text=" +
        '"' +
        document.getElementById("quoteText").innerHTML +
        '"' +
        "  - " +
        realAuthor
    );
  }

  loadingPage();
  newImage();

  $(".startButton").on("click", function() {
    $("#startButton")
      .add($("#intro"))
      .fadeOut("fast", function() {});
    $("#xerxes").fadeOut("fast", function() {});
    $("#screen").fadeIn(2000, function() {
      $("#quoteBox")
        .css("display", "flex")
        .addClass("animated bounceInUp");
      $("#photographerCredit")
        .css("display", "inherit")
        .addClass("animated bounceInUp");
      $("#refreshButton").trigger("click");
    });
  });

  $("#refreshButton").on("click", function() {
    if (firstClick == 0) {
      $("#answer0")
        .css("display", "initial")
        .addClass("animated bounceInRight");
      $("#answer1")
        .css("display", "initial")
        .addClass("animated bounceInLeft");
      $("#answer2")
        .css("display", "initial")
        .addClass("animated bounceInRight");
      nextQuote();
      firstClick++;
    } else if (document.getElementById("answer0").innerHTML == realAuthor) {
      score = -1;
      $("#answer0").trigger("click");
      setTimeout(function() {
        newImage();
      }, 1500);
    } else if (document.getElementById("answer1").innerHTML == realAuthor) {
      score = -1;
      $("#answer1").trigger("click");
      setTimeout(function() {
        newImage();
      }, 1500);
    } else if (document.getElementById("answer2").innerHTML == realAuthor) {
      score = -1;
      $("#answer2").trigger("click");
      setTimeout(function() {
        newImage();
      }, 1500);
    }
  }); //refreshButton Close

  $("#tweetButton").on("click", function() {
    tweetQuote();
  });

  // Show tooltips when mouse hovers over info
  document.getElementById("infoButton").onmouseenter = function() {
    $("#infoBoxRefresh")
      .fadeIn("slow")
      .css("display", "flex");
    $("#infoBoxScore")
      .fadeIn("slow")
      .css("display", "flex");
    $("#infoBoxPhoto")
      .fadeIn("slow")
      .css("display", "flex");
    $("#infoBox").css("height", "20px");
    $("#infoBox").css("width", "80px");
    var photoButtonWidth = $("#photographerCredit").innerWidth();
    $("#infoBoxPhoto").css("right", photoButtonWidth + 11);
  };

  // Remove toltips when mouse leaves info button
  document.getElementById("infoButton").onmouseleave = function() {
    $("#infoBoxRefresh").fadeOut("slow");
    $("#infoBoxScore").fadeOut("slow");
    $("#infoBoxPhoto").fadeOut("slow");
  };

  $("#answer0").click(function() {
    $(this)
      .prop("disabled", true)
      .css("opacity", 1);
    $("#answer1")
      .prop("disabled", true)
      .css("opacity", 1);
    $("#answer2")
      .prop("disabled", true)
      .css("opacity", 1);
    var answer0 = document.getElementById("answer0").innerHTML;
    var answer1 = document.getElementById("answer1").innerHTML;
    var answer2 = document.getElementById("answer2").innerHTML;

    if (answer0 == realAuthor) {
      score++;
      $("#answer0").addClass("correct");
      console.log("Answer0 is correct");
      $("#answer1").addClass("incorrect");
      $("#answer2").addClass("incorrect");

      setTimeout(function() {
        nextQuote();
        $("#answer0")
          .removeClass("correct")
          .prop("disabled", false);
        $("#answer1")
          .removeClass("incorrect")
          .prop("disabled", false);
        $("#answer2")
          .removeClass("incorrect")
          .prop("disabled", false);
      }, 1500);
    } else if (answer1 == realAuthor) {
      $("#answer0").addClass("incorrect");
      $("#answer1").addClass("correct");
      $("#answer2").addClass("incorrect");

      setTimeout(function() {
        nextQuote();
        $("#answer1")
          .removeClass("correct")
          .prop("disabled", false);
        $("#answer0")
          .removeClass("incorrect")
          .prop("disabled", false);
        $("#answer2")
          .removeClass("incorrect")
          .prop("disabled", false);
      }, 1500);
      score = 0;
    } else if (answer2 == realAuthor) {
      $("#answer0").addClass("incorrect");
      $("#answer1").addClass("incorrect");
      $("#answer2").addClass("correct");

      setTimeout(function() {
        nextQuote();
        $("#answer2")
          .removeClass("correct")
          .prop("disabled", false);
        $("#answer1")
          .removeClass("incorrect")
          .prop("disabled", false);
        $("#answer0")
          .removeClass("incorrect")
          .prop("disabled", false);
      }, 1500);
      score = 0;
    }
    $(".score").html(score);
  });

  $("#answer1").click(function() {
    $(this)
      .prop("disabled", true)
      .css("opacity", 1);
    $("#answer0")
      .prop("disabled", true)
      .css("opacity", 1);
    $("#answer2")
      .prop("disabled", true)
      .css("opacity", 1);
    var answer0 = document.getElementById("answer0").innerHTML;
    var answer1 = document.getElementById("answer1").innerHTML;
    var answer2 = document.getElementById("answer2").innerHTML;

    if (answer1 == realAuthor) {
      score++;
      $("#answer1").addClass("correct");
      $("#answer0").addClass("incorrect");
      $("#answer2").addClass("incorrect");

      setTimeout(function() {
        nextQuote();
        $("#answer1")
          .removeClass("correct")
          .prop("disabled", false);
        $("#answer0")
          .removeClass("incorrect")
          .prop("disabled", false);
        $("#answer2")
          .removeClass("incorrect")
          .prop("disabled", false);
      }, 1500);
    } else if (answer0 == realAuthor) {
      $("#answer0").addClass("correct");
      $("#answer1").addClass("incorrect");
      $("#answer2").addClass("incorrect");

      setTimeout(function() {
        nextQuote();
        $("#answer0")
          .removeClass("correct")
          .prop("disabled", false);
        $("#answer1")
          .removeClass("incorrect")
          .prop("disabled", false);
        $("#answer2")
          .removeClass("incorrect")
          .prop("disabled", false);
      }, 1500);
      score = 0;
    } else if (answer2 == realAuthor) {
      $("#answer0").addClass("incorrect");
      $("#answer1").addClass("incorrect");
      $("#answer2").addClass("correct");

      setTimeout(function() {
        nextQuote();
        $("#answer0")
          .removeClass("incorrect")
          .prop("disabled", false);
        $("#answer1")
          .removeClass("incorrect")
          .prop("disabled", false);
        $("#answer2")
          .removeClass("correct")
          .prop("disabled", false);
      }, 1500);
      score = 0;
    }
    $(".score").html(score);
  });

  $("#answer2").click(function() {
    $(this)
      .prop("disabled", true)
      .css("opacity", 1);
    $("#answer0")
      .prop("disabled", true)
      .css("opacity", 1);
    $("#answer1")
      .prop("disabled", true)
      .css("opacity", 1);
    var answer0 = document.getElementById("answer0").innerHTML;
    var answer1 = document.getElementById("answer1").innerHTML;
    var answer2 = document.getElementById("answer2").innerHTML;

    if (answer2 == realAuthor) {
      score++;
      $("#answer2").addClass("correct");
      $("#answer0").addClass("incorrect");
      $("#answer1").addClass("incorrect");

      setTimeout(function() {
        nextQuote();
        $("#answer2")
          .removeClass("correct")
          .prop("disabled", false);
        $("#answer0")
          .removeClass("incorrect")
          .prop("disabled", false);
        $("#answer1")
          .removeClass("incorrect")
          .prop("disabled", false);
      }, 1500);
    } else if (answer1 == realAuthor) {
      $("#answer0").addClass("incorrect");
      $("#answer1").addClass("correct");
      $("#answer2").addClass("incorrect");

      setTimeout(function() {
        nextQuote();
        $("#answer0")
          .removeClass("incorrect")
          .prop("disabled", false);
        $("#answer1")
          .removeClass("correct")
          .prop("disabled", false);
        $("#answer2")
          .removeClass("incorrect")
          .prop("disabled", false);
      }, 1500);
      score = 0;
    } else if (answer0 == realAuthor) {
      $("#answer0").addClass("correct");
      $("#answer1").addClass("incorrect");
      $("#answer2").addClass("incorrect");

      setTimeout(function() {
        nextQuote();
        $("#answer0")
          .removeClass("correct")
          .prop("disabled", false);
        $("#answer1")
          .removeClass("incorrect")
          .prop("disabled", false);
        $("#answer2")
          .removeClass("incorrect")
          .prop("disabled", false);
      }, 1500);
      score = 0;
    }
    $(".score").html(score);
  });
});

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console