fluxer-website/script.js
2026-12-02 17:50:46 -05:00

118 lines
7.3 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'];
// [speakerIndex, message]. speakerIndex 0-2 maps to chosen names.
var convos = [
// knock-knock (5 lines, proper format)
[[0,"Knock, knock!"],[1,"Who's there?"],[0,"Lettuce."],[1,"Lettuce who?"],[0,"Lettuce in, it's cold out here!"]],
[[0,"Knock, knock!"],[1,"Who's there?"],[0,"Cow says."],[1,"Cow says who?"],[0,"No silly, cow says moo!"]],
[[0,"Knock, knock!"],[1,"Who's there?"],[0,"Tank."],[1,"Tank who?"],[0,"You're welcome!"]],
[[0,"Knock, knock!"],[1,"Who's there?"],[0,"Alpaca."],[1,"Alpaca who?"],[0,"Alpaca the snacks, you grab the map!"]],
[[0,"Knock, knock!"],[1,"Who's there?"],[0,"Dishes."],[1,"Dishes who?"],[0,"Dishes the police, open up!"]],
[[0,"Knock, knock!"],[1,"Who's there?"],[0,"Cargo."],[1,"Cargo who?"],[0,"Cargo beep beep, vroom vroom!"]],
[[0,"Knock, knock!"],[1,"Who's there?"],[0,"Nobel."],[1,"Nobel who?"],[0,"Nobel, that's why I knocked!"]],
[[0,"Knock, knock!"],[1,"Who's there?"],[0,"Butter."],[1,"Butter who?"],[0,"Butter open the door, it's chilly!"]],
[[0,"Knock, knock!"],[1,"Who's there?"],[0,"Etch."],[1,"Etch who?"],[0,"Bless you!"]],
[[0,"Knock, knock!"],[1,"Who's there?"],[0,"Ketchup."],[1,"Ketchup who?"],[0,"Ketchup with me and I'll tell you!"]],
[[0,"Knock, knock!"],[1,"Who's there?"],[0,"Owls say."],[1,"Owls say who?"],[0,"Yep, they sure do!"]],
[[0,"Knock, knock!"],[1,"Who's there?"],[0,"Annie."],[1,"Annie who?"],[0,"Annie thing you can do, I can do better!"]],
[[0,"Knock, knock!"],[1,"Who's there?"],[0,"Boo."],[1,"Boo who?"],[0,"Hey, don't cry, it's just a joke!"]],
[[0,"Knock, knock!"],[1,"Who's there?"],[0,"Interrupting cow."],[1,"Interrupting cow wh-"],[0,"MOO!"]],
[[0,"Knock, knock!"],[1,"Who's there?"],[0,"Dozen."],[1,"Dozen who?"],[0,"Dozen anyone want to let me in?"]],
[[0,"Knock, knock!"],[1,"Who's there?"],[0,"Ice cream."],[1,"Ice cream who?"],[0,"Ice cream every time I see a scary movie!"]],
[[0,"Knock, knock!"],[1,"Who's there?"],[0,"Olive."],[1,"Olive who?"],[0,"Olive you and I miss you!"]],
// dad jokes / banter (3 lines, 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,"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,"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."]],
[[0,"What do you call a belt made of watches?"],[1,"What?"],[0,"A waist of time!"]],
[[0,"Why did the tomato blush?"],[1,"Why?"],[0,"It saw the salad dressing!"]],
// 3-person chats
[[0,"What do you call a factory that makes okay products?"],[1,"I don't know, what?"],[2,"A satisfactory!"]],
[[0,"Did you hear about the restaurant on the moon?"],[1,"No, what about it?"],[2,"Great food, no atmosphere!"]],
[[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,"What do you call a can opener that doesn't work?"],[1,"Uhh..."],[2,"A can't opener!"]],
[[0,"Why do seagulls fly over the sea?"],[1,"Why?"],[2,"Because if they flew over the bay, they'd be bagels!"]],
[[0,"I asked the librarian if they had books on paranoia."],[1,"And?"],[2,"She whispered, 'They're right behind you...'"]],
[[0,"What do sprinters eat before a race?"],[1,"Bananas?"],[2,"Nothing, they fast!"]],
[[0,"Why don't skeletons fight each other?"],[1,"Why not?"],[2,"They don't have the guts."]]
];
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 = '';
var delay = 0.8;
var lastDelay = 0.8;
for (var k = 0; k < convo.length; k++) {
var speaker = convo[k][0];
lastDelay = delay;
html += '<div class="msg msg-' + (k + 1) + '" style="animation-delay:' + delay.toFixed(2) + 's">' +
'<span class="av ' + avs[speaker] + '"></span>' +
'<div><b>' + chosenNames[speaker] + '</b><p>' + convo[k][1] + '</p></div>' +
'</div>';
delay += 1.8 + Math.random() * 1.4;
}
html += '<div class="typing"><span></span><span></span><span></span></div>';
chat.innerHTML = html;
var typing = chat.querySelector('.typing');
if (typing) typing.style.animationDelay = (lastDelay + 1.8).toFixed(2) + 's';
}
})();