2.0.0 • Published 7 years ago

quote-roulette v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

quote-roulette

npm-package

yarn install quote-roulette
npm install quote-roulette

A whole npm package dedicated to Hollywood quotes?

Surely you can't be serious. I am serious... and don't call me Shirley.

How to Contribute

Fork this repo. Add a line to the end of quotes.txt and make a pull request.

Each line in quotes.txt should contain the IMDb title ID, a tab character, and the quote:

tt0304141	I solemnly swear that I am up to no good.

Browse imdb.com for quote transcripts and title IDs.

Format

quotes.json has the following structure:

{
    "quotes": []
}

Where quotes is an array of objects:

{
    "imdbID": "tt0304141",
    "quote": "I solemnly swear that I am up to no good.",
    "scooptvURL": "https://scooptv.io/title/tt0304141/",
    "imdbURL": "http://www.imdb.com/title/tt0304141/"
}

How to Use

jQuery

Put quotes.json somewhere on your server.

<div id="quote-roulette"></div
var quoteRoulette = $('#quote-roulette');
var allQuotes = null;

$.getJSON('/quotes.json', function(data) {
  allQuotes = data.quotes;
  updateQuote();
});

quoteRoulette.click(function(e) {
  e.preventDefault();

  updateQuote();
});

function updateQuote(obj) {
  var index = getRandomInt(0, allQuotes.length);

  quoteRoulette.text(allQuotes[index].quote);
}

// returns an integer, min <= integer < max
function getRandomInt(min, max) {
  min = Math.ceil(min);
  max = Math.floor(max);

  return Math.floor(Math.random() * (max - min)) + min;
}
2.0.0

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago