cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              <div class="mt6 helvetica measure h-75 bg-white mw5 mw7-ns center pa3 ph5-ns">

  <div class="bg-white measure">
    <blockquote class="flex flex-column justify-center h5 ml0 mt0 mr4 pl4 black-90 bl bw2 b--blue" id="blockquote">
      <span id="text" class="f2"></span>
      <div class="f3">
        - <span id="author"></span>
      </div>
    </blockquote>
  </div>
  <div class="buttons">
    <a class="f6 link dim br2 ph3 pv2 mb2 dib white twitter" id="twitter"><i class = "fa fa-twitter"></i>  Tweet This</a>
    <a class="f6 link dim br2 ph3 pv2 mb2 dib white" id="new-quote">New quote</a>
  </div>

</div>
<div id="tweet-container"></div>


<form method="post" name="Form" action="" class="mt5">
  <label for="userName" class="mr4">If you want to make it personal, type your name: </label>
  <input cols="20" rows="1" name="userName" id="userName" placeholder="name"></input>
</form>


<footer class="mt3">
  <small class="ph3 ph4-ns pv6 white-70"> by 
    <a href="http://kevindav.us" class="static center link b f4 f4-ns dim white-70 lh-solid " target="_blank">Kevin Davis</a>
  </small>
</footer>
            
          
!
            
              .twitter{
  background-color: #00aced;
  text-decoration: none;
}

input{
      border: 5px solid white; 
    -webkit-box-shadow: 
      inset 0 0 8px  rgba(0,0,0,0.1),
            0 0 16px rgba(0,0,0,0.1); 
    -moz-box-shadow: 
      inset 0 0 8px  rgba(0,0,0,0.1),
            0 0 16px rgba(0,0,0,0.1); 
    box-shadow: 
      inset 0 0 8px  rgba(0,0,0,0.1),
            0 0 16px rgba(0,0,0,0.1); 
    padding: 1em;
    background: rgba(255,255,255,0.5);
    margin: 0 0 1em 0;
}

form{
    width: 30%;
    min-width: 25em;
    border: 5px solid white;
    padding: 15px;
    background: rgba(255,255,255,0.5);
    margin: 0 auto;
  
}
blockquote{
    flex-wrap: nowrap;
    min-width: 40em;
}

.buttons{
  -webkit-touch-callout: none; /* iOS Safari */
  -webkit-user-select: none;   /* Chrome/Safari/Opera */
  -khtml-user-select: none;    /* Konqueror */
  -moz-user-select: none;      /* Firefox */
  -ms-user-select: none;       /* Internet Explorer/Edge */
  user-select: none;           /* Non-prefixed version, currently
                                  not supported by any browser */
}

            
          
!
            
              const quote = document.getElementById("new-quote");
const tweet = document.getElementById("twitter");
let hasName = false;
let httpRequest = new XMLHttpRequest();
let pUrl;
let rUrl = 'https://api.whatdoestrumpthink.com/api/v1/quotes/random';
let quoteText;
const quoteAuthor = 'Donald Trump';

document.onreadystatechange = function() {
  if (document.readyState === "interactive") {
    document.forms["Form"]
    nameCheck();
  }
}
window.onload = randBackground;
quote.onclick = nameCheck;
twitter.onclick = tweetIt;
function randBackground() {
  let color = '#' + Math.floor(Math.random() * 16777215).toString(16);
  quote.style.background = color;
  document.getElementById("blockquote").style["border-color"] = color;
};

function newQuote() {
  if (!hasName) {
    makeRequest(rUrl);
  } else {
    makeRequest(pUrl);
  }
}
  function makeRequest(url) {
    httpRequest = new XMLHttpRequest();

    if (!httpRequest) {
      console.log('Giving up :( Cannot create an XMLHTTP instance');
      return false;
    }
    httpRequest.onreadystatechange = alertContents;
    httpRequest.open('GET', url);
    httpRequest.send();
  };

  function alertContents() {
    if (httpRequest.readyState === XMLHttpRequest.DONE) {
      randBackground();
      if (httpRequest.status === 200) {
        quoteText = JSON.parse(httpRequest.responseText).message;
        document.getElementById("text").textContent = quoteText;
        document.getElementById("author").textContent = quoteAuthor;

       // console.log(JSON.parse(httpRequest.responseText).message);
      } else {
        console.log('There was a problem with the request.');
      }
    }
  };

 function nameCheck()
    {
    let nameValue =document.forms["Form"]["userName"].value;
      if (nameValue ==null||nameValue==""){
        hasName = false;
      //console.log(nameValue=="");
      }
      else {
        hasName = true;
        pUrl = "https://api.whatdoestrumpthink.com/api/v1/quotes/personalized?q=" + nameValue;
      }
      newQuote();
      
    }
function tweetIt(){
  let tweetText = quoteText + " - " + quoteAuthor;
  if (tweetText.length > 140) {
 alert('Tweet should be less than 140 Chars');
 }
 else {
 var twtLink = 'https://twitter.com/intent/tweet?text=' +encodeURI(tweetText)+'&related=kevindavus,freecodecamp,codenewbies';
   console.log(tweetText);
   console.log(twtLink);
 window.open(twtLink,'_blank');
 }
}
            
          
!
999px
Loading ..................

Console