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.

            
              <head>
  <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>
  <link rel="pingback" href="https://quotesondesign.com/xmlrpc.php">
</head>
<body>
<div id="main" class="container-fluid">
  <div class="quote_div jumbotron">
    <div class="quote text-left lead" id="quote">"
      If you can&#8217;t explain it simply, you don&#8217;t understand it well enough "
    </div>
    
    <div class="quote_by text-right" id="quote_by"><blockquote>
      Albert Einstein</blockquote>
    </div>
    
      <div class="foot">
        <div class="social_buttons btn-group">
        <a href="https://www.facebook.com/sharer.php?u=https://codepen.io/isaacgg/pen/ZOQKYE?editors=1111" target="_blank"
           class="btn btn-social-icon btn-lg btn-facebook facebook_button mySocialButtons" style="background-color:#3b5998; color:#fff">
          <i class="fa fa-facebook"></i>
        </a>
       
        <a href="https://twitter.com/share?url=https://codepen.io/isaacgg/pen/ZOQKYE?editors=1111&amp;text=The%20Quote%20&amp;hashtags=quotes" target="_blank" class="btn btn-social-icon btn-lg btn-twitter btn-info mySocialButtons twitter_button" style="background-color:#55acee; color:#fff">
          <i class="fa fa-twitter"></i>
          </a>
     
        <a href="https://plus.google.com/share?url=https://codepen.io/isaacgg/pen/ZOQKYE?editors=1111" target="_blank"
           class="btn btn-social-icon btn-lg btn-google btn-danger google_button mySocialButtons" style="background-color:#dd4b39; color:#fff">
          <i class="fa fa-google"></i>
        </a>
        </div>
        <div class="next_button">
          <button class="btn btn-lg button_main" id="next-quote">New Quote</button>
        </div>
    </div>
    
    </div>  
</div>
</body>
            
          
!
            
              
body{
  background-color: red;
}
.quote_div{
  position: absolute;
  top:50%;
  left:50%;
  background-color: #123123;
  width:480px;
  height:250px;
  margin-top: -125px;
  margin-left:-240px;
  
  padding-top: 20px;
  padding-left:20px;
  padding-right: 20px;
  padding-bottom: 20px;
  
  color:white;
}

.foot{
  position: absolute;
  bottom: 10%;
}
.social_buttons{
  display: inline-block;
  float: left;
  margin-left: -10px;
}
.next_button{
  display: inline-block;
  float: right;
  margin-left: 120px;
}
.quote{
  margin-bottom: 10px;
}
.quote_by{
  
}

            
          
!
            
              var quotes=[["If you can’t explain it simply, you don’t understand it well enough","Albert Einstein"],
            ["The difference between a weed and a flower is a judgement","Wayne Dyer"],
           ["The process is really just Iterate, Iterate, Iterate","Chris Clark"],
           ["We don&#8217;t get hired to make pretty things or win design awards. We get hired to solve business problems","James Bradley"],
           ["Don&#8217;t think","William Firebrace"],
           ["Typography has one plain duty before it and that is to convey information in writing. No argument or consideration can absolve typography from this duty","Emil Ruder"]];

var useTheAPI = true;

$(document).ready(function(){
  changeQuote();
  $("#next-quote").click(changeQuote);
});

function changeQuote(){
  var quote, author, idq, color1, color2;
  var speed = 1000;
  color1 = randomColor();
  /*color2 = randomColor();
  color2 = "#"+(parseInt("0xFFFFFF") - parseInt("0x"+color1)).toString(16);
  console.log(color2.toString(16));*/
  color2 = "white";
  color1 = "#"+color1;

  $('.quote_div').animate( { backgroundColor: color2 }, speed);
  $(".button_main").animate({backgroundColor: color2}, speed);
  $(".button_main").animate({color: color1}, speed);
  $(".button_main").css("border", color1+" solid");
  $(".quote_div").animate({color: color1}, speed);
  $("body").animate({backgroundColor: color1}, speed);
  
  var weblink = "https://quotesondesign.com/wp-json/posts?filter[orderby]=rand";//&filter[posts_per_page]=1&callback=?";
 
 if(useTheAPI){
   /*var weblink = "https://quotesondesign.com/wp-json/posts?filter[orderby]=rand";
  $.getJSON(weblink, function(val) {
    console.log("hola");
    author = val[0].title;
    quote = val[0].content;*/
    
   $.ajax({
     url: "https://andruxnet-random-famous-quotes.p.mashape.com/", 
     headers: {
               'Content-Type':'application/x-www-form-urlencoded',
               'X-Mashape-Key': "W5YILaESBKmshbgACjTBRCkYYcVIp1cU6l9jsn6OcfxWrkQmlw",
               'Accept': 'application/json'
            },
     success: function(val){
        var bar = jQuery.parseJSON(val);
        quote = bar.quote;
        author = bar.author;
       console.log(author);
       console.log(quote);
       updateHtml(quote, author);
     }});
      /*$.post("https://andruxnet-random-famous-quotes.p.mashape.com/?cat=movies", {
     'X-Mashape-Key': 'W5YILaESBKmshbgACjTBRCkYYcVIp1cU6l9jsn6OcfxWrkQmlw'
   }, function(data, status){
                console.log(data);
                });
   
  });*/
 }else{
  idq = selectRandomQuote();
  quote = quotes[idq][0];
  author = quotes[idq][1];
   
  updateHtml(quote, author);
 }

  /*console.log(title);
  $("#quote").html(title);
  $("#quote_by").html(content);*/
};

function updateHtml(quote, author){
    $("#quote").html(quote);
    $("#quote_by").html("<blockquote>"+author+"</blockquote>");
    
    $(".twitter_button").attr("href", "https://twitter.com/share?url=https://codepen.io/isaacgg/pen/ZOQKYE?editors=1111&amp;text="+quote+"&amp;hashtags=quotes");
  
    $(".facebook_button").attr("href", "https://www.facebook.com/sharer.php?u="+quote+"%20https://codepen.io/isaacgg/pen/ZOQKYE?editors=1111");
  
    $(".google_button").attr("href", "https://plus.google.com/share?url="+quote+"%20https://codepen.io/isaacgg/pen/ZOQKYE?editors=1111");
}

function selectRandomQuote(){
  return Math.floor(Math.random()*quotes.length);
}

function randomColor() {
  var color="";
  for (var i=0; i<6; i++){
    color += Math.floor(Math.random()*16).toString(16);
  }
  return color;
}
            
          
!
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.

Console