Make mock chat use conversational jokes
This commit is contained in:
parent
0f8f089fdc
commit
ba9a3924d2
1 changed files with 34 additions and 36 deletions
70
script.js
70
script.js
|
|
@ -32,54 +32,52 @@
|
|||
var chat = document.querySelector('.mock-chat');
|
||||
if (chat) {
|
||||
var names = ['Sam', 'Ruth', 'Kai', 'Milo', 'Jules', 'Bea', 'Ollie', 'Finn', 'Pip', 'Nora'];
|
||||
var pool = [
|
||||
"why did the scarecrow get promoted? he was outstanding in his field",
|
||||
"I told my computer I needed a break and it said 'no problem, I'll go to sleep'",
|
||||
"anyone else name their Wi-Fi something dramatic? mine is 'Pretty Fly for a Wi-Fi'",
|
||||
"I'm reading a book on anti-gravity. it's impossible to put down",
|
||||
"why don't eggs tell jokes? they'd crack each other up",
|
||||
"just tried to catch fog. I mist",
|
||||
"my dad said I should do lunges to stay in shape. that was a big step forward",
|
||||
"what do you call a fake noodle? an impasta",
|
||||
"I used to play piano by ear, but now I use my hands",
|
||||
"why did the bicycle fall over? it was two-tired",
|
||||
"I asked the dog for tech support. he just said 'ruff'",
|
||||
"I'm on a seafood diet. I see food and I eat it",
|
||||
"the rotation of the earth really makes my day",
|
||||
"why can't you trust stairs? they're always up to something",
|
||||
"I made a belt out of watches. it was a waist of time",
|
||||
"did you hear about the claustrophobic astronaut? he just needed a little space",
|
||||
"I would tell you a construction joke, but I'm still working on it",
|
||||
"what do you call cheese that isn't yours? nacho cheese",
|
||||
"my plants are thriving. I think they finally root for me",
|
||||
"why did the math book look sad? it had too many problems",
|
||||
"I got a job at a bakery because I kneaded dough",
|
||||
"singing in the shower is fun until you get soap in your mouth. then it's a soap opera",
|
||||
"I don't trust atoms. they make up everything",
|
||||
"what did the ocean say to the beach? nothing, it just waved",
|
||||
"I told a chemistry joke but there was no reaction",
|
||||
"just burned 2000 calories. I forgot the pizza in the oven",
|
||||
"why do cows have hooves instead of feet? because they lactose",
|
||||
"I'm afraid for the calendar. its days are numbered",
|
||||
"what do you call a bear with no teeth? a gummy bear",
|
||||
"parallel lines have so much in common... it's a shame they'll never meet"
|
||||
var convos = [
|
||||
["Knock, knock!", "Who's there?", "Lettuce. Lettuce who? Lettuce in, it's cold out here!"],
|
||||
["Knock, knock!", "Who's there?", "Cow says. Cow says who? No silly, cow says moo!"],
|
||||
["Knock, knock!", "Who's there?", "Tank. Tank who? You're welcome!"],
|
||||
["Knock, knock!", "Who's there?", "Alpaca. Alpaca who? Alpaca the snacks, you grab the map!"],
|
||||
["Knock, knock!", "Who's there?", "Dishes. Dishes who? Dishes the police, open up!"],
|
||||
["Knock, knock!", "Who's there?", "Cargo. Cargo who? Cargo beep beep, vroom vroom!"],
|
||||
["Why did the scarecrow get promoted?", "No idea, why?", "He was outstanding in his field!"],
|
||||
["I'm reading a book on anti-gravity.", "Oh yeah? How is it?", "Impossible to put down!"],
|
||||
["What do you call a fake noodle?", "Hmm... I give up.", "An impasta!"],
|
||||
["Why don't eggs tell jokes?", "Why not?", "They'd crack each other up!"],
|
||||
["Did you hear about the claustrophobic astronaut?", "Oh no, what happened?", "He just needed a little space."],
|
||||
["What do you call cheese that isn't yours?", "What?", "Nacho cheese!"],
|
||||
["Why did the bicycle fall over?", "Why?", "It was two-tired!"],
|
||||
["I used to play piano by ear.", "Really? That's impressive!", "Now I use my hands, it's much easier."],
|
||||
["What did the ocean say to the beach?", "What did it say?", "Nothing, it just waved!"],
|
||||
["Why can't you trust stairs?", "Tell me.", "They're always up to something."],
|
||||
["What do you call a bear with no teeth?", "A what?", "A gummy bear!"],
|
||||
["I'm afraid for the calendar.", "Why's that?", "Its days are numbered."],
|
||||
["What do you call a fish with no eyes?", "I don't know...", "A fsh!"],
|
||||
["Why did the math book look so sad?", "Poor thing, why?", "It had too many problems."],
|
||||
["I told my computer I needed a break.", "What did it say?", "Nothing, it just went to sleep."],
|
||||
["Anyone want to hear a construction joke?", "Sure!", "Never mind, I'm still working on it."],
|
||||
["I made a belt out of watches.", "And?", "It was a waist of time."],
|
||||
["Why do cows have hooves instead of feet?", "Why?", "Because they lactose!"],
|
||||
["What do you call a dog that can do magic?", "What?", "A Labracadabrador!"]
|
||||
];
|
||||
function pick(arr, n) {
|
||||
function pick(arr) {
|
||||
return arr[Math.floor(Math.random() * arr.length)];
|
||||
}
|
||||
function shuffle(arr) {
|
||||
var copy = arr.slice();
|
||||
for (var i = copy.length - 1; i > 0; i--) {
|
||||
var j = Math.floor(Math.random() * (i + 1));
|
||||
var t = copy[i]; copy[i] = copy[j]; copy[j] = t;
|
||||
}
|
||||
return copy.slice(0, n);
|
||||
return copy;
|
||||
}
|
||||
var chosenNames = pick(names, 3);
|
||||
var chosenMsgs = pick(pool, 3);
|
||||
var chosenNames = shuffle(names).slice(0, 3);
|
||||
var convo = pick(convos);
|
||||
var avs = ['av-a', 'av-b', 'av-c'];
|
||||
var html = '';
|
||||
for (var k = 0; k < 3; k++) {
|
||||
html += '<div class="msg msg-' + (k + 1) + '">' +
|
||||
'<span class="av ' + avs[k] + '"></span>' +
|
||||
'<div><b>' + chosenNames[k] + '</b><p>' + chosenMsgs[k] + '</p></div>' +
|
||||
'<div><b>' + chosenNames[k] + '</b><p>' + convo[k] + '</p></div>' +
|
||||
'</div>';
|
||||
}
|
||||
html += '<div class="typing"><span></span><span></span><span></span></div>';
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue