Skip to content

Instantly share code, notes, and snippets.

@roberthamel
Created September 30, 2017 19:52
Show Gist options
  • Save roberthamel/c70d1569ab3e471e54c05661fd32211e to your computer and use it in GitHub Desktop.
Save roberthamel/c70d1569ab3e471e54c05661fd32211e to your computer and use it in GitHub Desktop.
freecodecampe-RandomQuoteMachine
#app
v-app.blue-grey.darken-1
v-layout
v-flex
v-card.blue-grey.darken-2.white--text.pa-3.mx-5.mt-5
v-card-title.text--center(primary-title)
.headline Random Quote Generator
v-card-text
div.ma-5.title "{{ quotes[current].quote }}" -- {{ quotes[current].author }}
v-card-actions.mb-2
v-spacer
v-btn.white--text(flat dark outline @click="getNewQuote()") Next Quote
v-btn.white--text(flat dark outline @click="tweet()") Tweet Quote
/* SOURCE: http://cubemonkey.net/quotes/ */
new Vue({
created () {
this.current = this.generateRandom()
},
data: {
quotes: [
{
quote: 'We cannot put off living until we are ready. The most salient characteristic of life is its coerciveness; it is always urgent, "here and now," without any possible postponement. Life is fired at us point blank.',
author: 'Ortega y Gasset'
},
{
quote: 'This is now. Later is later. ',
author: 'Unknown'
},
{
quote: 'Life sucks, but it\'s better than the alternative.',
author: 'Peter da Silva'
},
{
quote: 'Of course power tools and alcohol don\'t mix. Everyone knows power tools aren\'t soluble in alcohol...',
author: 'Crazy Nigel '
},
{
quote: '...Local prohibitions cannot block advances in military and commercial technology... Democratic movements for local restraint can only restrain the world\'s democracies, not the world as a whole.',
author: 'K. Eric Drexler '
},
{
quote: 'It ain\'t over until it\'s over.',
author: 'Casey Stengel'
},
{
quote: 'Abstainer: A weak person who yields to the temptation of denying himself a pleasure. A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the affairs of others.',
author: 'Ambrose Bierce'
},
{
quote: 'Largely because it is so tangible and exciting a program and as such will serve to keep alive the interest and enthusiasm of the whole spectrum of society...It is justified because...the program can give a sense of shared adventure and achievement to the society at large.',
author: 'Dr. Colin S. Pittendrigh'
},
{
quote: 'Perhaps I am flogging a straw herring in mid-stream, but in the light of what is known about the ubiquity of security vulnerabilities, it seems vastly too dangerous for university folks to run with their heads in the sand.',
author: 'Peter G. Neumann'
},
{
quote: 'The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs.',
author: 'Joseph Weizenbaum'
},
{
quote: 'I have not the slightest confidence in \'spiritual manifestations.\'',
author: 'Robert G. Ingersoll'
},
{
quote: 'There\'s only one way to have a happy marriage and as soon as I learn what it is I\'ll get married again.',
author: 'Clint Eastwood'
},
{
quote: 'The F-15 Eagle: If it\'s up, we\'ll shoot it down. If it\'s down, we\'ll blow it up.',
author: 'A McDonnel-Douglas ad from a few years ago'
},
{
quote: 'What a wonder is USENET; such wholesale production of conjecture from such a trifling investment in fact.',
author: 'Carl S. Gutekunst'
},
{
quote: 'One day I woke up and discovered that I was in love with tripe.',
author: 'Tom Anderson'
},
{
quote: 'Why should we subsidize intellectual curiosity?',
author: 'Ronald Reagan'
},
{
quote: 'He didn\'t run for reelection. `Politics brings you into contact with all the people you\'d give anything to avoid,\' he said. \`I\'m staying home.\`',
author: 'Garrison Keillor'
},
{
quote: 'Memories of you remind me of you.',
author: 'Karl Lehenbauer'
},
{
quote: 'It is not best to swap horses while crossing the river.',
author: 'Abraham Lincoln'
},
{
quote: 'An entire fraternity of strapping Wall-Street-bound youth. Hell - this is going to be a blood bath!',
author: 'Post Bros. Comics'
}
],
current: null
},
methods: {
generateRandom () {
return Math.floor(Math.random() * this.quotes.length)
},
getNewQuote () {
const newCurr = this.generateRandom()
newCurr === this.current ? this.current += 1 : this.current = newCurr
},
tweet () {
const { quote, author } = this.quotes[this.current]
window.open(`http://twitter.com/intent/tweet?hashtags=quotes&text="${quote}" -- ${author}`, '_blank').focus()
}
}
}).$mount('#app')
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/vuetify/dist/vuetify.js"></script>
<link href="https://unpkg.com/vuetify/dist/vuetify.min.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment