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.

            
                  <body class="htmlback">
        
        <div class="title">
            <h1 class="font"> Random Quote Machine</h1>
            
          <p>by <a href="https://codepen.io/morazajuan/full/OXNvGM" target="_blank"> Juan Moraza</p></a>
            
            <div class="textbox tex" ><span>
                <h2 id="container" class="message ">
                    Ready for a Quote? if yes, click the "Next Quote" button
              </h2> </span>
            </div>
            
        </div>
        
        <div>
            
            <button  id="getMessage" class="btn-loc cursor" type="button">Next Quote</button> <button class="btnTweet cursor">Tweet</button>

            
            
        </div>
      <span style="z-index:50;font-size:0.9em;"><img src="https://theysaidso.com/branding/theysaidso.png" height="20" width="20" alt="theysaidso.com"/><a href="https://theysaidso.com" title="Powered by quotes from theysaidso.com" style="color: #9fcc25; margin-left: 4px; vertical-align: middle;">theysaidso.com</a></span>
      
     

    </body>
            
          
!
            
               .htmlback{
                background-color:white;
            }
        .title{
            color: gray;
            text-align:center;
        }
button.cursor{
  cursor:pointer;
}
h1{
  font-family:"Comic Sans MS",cursive,sans-serif; 
  color: gray;
  
}
        .btn-loc{
         color:white;
          border-radius:5px;
          height: 30px;
           width: 80px;
            position: absolute;
            right: 10%;
          
        }
        .textbox{
            background-color:lightblue;
          position:relative;
          width: 100%;
          height: 200px;
          vertical-align:center;
          
}

span
{
     display: inline-block;
    vertical-align: middle;
  color: white;
}
         .btnTweet {
           height: 30px;
           width: 80px;
          background-color: #1da1f2;
         color: white;
          border-radius:5px;
           margin: 0 auto;
           display:block;

 }
        
            
          
!
            
              //Note  this site only works withou the "http://"  wich means if the page is ran as " https://codepen.io/morazajuan/full/zBPAqJ " it woulnt work but if instead is run as fallow,"codepen.io/morazajuan/full/zBPAqJ"it would work
$(document).ready(function() {
    	 var s =3;
     var textToTweet = "";

   
 $('#btnTweet').click(function (e) {
 alert('Tweet Quote');
 
 if (textToTweet.length > 140) {
 alert('Tweet should be less than 140 Chars');
 }else if (textToTweet.length < 1 ){
   alert('Please press the "Next Quote" button to tweet a quote')
 }
 else {
 var twtLink = 'https://twitter.com/home?status=' +encodeURIComponent(textToTweet);
 window.open(twtLink,'_blank');
 }
 });
 
    
    
    
$("#getMessage").delay(1000).on("click",function(){
     
      $.getJSON("https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=" + s, function(a) {

   
      $(".message").fadeOut(1000,function(){
  
 $(".message").empty().append(a[0].content + "<span>— " + a[0].title + "</span>")  .fadeIn(1000); 
        textToTweet=a[0].content + "<span>— " + a[0].title + "</span>";
        
        textToTweet=textToTweet.replace(/<p>/g,"");
        
        textToTweet=textToTweet.replace(/<\/p>/gm,"");
        textToTweet=textToTweet.replace(/<span>/g,"");
        textToTweet=textToTweet.replace(/<\/span>/gm,"");
        
        textToTweet=textToTweet.replace(/&#8230;/g,"...");
     textToTweet=textToTweet.replace(/&#8220;/g,"“"); 
 textToTweet=textToTweet.replace(/&#8221;/g,"”");      
      
      textToTweet=textToTweet.replace(/&#8211;/g,"–"); textToTweet=textToTweet.replace(/&#8217;/g,"'");
        console.log(textToTweet);
        
        
      });
        
     });
    s+=1;

    
});

});
        

            
          
!
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