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.

+ 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.

            
              <div class="wrap">
  <div class="container">
    <div class="row">
      <div class="col-12-lg title">
        <h1 class="center-block"> Random Quote Generator </h1>
        <br>
        <h2 class="center-block"> A selection of quotes related to soccer/football </h2>
        <br>
      </div>
    </div>
    <div class="jumbotron" id="jumbotron">
      <p id="quote"> Press new quote to display a random quote. Press tweet to tweet the quote! </p>
      <p><small id="authorDate"> - Anthony Bruno, 2015 </small> </p>
    </div>
  </div>
  <div class="container center-block" id="buttons">
    <button class="btn btn-default" id="newQuote"> New Quote </button>
    <button class="btn btn-default" href="https://twitter.com/intent/tweet" id="tweet"> <i class="fa fa-twitter"></i> Tweet </button>
  </div>
</div>
            
          
!
            
              .wrap{
  background: url('http://seasonssoccerclub.org/wp-content/uploads/2015/12/o-SOCCER-facebook.jpg') no-repeat center center;
height:100vh;
}

.title {
  padding-top: 10vh;
  padding-bottom: 10vh;
}
#authorDate {
  float: right;
}

#quote {

}

.jumbotron{
  min-height: 175px; 
  box-shadow: 10px 10px 2px #000000;
}

.center-block {
  margin: 0 auto;
  float: none;
  text-align: center;
}

h1{
  font-weight: bold;
  color: white;
    text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000;  
}

h2 {
    color: white;
    text-shadow:
    -1px -1px 0 #000,
    1px -1px 0 #000,
    -1px 1px 0 #000,
    1px 1px 0 #000;  
}

.fa-twitter {
  color: #55acee
}
            
          
!
            
              /* --- Global variables for HTML elements  --- */
var newQuoteBtn = document.getElementById("newQuote");
var tweetBtn = document.getElementById("tweet");
var quote = document.getElementById("quote");
var authorDate = document.getElementById("authorDate");
/* ---       End of Global Variables      --- */

/* --- Adding Event Listeners to buttons --- */
if (newQuoteBtn.addEventListener) {
  newQuoteBtn.addEventListener("click", generateQuote, false);
} else if (newQuoteBtn.attachEvent) {
  newQuoteBtn.attachEvent('on click', generateQuote);
}
if (tweetBtn.addEventListener) {
  tweetBtn.addEventListener("click", tweetQuote, false);
} else if (tweetBtn.attachEvent) {
  tweetBtnattachEvent('on click', tweetQuote);
}
/* ---                                   --- */

/* Global Variable(s) */
var lastNumber = -1;
/*--------------------*/

/* Gets a quote and displays it */
function generateQuote() {
  var line = getQuote();
  line = line.split("|");
  quote.innerHTML = line[0];
  authorDate.innerHTML = " - "+line[1];
}


/* Returns random quote from quoteArray */
function getQuote() {
  var quoteArray = ["When I meet a European, the first thing I say is, “I’d much rather watch football than football.” But I’m just teasing them, and they know I’d really rather watch football than football.|Jarod Kintz","Many people say I'm the best women's soccer player in the world. I don't think so. And because of that, someday I just might be.|Mia Hamm","A penalty is a cowardly way to score.|Pelé","Football is a team sport and not an individual sport. We win as a team, and every individual is better if we are part of the team.|Fernando Torres","What I do is play soccer, which is what I like.|Lionel Messi","Football (soccer) is a matter of life and death, except more important.|Bill Shankly","Football is the ballet of the masses|Dmitri Shostakovich","International football is the continuation of war by other means|Eric Arthur Blair"];

do {
var randomNumber = Math.floor(Math.random() * quoteArray.length);
} while(randomNumber === lastNumber);
  
lastNumber = randomNumber;
return quoteArray[randomNumber];
}

/* opens a new window with the quote as a tweet */
function tweetQuote() {
  var quoteText = quote.innerHTML;
  window.open("https://twitter.com/intent/tweet?text="+quoteText+"&related=AnthonyBrunoAUS");
}


            
          
!
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