fluxer-website/script.js

109 lines
6.7 KiB
JavaScript
Executable file

(function () {
var reveals = document.querySelectorAll('.reveal');
if ('IntersectionObserver' in window) {
var observer = new IntersectionObserver(function (entries) {
entries.forEach(function (entry) {
if (entry.isIntersecting) {
entry.target.classList.add('is-visible');
observer.unobserve(entry.target);
}
});
}, { threshold: 0.12, rootMargin: '0px 0px -40px 0px' });
reveals.forEach(function (el, i) {
if (el.closest('.cards') || el.closest('.faq')) {
el.style.setProperty('--delay', (i % 4) * 0.08 + 's');
}
observer.observe(el);
});
} else {
reveals.forEach(function (el) { el.classList.add('is-visible'); });
}
document.querySelectorAll('.card').forEach(function (card) {
card.addEventListener('pointermove', function (e) {
var rect = card.getBoundingClientRect();
card.style.setProperty('--mx', (e.clientX - rect.left) + 'px');
card.style.setProperty('--my', (e.clientY - rect.top) + 'px');
});
});
var chat = document.querySelector('.mock-chat');
if (chat) {
var names = ['Sam', 'Ruth', 'Kai', 'Milo', 'Jules', 'Bea', 'Ollie', 'Finn', 'Pip', 'Nora', 'Leo', 'Ada'];
// Each convo: [speakerIndex, message] x3. speakerIndex 0-2 maps to chosen names.
var convos = [
// knock-knock (joker=0, responder=1, joker=0)
[[0,"Knock, knock!"], [1,"Who's there?"], [0,"Lettuce. Lettuce who? Lettuce in, it's cold out here!"]],
[[0,"Knock, knock!"], [1,"Who's there?"], [0,"Cow says. Cow says who? No silly, cow says moo!"]],
[[0,"Knock, knock!"], [1,"Who's there?"], [0,"Tank. Tank who? You're welcome!"]],
[[0,"Knock, knock!"], [1,"Who's there?"], [0,"Alpaca. Alpaca who? Alpaca the snacks, you grab the map!"]],
[[0,"Knock, knock!"], [1,"Who's there?"], [0,"Dishes. Dishes who? Dishes the police, open up!"]],
[[0,"Knock, knock!"], [1,"Who's there?"], [0,"Cargo. Cargo who? Cargo beep beep, vroom vroom!"]],
[[0,"Knock, knock!"], [1,"Who's there?"], [0,"Nobel. Nobel who? Nobel, that's why I knocked!"]],
[[0,"Knock, knock!"], [1,"Who's there?"], [0,"Butter. Butter who? Butter open the door, it's chilly!"]],
[[0,"Knock, knock!"], [1,"Who's there?"], [0,"Etch. Etch who? Bless you!"]],
[[0,"Knock, knock!"], [1,"Who's there?"], [0,"Ketchup. Ketchup who? Ketchup with me and I'll tell you!"]],
[[0,"Knock, knock!"], [1,"Who's there?"], [0,"Owls say. Owls say who? Yep, they sure do!"]],
[[0,"Knock, knock!"], [1,"Who's there?"], [0,"Annie. Annie who? Annie thing you can do, I can do better!"]],
// dad jokes / banter (2 people)
[[0,"Why did the scarecrow get promoted?"], [1,"No idea, why?"], [0,"He was outstanding in his field!"]],
[[0,"I'm reading a book on anti-gravity."], [1,"Oh yeah? How is it?"], [0,"Impossible to put down!"]],
[[0,"What do you call a fake noodle?"], [1,"Hmm... I give up."], [0,"An impasta!"]],
[[0,"Why don't eggs tell jokes?"], [1,"Why not?"], [0,"They'd crack each other up!"]],
[[0,"Did you hear about the claustrophobic astronaut?"], [1,"Oh no, what happened?"], [0,"He just needed a little space."]],
[[0,"What do you call cheese that isn't yours?"], [1,"What?"], [0,"Nacho cheese!"]],
[[0,"Why did the bicycle fall over?"], [1,"Why?"], [0,"It was two-tired!"]],
[[0,"What did the ocean say to the beach?"], [1,"What did it say?"], [0,"Nothing, it just waved!"]],
[[0,"Why can't you trust stairs?"], [1,"Tell me."], [0,"They're always up to something."]],
[[0,"What do you call a bear with no teeth?"], [1,"A what?"], [0,"A gummy bear!"]],
[[0,"I'm afraid for the calendar."], [1,"Why's that?"], [0,"Its days are numbered."]],
[[0,"What do you call a fish with no eyes?"], [1,"I don't know..."], [0,"A fsh!"]],
[[0,"Why did the math book look so sad?"], [1,"Poor thing, why?"], [0,"It had too many problems."]],
[[0,"I made a belt out of watches."], [1,"And...?"], [0,"It was a waist of time."]],
[[0,"Why do cows have hooves instead of feet?"], [1,"Why?"], [0,"Because they lactose!"]],
[[0,"What do you call a dog that can do magic?"], [1,"What?"], [0,"A Labracadabrador!"]],
[[0,"Why don't scientists trust atoms?"], [1,"Why?"], [0,"Because they make up everything!"]],
[[0,"What do you call a sleeping dinosaur?"], [1,"I dunno."], [0,"A dino-snore!"]],
[[0,"Why did the golfer bring two pairs of pants?"], [1,"Just in case...?"], [0,"In case he got a hole in one!"]],
[[0,"What do you call a pile of cats?"], [1,"What?"], [0,"A meowtain!"]],
[[0,"I used to be a baker."], [1,"Oh really?"], [0,"Yeah, but I couldn't make enough dough."]],
// 3-person chats
[[0,"What do you call a factory that makes okay products?"], [1,"I don't know, what?"], [2,"A satisfactory!"]],
[[0,"I just got a job at the orange juice factory."], [1,"Nice! How is it?"], [2,"I heard he got fired because he couldn't concentrate."]],
[[0,"Why did the cookie go to the doctor?"], [1,"Why?"], [2,"Because it was feeling crummy!"]],
[[0,"I'm on a seafood diet."], [1,"Oh, how's that going?"], [2,"He sees food and eats it. Every time."]],
[[0,"Did you hear about the restaurant on the moon?"], [1,"No, what about it?"], [2,"Great food, no atmosphere!"]],
[[0,"What do you call a can opener that doesn't work?"], [1,"Uhh..."], [2,"A can't opener!"]],
[[0,"I told my dog a joke about fetch."], [1,"Did he laugh?"], [2,"Nah, tough crowd. He just gave you a ruff look."]],
[[0,"Why do seagulls fly over the sea?"], [1,"Why?"], [2,"Because if they flew over the bay, they'd be bagels!"]],
[[0,"What do sprinters eat before a race?"], [1,"Bananas?"], [2,"Nothing, they fast!"]],
[[0,"I asked the librarian if the library had books on paranoia."], [1,"And?"], [2,"She whispered, 'They're right behind you...'"]]
];
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;
}
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++) {
var speaker = convo[k][0];
html += '<div class="msg msg-' + (k + 1) + '">' +
'<span class="av ' + avs[speaker] + '"></span>' +
'<div><b>' + chosenNames[speaker] + '</b><p>' + convo[k][1] + '</p></div>' +
'</div>';
}
html += '<div class="typing"><span></span><span></span><span></span></div>';
chat.innerHTML = html;
}
})();