Skip to content

Instantly share code, notes, and snippets.

@ja-k-e
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save ja-k-e/cba7a9ea25b6d3a4693d to your computer and use it in GitHub Desktop.

Select an option

Save ja-k-e/cba7a9ea25b6d3a4693d to your computer and use it in GitHub Desktop.
Ridiculous Password Generator
<section>
<h1>You need a better password.</h1>
<input id=output />
<button id=input>Generate Ridiculous Password</button>
</section>
function Generator() {
var g = {
input: undefined,
output: undefined,
init: function(input,output) {
g.input = document.getElementById(input);
g.output = document.getElementById(output);
g.input.addEventListener('click', g.generatePassword);
},
generatePassword: function() {
var p = g.getPassword();
g.outputPassword(p);
},
getPassword: function() {
var dict = g.dictionary,
subj1 = dict.subjects[Math.floor(Math.random() * dict.subjects.length)],
verb = dict.verbs[Math.floor(Math.random() * dict.verbs.length)],
count = Math.round(Math.random() * dict.counts),
adj = dict.adjectives[Math.floor(Math.random() * dict.adjectives.length)],
noun = dict.nouns[Math.floor(Math.random() * dict.nouns.length)],
prep = dict.prepositions[Math.floor(Math.random() * dict.prepositions.length)],
subj2 = dict.subjects[Math.floor(Math.random() * dict.subjects.length)],
punct = dict.punctuations[Math.floor(Math.random() * dict.punctuations.length)],
pw = [subj1, verb, count, adj, noun, prep, subj2, punct].join("");
return pw;
},
outputPassword: function(p) {
g.output.value = p;
},
dictionary: {
subjects: ['Sophia', 'Emma', 'Olivia', 'Ava', 'Isabella', 'Mia', 'Zoe', 'Lily', 'Emily', 'Madelyn', 'Madison', 'Chloe', 'Charlotte', 'Aubrey', 'Avery', 'Abigail', 'Kaylee', 'Layla', 'Harper', 'Ella', 'Amelia', 'Arianna', 'Riley', 'Aria', 'Hailey', 'Hannah', 'Aaliyah', 'Evelyn', 'Addison', 'Mackenzie', 'Adalyn', 'Ellie', 'Brooklyn', 'Nora', 'Scarlett', 'Grace', 'Anna', 'Isabelle', 'Natalie', 'Kaitlyn', 'Lillian', 'Sarah', 'Audrey', 'Elizabeth', 'Leah', 'Annabelle', 'Kylie', 'Mila', 'Claire', 'Victoria', 'Maya', 'Lila', 'Elena', 'Lucy', 'Savannah', 'Gabriella', 'Callie', 'Alaina', 'Sophie', 'Makayla', 'Kennedy', 'Sadie', 'Skyler', 'Allison', 'Caroline', 'Charlie', 'Penelope', 'Alyssa', 'Peyton', 'Samantha', 'Liliana', 'Bailey', 'Maria', 'Reagan', 'Violet', 'Eliana', 'Adeline', 'Eva', 'Stella', 'Keira', 'Katherine', 'Vivian', 'Alice', 'Alexandra', 'Camilla', 'Kayla', 'Alexis', 'Sydney', 'Kaelyn', 'Jasmine', 'Julia', 'Cora', 'Lauren', 'Piper', 'Gianna', 'Paisley', 'Bella', 'London', 'Clara', 'Cadence', 'Jackson', 'Aiden', 'Liam', 'Lucas', 'Noah', 'Mason', 'Ethan', 'Caden', 'Jacob', 'Logan', 'Jayden', 'Elijah', 'Jack', 'Luke', 'Michael', 'Benjamin', 'Alexander', 'James', 'Jayce', 'Caleb', 'Connor', 'William', 'Carter', 'Ryan', 'Oliver', 'Matthew', 'Daniel', 'Gabriel', 'Henry', 'Owen', 'Grayson', 'Dylan', 'Landon', 'Isaac', 'Nicholas', 'Wyatt', 'Nathan', 'Andrew', 'Cameron', 'Dominic', 'Joshua', 'Eli', 'Sebastian', 'Hunter', 'Brayden', 'David', 'Samuel', 'Evan', 'Gavin', 'Christian', 'Max', 'Anthony', 'Joseph', 'Julian', 'John', 'Colton', 'Levi', 'Muhammad', 'Isaiah', 'Aaron', 'Tyler', 'Charlie', 'Adam', 'Parker', 'Austin', 'Thomas', 'Zachary', 'Nolan', 'Alex', 'Ian', 'Jonathan', 'Christopher', 'Cooper', 'Hudson', 'Miles', 'Adrian', 'Leo', 'Blake', 'Lincoln', 'Jordan', 'Tristan', 'Jason', 'Josiah', 'Xavier', 'Camden', 'Chase', 'Declan', 'Carson', 'Colin', 'Brody', 'Asher', 'Jeremiah', 'Micah', 'Easton', 'Xander', 'Ryder', 'Nathaniel', 'Elliot', 'Sean', 'Cole'],
verbs: ['Wants','Feeds','Gets','Awards','Gives','Kills','Disguises','Gifts','Grabs','Pours','Buys','Sells','Invests','Throws','Tries','Births','HighFives','Worships'],
counts: 2000,
adjectives: ['Greedy','Friendly','Ornery','Wonderful','Lonely','Needy','Spoiled','Lovely','Yellow','Bored','Crying','Upset','Happy','Elated'],
nouns: ['Dogs','Babies','Friends','Chickens','Cats','Men','Ladies','Goats','Ingredients'],
prepositions: ['On','For','In','Between','At','With','AccordingTo','Without','AsPaymentTo','ToAvenge','BecauseTheyHate','BecauseTheyLove','InsteadOf'],
punctuations: ['!','?','.']
}
}
return g;
}
var generator = new Generator();
generator.init('input', 'output');
body {
background: teal;
font-weight: 300;
}
section {
width: 95%;
max-width: 800px;
margin: 0 auto;
}
#input,
#output {
display: block;
box-sizing: border-box;
margin: 2rem auto;
text-align: center;
font-size: 1.5rem;
padding: 1rem;
border-radius: 0.25rem;
border: 1px solid darken(teal,5%);
}
#output {
width: 100%;
}
#input {
appearance: none;
background: lighten(teal,5%);
color: white;
text-shadow: -1px -1px 0px darken(teal,5%);
box-shadow: 0px 4px 0px 0px darken(teal,5%);
transition: box-shadow 100ms ease-out,
background 100ms ease-out;
outline: none;
&:hover, &:focus {
background: lighten(teal,10%);
}
&:active {
background: lighten(teal,5%);
box-shadow: 0px 0px 0px 0px darken(teal,5%);
}
}
::selection {
background: desaturate(lighten(teal,50%),60%);
}
h1 {
font-weight: 300;
color: white;
text-shadow: -1px -1px 0px darken(teal,5%);
text-align: center;
margin-top: 20vh;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment