fluxer-website/script.js
2026-12-02 17:44:35 -05:00

86 lines
4.2 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'];
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) {
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++) {
html += '<div class="msg msg-' + (k + 1) + '">' +
'<span class="av ' + avs[k] + '"></span>' +
'<div><b>' + chosenNames[k] + '</b><p>' + convo[k] + '</p></div>' +
'</div>';
}
html += '<div class="typing"><span></span><span></span><span></span></div>';
chat.innerHTML = html;
}
})();