HoldTheButton/script.js
2025-05-26 21:27:03 -04:00

362 lines
No EOL
12 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Initialize particles.js
particlesJS('particles-js', {
particles: {
number: {
value: 80,
density: {
enable: true,
value_area: 800
}
},
color: {
value: '#ffffff'
},
shape: {
type: 'circle'
},
opacity: {
value: 0.5,
random: false
},
size: {
value: 3,
random: true
},
line_linked: {
enable: true,
distance: 150,
color: '#ffffff',
opacity: 0.4,
width: 1
},
move: {
enable: true,
speed: 2,
direction: 'none',
random: false,
straight: false,
out_mode: 'out',
bounce: false
}
},
interactivity: {
detect_on: 'canvas',
events: {
onhover: {
enable: true,
mode: 'grab'
},
onclick: {
enable: true,
mode: 'push'
},
resize: true
}
},
retina_detect: true
});
// DOM elements
const holdButton = document.getElementById('holdButton');
const timer = document.getElementById('timer');
const message = document.getElementById('message');
const resultContainer = document.getElementById('resultContainer');
const result = document.getElementById('result');
// Variables
let startTime;
let timerInterval;
let isHolding = false;
let buttonText = holdButton.querySelector('span');
// Random messages while holding
const holdingMessages = [
"Time is just a construct, right?",
"You're transcending reality.",
"The universe is watching you.",
"Is your arm okay?",
"Do you do this for sport?",
"You're redefining persistence.",
"You're officially holding reality together.",
"Just you and the void now.",
"What are you trying to prove?",
"I hope you're charging rent for your dedication.",
"This is borderline mythological.",
"Even statues blink eventually.",
"Are you trying to summon something?",
"You're writing history with your finger.",
"Blink twice if you're stuck.",
"You might be stuck in a time loop.",
"Legends start just like this.",
"Have you considered letting go... just kidding!",
"Still? I'm out of things to say!",
"I should be charging for this show.",
"You're more committed than some relationships.",
"Your screen is going to imprint your fingerprint.",
"Can we get a slow clap going?",
"You're raising the bar and then some.",
"I'm starting to believe you're a machine.",
"Even the code is impressed.",
"Reality might bend soon.",
"You're a digital monk now.",
"Still holding? Your screen says hi.",
"This is what dedication smells like... probably.",
"If effort was money, you'd be a billionaire.",
"Time is melting around you.",
"Every second, you enter deeper legend.",
"You may be achieving enlightenment.",
"This is your legacy now.",
"You clearly dont fear cramps.",
"Heroes don't always wear capes.",
"I'm speechless... you're not.",
"You're holding like the Wi-Fi signal depends on it.",
"I think you unlocked ultra-hold mode.",
"Even gravity is impressed.",
"You're ignoring the laws of boredom.",
"This isn't even your final form.",
"The simulation is glitching just watching you.",
"You're becoming folklore.",
"Youve reached the point of no return.",
"You broke the give-up meter.",
"You outlasted my motivational quotes.",
"Are you aiming for the Guinness World Record?",
"At this point, I'm emotionally invested.",
"You're becoming legend in real time.",
"All of this for what? Oh right—immortality.",
"Hold level: Ascended.",
"You're now an honorary statue.",
"Existential crises start here.",
"You're challenging the laws of patience.",
"Your willpower could power a small town.",
"You're so deep in, I cant let you stop.",
"This is how digital devotion looks.",
"Youll need a recovery arc after this.",
"Even Im nervous for you.",
"Youve reached overachiever mode.",
"You're passing into the mythos now.",
"The button might be scared of you.",
"I think you just invented a new sport.",
"This is your endurance saga.",
"Still holding. The stars are aligning.",
"Youre one hold away from godhood.",
"Your thumb deserves its own biography.",
"There are monks less dedicated than this.",
"Youre holding onto greatness—literally.",
"Youve entered the Matrix hold level.",
"Reality checks in... still holding.",
"Are your bones okay?",
"You're breaking records in another dimension.",
"You're now holding the universe together.",
"Your phone might evolve from this.",
"NASA might want to study you.",
"You're showing the world what's possible.",
"The screen is probably sweating now.",
"Who needs sleep when you have this?",
"I bet the device is questioning its purpose.",
"You're entering final form: Hold God.",
"Still? I'm writing a song about you.",
"This isn't holding—it's art.",
"I can feel the strain through the code.",
"You're distorting time with your will.",
"You're holding like a black hole grips light.",
"You may have just glitched reality.",
"Youre now part of the code.",
"A statue couldnt keep up with you.",
"Youre outperforming machines.",
"Your name shall echo through holding halls.",
"Still here? Youre writing digital lore.",
"This is holdvana. Welcome.",
"If there was a throne, you'd sit on it.",
"Youve held longer than most people dream.",
"Reality salutes your grip.",
"You're in another timeline now.",
"I hope this gets written in history books.",
"You're unshakable. Literally.",
"I stopped counting. You're still holding.",
"A galaxy was born during this hold."
];
// Snarky result messages
const resultMessages = [
"Did you ascend while holding?",
"That was a full spiritual journey.",
"You defied all known limits.",
"Your phone thinks you're stuck.",
"I need to sit down after watching that.",
"You may have entered another plane.",
"That was less of a hold, more of a legend.",
"No one will believe this—print the T-shirt.",
"What sorcery is this?",
"Please seek professional help... for awesomeness.",
"You have a new identity now: The Holder.",
"Statues have nothing on you.",
"Im 99% sure you transcended reality.",
"Was this a dare? A quest? A destiny?",
"You're a holding deity now.",
"Next step: documentary film.",
"Do you even feel your finger anymore?",
"You broke my internal timer!",
"You passed the test... that no one asked for.",
"That was the digital version of a marathon.",
"I'm getting jealous of your finger strength.",
"You've set a precedent for future generations.",
"This is your superhero origin story.",
"That hold was practically a time capsule.",
"You earned honorary screen rights.",
"I ran out of congratulations halfway through.",
"You need a cape and a trophy.",
"Youve been upgraded to Ultra User.",
"Is it over? Or is it just the beginning?",
"That wasn't holding, that was history-making.",
"The universe blinked. You didnt.",
"You just changed the definition of patience.",
"You shattered the digital fourth wall.",
"You deserve a monument in an app store.",
"I hope your battery held as well as you.",
"My circuits cant process that level of commitment.",
"I'm rethinking reality after that.",
"That wasn't a test. That was a declaration.",
"This hold deserves an NFT.",
"Award yourself a nap. A long one.",
"You probably warped time and space.",
"Someone get this user a medal—stat!",
"You've redefined what 'long press' means.",
"This is now your personality trait.",
"Are your fingerprints still intact?",
"That was a saga. A true epic.",
"You won. Whatever this was, you won.",
"Your finger now has legendary status.",
"This app will remember you forever.",
"You held so long I started to worry.",
"You should charge admission to your skill.",
"You were holding more than a button—you held fate.",
"You broke my snark barrier. Respect.",
"Your future memoir starts with this.",
"I bow to your resolve.",
"I ran out of excuses to doubt you.",
"I don't even have jokes left—just awe.",
"Holding like that? That's science fiction.",
"This deserves a museum exhibit.",
"Did your soul temporarily exit your body?",
"You unlocked the ancient holding technique.",
"Reality bent. You didnt.",
"This is beyond mortal comprehension.",
"Are you part machine?",
"The screen now fears you.",
"That was pure digital sorcery.",
"Youve crossed into myth.",
"People will whisper your time in awe.",
"This achievement deserves music.",
"You broke a record and maybe some bones.",
"Epic doesn't begin to cover it.",
"Do you feel different now?",
"You need a certificate for that.",
"Some say you're still holding... spiritually.",
"That was endurance theater.",
"The button says thank you... and sorry.",
"You time-traveled with sheer determination.",
"You deserve a monument and a break.",
"You made boredom bow to you.",
"That was uncharted excellence.",
"You deserve a cinematic universe.",
"Youre now part of the lore.",
"You outlasted reason itself.",
"I need to lie down from watching.",
"Finger print? More like finger legend.",
"You made me believe in magic again.",
"You crushed expectations with your thumb.",
"I hereby knight you: Sir Hold-a-lot.",
"You earned bragging rights forever.",
"This goes in your résumé.",
"You and the button had a moment.",
"The button cried when you let go.",
"That was hold-fu mastery.",
"I need to recalibrate reality.",
"The internet will remember this.",
"That was a digital exorcism of limits.",
"Legends say youre still glowing.",
"I got emotional. Well done.",
"You made the impossible... look held.",
"Im impressed. And Im code.",
"This moment will echo through apps forever."
];
// Format time
function formatTime(ms) {
return (ms / 1000).toFixed(2) + 's';
}
// Update timer display
function updateTimer() {
const currentTime = Date.now();
const elapsedTime = currentTime - startTime;
timer.textContent = formatTime(elapsedTime);
}
// Get random message from array
function getRandomMessage(array) {
return array[Math.floor(Math.random() * array.length)];
}
// Change message with animation
function changeMessage(newMessage) {
message.classList.remove('changed');
void message.offsetWidth; // Trigger reflow
message.textContent = newMessage;
message.classList.add('changed');
}
// Start holding
holdButton.addEventListener('mousedown', () => {
if (!isHolding) {
isHolding = true;
startTime = Date.now();
timerInterval = setInterval(updateTimer, 10);
resultContainer.classList.remove('show');
buttonText.textContent = "Holding...";
// Start random messages
const messageInterval = setInterval(() => {
if (isHolding) {
changeMessage(getRandomMessage(holdingMessages));
} else {
clearInterval(messageInterval);
}
}, 3000);
}
});
// Stop holding
holdButton.addEventListener('mouseup', () => {
if (isHolding) {
isHolding = false;
clearInterval(timerInterval);
const finalTime = Date.now() - startTime;
// Show result
result.textContent = `${formatTime(finalTime)} - ${getRandomMessage(resultMessages)}`;
resultContainer.classList.add('show');
// Reset message and button text
message.textContent = "Ready to try again?";
buttonText.textContent = "Hold Me";
}
});
// Prevent context menu on long press
holdButton.addEventListener('contextmenu', (e) => {
e.preventDefault();
});
// Handle touch events for mobile
holdButton.addEventListener('touchstart', (e) => {
e.preventDefault();
holdButton.dispatchEvent(new MouseEvent('mousedown'));
});
holdButton.addEventListener('touchend', (e) => {
e.preventDefault();
holdButton.dispatchEvent(new MouseEvent('mouseup'));
});