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 lang="en">
  <head>
    <link rel="stylesheet" type="text/css" href="QuoteMachine.css"/>
    
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> 
      
    <link href="https://fonts.googleapis.com/css?family=Dancing+Script|Nanum+Pen+Script|Raleway|Montserrat|Give+You+Glory|Indie+Flower|Open+Sans|Caveat|Gloria+Hallelujah|Mrs+Sheppards|Nanum+Brush+Script|Pacifico|Sacramento|Satisfy|Shadows+Into+Light" rel="stylesheet">    

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
   

    <!-- <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css">-->
    
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge"> 

    <title>Radek's Quote Machine</title>
  </head>

  <body class=class="randomColor" id='bdy'>


    <div class="container">
  <p id="quote">- </p>
  <p id="author"></p>



  <button type="button" class="btn btn-primary fa fa-twitter shadow" id="btnTweet"></button>
<!-- <button type="button" class="btn btn-primary fa fa-facebook shadow" id="btnFcb"></button> -->
<button type="button" class="btn btn-primary pull-right shadow" id="nextQuote">Next Quote</button>

    </div>

<div>
  <p id="impressum">coded by <a target="_blank" href="https://twitter.com/RadoKosiada">Radek</a></p>
</div>



<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js" type="text/javascript"></script>
      <!-- <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> -->
    <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
    -->

    <script type="text/javascript" src="QuoteMAchine.js"> </script>
  </body>
</html>
              
            
!

CSS

              
                body {
  display: none;
}

.container {
  /* border: 1px black solid; */
  border-radius: 10px;
  margin-top: 10em;
  background-color: white;
  padding-top: 10px;
  box-shadow: 20px 20px 8px grey;
  max-width: 35em !important;
  
};

#quote, #author {
  font-family: 'Indie Flower', cursive;
}

.btn {
  margin-bottom: 20px;
  border-color: white;
  font-size: 20em;
  min-width: 50px; 
  min-height: 50px;
  box-shadow: 5px 5px 5px grey;
}

#quote {
  font-size: 1.5em;
  font-style: italic;
  font-weight: 200;
}

#author {
  text-align: right;
  font-weight: bold;
}

#nextQuote {
  font-family: 'Indie Flower', cursive;
  font-size:1.5em;
  float: right;
  color: black;
  background-color: white !important;
  border-width: 3px !important;
  /* box-shadow: grey !important; */
  /* box-shadow: none; */
  box-shadow: 5px 5px 5px grey;
  };

.randomColor {
  color: g
}

.fa-twitter {
  color: white;
}

.pull-right {
  float: right !important;
}

#impressum {
  color: white !important; 
  font-weight: 300;
  text-align: center;
  margin-top: 2.5em;
  text-decoration: none;
  }

 
              
            
!

JS

              
                  var arrayOfFonts = [
      "'Pacifico', cursive",
      "'Dancing Script', cursive",
      "'Indie Flower', cursive",
      "'Give You Glory', cursive",
      "'Shadows Into Light', cursive",
      "'Gloria Hallelujah', cursive",
      "'Nanum Pen Script', cursive",
      "'Satisfy', cursive",
      "'Nanum Brush Script', cursive",
      "'Sacramento', cursive",
      "'Caveat', cursive",
     ];
  
function setQuote(d){
  var q = document.querySelector("#quote");
  q.innerHTML = d.quote;
  
  var a = document.querySelector("#author");
  a.innerHTML = '- ' + d.author;
  
  setRandomView();
};

function getRandom() {

// random color
  var letters = '0123456789ABCDEF';
  var color = '#';
  for (var i = 0; i < 6; i++) {
    color += letters[Math.floor(Math.random() * 16)];
  }
  randomColor=color;
  console.log(randomColor);

  // random font
  var randomFontNumber = Math.floor(Math.random() *arrayOfFonts.length); // (Math.random() *2 gives number between 0 and 1,99999..., thus we multiply it by 2 so we get 1,9 nd then Math.floor
  console.log(randomFontNumber);
  randomFont= arrayOfFonts[randomFontNumber];
  }

  function setRandomView() {

  
  // changing colors & family fonts
  getRandom();
  // background color
    document.querySelector("body").style.backgroundColor=randomColor;

  // // font color of quote & author
    // document.querySelector("#quote").style.color=randomColor;
    // document.querySelector("#author").style.color=randomColor;

  // // color of button
    document.querySelector("#btnTweet").style.backgroundColor=randomColor;
    // document.querySelector("#btnFcb").style.backgroundColor=randomColor;
    // document.querySelector("#nextQuote").style.backgroundColor=randomColor;

  // color of borders container
    document.querySelector(".container").style.borderColor=randomColor;
    document.querySelector("body").style.display ='block';
  // color of buttons
    // document.querySelector("#btnFcb").style.borderColor=randomColor;
    document.querySelector("#btnTweet").style.borderColor=randomColor;
    document.querySelector("#nextQuote").style.borderColor=randomColor;


  // changing fonts
    document.querySelector("#quote").style.fontFamily = randomFont;
    document.querySelector("#author").style.fontFamily = randomFont;
    document.querySelector("#nextQuote").style.fontFamily = randomFont;
    document.querySelector("#impressum").style.fontFamily = randomFont;
    
};


var randomColor;
var randomFont;
var lastRandomFund;
var QuoteAndAuthor;

// setQuote(data);

getQuoteFromServer();
document.getElementById("nextQuote").addEventListener("click", getQuoteFromServer);


function getQuoteFromServer() {
  console.log('called')
  $.ajax( {
    url: "https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1",
    success: function(arrayOfQuote) {
          console.log('success: ' + JSON.stringify(arrayOfQuote));
          newObject = {
           author: arrayOfQuote[0].title,
           quote: arrayOfQuote[0].content
         }
         setQuote(newObject);

         QuoteAndAuthor = newObject.quote.substring(3, newObject.quote.length - 6) + ' - ' + newObject.author;        
        outgoing();

    },
    
     error: function() {
      console.log('did not get data');
      alert("Sorry, the data cannot be triggered due to a server's issue. It's not my fault ;) Please try again later.")
    },

    cache: false
  });

}
// DRY dont repeat yourself

$("#newQuote").hover(
  function() {
  $(this).animate({ width:180, height:65}, 1000);
},
  function() {
  $(this).animate({ width:170, height:60}, 1000);
  },  
);

function outgoing(){
  
  console.log(textToTweet);
  var urlTweet= "https://twitter.com/home?status=" + $("#quote").text().trim() +  "%0D%0A" + $("#author").text().trim();
  
  console.log(urlTweet);
  window.open(urlTweet);
}

document.getElementById("btnTweet").addEventListener("click", outgoing);




              
            
!
999px

Console