dad-joke-generator / index.html
MarcusCorvus's picture
Add 3 files
e9a2348 verified
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dad Joke Generator</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.dad-hat {
position: absolute;
top: -20px;
left: 50%;
transform: translateX(-50%);
width: 100px;
height: 60px;
background-color: #f59e0b;
border-radius: 50% 50% 0 0;
z-index: 10;
}
.dad-hat::before {
content: '';
position: absolute;
bottom: -10px;
left: 0;
width: 100%;
height: 20px;
background-color: #92400e;
border-radius: 0 0 50% 50%;
}
.dad-hat::after {
content: '';
position: absolute;
top: 15px;
right: -15px;
width: 30px;
height: 30px;
background-color: #f59e0b;
border-radius: 50%;
transform: rotate(45deg);
}
.joke-container {
min-height: 200px;
transition: all 0.3s ease;
}
.mustache {
position: absolute;
bottom: -10px;
left: 50%;
transform: translateX(-50%);
width: 100px;
height: 30px;
background-color: #333;
border-radius: 0 0 50% 50%;
}
.mustache::before,
.mustache::after {
content: '';
position: absolute;
top: 0;
width: 40px;
height: 40px;
background-color: #333;
border-radius: 50%;
}
.mustache::before {
left: -30px;
}
.mustache::after {
right: -30px;
}
.dad-shadow {
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
}
.joke-text {
font-family: 'Comic Sans MS', cursive, sans-serif;
}
.btn-pulse:hover {
animation: pulse 0.5s infinite;
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}
</style>
</head>
<body class="bg-gradient-to-b from-blue-50 to-blue-100 min-h-screen">
<div class="container mx-auto px-4 py-12">
<div class="max-w-2xl mx-auto text-center">
<!-- Dad Hat Title -->
<div class="relative mb-16">
<div class="dad-hat"></div>
<h1 class="text-4xl md:text-5xl font-bold text-amber-800 bg-white py-4 px-8 rounded-full shadow-lg relative z-0">
<span class="text-amber-600">Dad</span> Joke Generator
</h1>
</div>
<!-- Joke Display -->
<div class="bg-white rounded-2xl p-8 mb-10 joke-container dad-shadow relative overflow-hidden">
<div class="absolute -bottom-2 left-0 w-full flex justify-center">
<div class="mustache"></div>
</div>
<div class="min-h-40 flex items-center justify-center">
<p id="joke" class="text-2xl joke-text text-gray-800">Why don't eggs tell jokes? They'd crack each other up!</p>
</div>
<div class="absolute top-2 right-2">
<button id="copyBtn" class="text-gray-400 hover:text-amber-600 transition-colors">
<i class="fas fa-copy"></i>
</button>
</div>
</div>
<!-- Controls -->
<div class="flex flex-col sm:flex-row gap-4 justify-center">
<button id="newJokeBtn" class="bg-amber-500 hover:bg-amber-600 text-white font-bold py-3 px-6 rounded-full text-lg btn-pulse transition-colors flex items-center justify-center gap-2">
<i class="fas fa-redo"></i> New Joke
</button>
<button id="shareBtn" class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-3 px-6 rounded-full text-lg transition-colors flex items-center justify-center gap-2">
<i class="fas fa-share-alt"></i> Share
</button>
</div>
<!-- Rating -->
<div class="mt-8">
<p class="text-gray-600 mb-2">How bad was this dad joke?</p>
<div class="flex justify-center gap-2">
<button class="rate-btn bg-red-100 hover:bg-red-200 text-red-600 px-4 py-2 rounded-full transition-colors" data-rating="1">
<i class="fas fa-grin-squint-tears"></i> So bad
</button>
<button class="rate-btn bg-yellow-100 hover:bg-yellow-200 text-yellow-600 px-4 py-2 rounded-full transition-colors" data-rating="2">
<i class="fas fa-grin-beam"></i> Classic
</button>
<button class="rate-btn bg-green-100 hover:bg-green-200 text-green-600 px-4 py-2 rounded-full transition-colors" data-rating="3">
<i class="fas fa-grin-tears"></i> Legendary
</button>
</div>
</div>
<!-- Dad Joke Counter -->
<div class="mt-12 bg-white rounded-full py-3 px-6 inline-block shadow-md">
<p class="text-gray-700">
<span id="jokeCount" class="font-bold text-amber-600">0</span> dad jokes generated today!
</p>
</div>
</div>
</div>
<script>
// Dad Jokes API
const dadJokes = [
"Why don't skeletons fight each other? They don't have the guts.",
"I'm reading a book about anti-gravity. It's impossible to put down!",
"Did you hear about the claustrophobic astronaut? He just needed a little space.",
"Why don't scientists trust atoms? Because they make up everything!",
"What do you call a fake noodle? An impasta!",
"How do you organize a space party? You planet!",
"Why did the scarecrow win an award? Because he was outstanding in his field!",
"I used to be a baker, but I couldn't make enough dough.",
"What's orange and sounds like a parrot? A carrot.",
"How do you make a tissue dance? Put a little boogie in it!",
"Why did the math book look sad? Because it had too many problems.",
"What do you call a bear with no teeth? A gummy bear!",
"I'm on a seafood diet. Every time I see food, I eat it.",
"Why can't you explain puns to kleptomaniacs? They always take things literally.",
"What's the best time to go to the dentist? Tooth-hurty!",
"How does a penguin build its house? Igloos it together.",
"Why don't eggs tell jokes? They'd crack each other up!",
"What do you call cheese that isn't yours? Nacho cheese!",
"Why couldn't the bicycle stand up by itself? It was two tired.",
"What did the grape say when it got stepped on? Nothing, it just let out a little wine.",
"Why don't some couples go to the gym? Because some relationships don't work out.",
"What do you call a fish wearing a bowtie? Sofishticated.",
"How do you catch a squirrel? Climb a tree and act like a nut!",
"I told my wife she was drawing her eyebrows too high. She looked surprised.",
"What's brown and sticky? A stick.",
"Why did the golfer bring two pairs of pants? In case he got a hole in one!",
"What do you call a parade of rabbits hopping backwards? A receding hare-line.",
"How many tickles does it take to make an octopus laugh? Ten-tickles.",
"I invented a new word: Plagiarism!",
"What's the difference between a poorly dressed man on a trampoline and a well-dressed man on a trampoline? Attire.",
"Why did the invisible man turn down the job offer? He couldn't see himself doing it.",
"What do you call a snowman with a six-pack? An abdominal snowman.",
"I used to play piano by ear, but now I use my hands.",
"Did you hear about the guy who invented the knock-knock joke? He won the 'no-bell' prize.",
"What did the janitor say when he jumped out of the closet? Supplies!",
"Why did the scarecrow win an award? Because he was outstanding in his field!",
"What do you call a dinosaur with an extensive vocabulary? A thesaurus.",
"I would tell you a chemistry joke, but I know I wouldn't get a reaction.",
"Why don't scientists trust atoms? Because they make up everything!",
"What did one wall say to the other wall? I'll meet you at the corner!"
];
// DOM Elements
const jokeElement = document.getElementById('joke');
const newJokeBtn = document.getElementById('newJokeBtn');
const copyBtn = document.getElementById('copyBtn');
const shareBtn = document.getElementById('shareBtn');
const rateButtons = document.querySelectorAll('.rate-btn');
const jokeCountElement = document.getElementById('jokeCount');
// Variables
let jokeCount = localStorage.getItem('jokeCount') || 0;
jokeCountElement.textContent = jokeCount;
// Functions
function getRandomJoke() {
const randomIndex = Math.floor(Math.random() * dadJokes.length);
return dadJokes[randomIndex];
}
function displayNewJoke() {
jokeElement.textContent = getRandomJoke();
jokeCount++;
jokeCountElement.textContent = jokeCount;
localStorage.setItem('jokeCount', jokeCount);
// Animate joke container
const jokeContainer = document.querySelector('.joke-container');
jokeContainer.style.transform = 'scale(0.95)';
setTimeout(() => {
jokeContainer.style.transform = 'scale(1)';
}, 300);
}
function copyJokeToClipboard() {
navigator.clipboard.writeText(jokeElement.textContent)
.then(() => {
copyBtn.innerHTML = '<i class="fas fa-check"></i>';
setTimeout(() => {
copyBtn.innerHTML = '<i class="fas fa-copy"></i>';
}, 2000);
})
.catch(err => {
console.error('Failed to copy text: ', err);
});
}
function shareJoke() {
if (navigator.share) {
navigator.share({
title: 'Dad Joke',
text: jokeElement.textContent,
url: window.location.href
})
.catch(err => {
console.error('Error sharing:', err);
});
} else {
// Fallback for browsers that don't support Web Share API
const shareUrl = `https://twitter.com/intent/tweet?text=${encodeURIComponent(jokeElement.textContent + " - Check out this Dad Joke Generator!")}`;
window.open(shareUrl, '_blank');
}
}
function rateJoke(rating) {
let message = '';
switch(rating) {
case '1':
message = 'Thanks for your honesty! We\'ll try harder next time.';
break;
case '2':
message = 'A classic dad joke! Right in the sweet spot.';
break;
case '3':
message = 'Legendary status achieved! This joke will go down in history.';
break;
}
// Create and show toast notification
const toast = document.createElement('div');
toast.className = `fixed bottom-4 left-1/2 transform -translate-x-1/2 bg-white px-6 py-3 rounded-full shadow-lg text-sm font-medium animate-bounce ${rating === '1' ? 'text-red-500' : rating === '2' ? 'text-yellow-500' : 'text-green-500'}`;
toast.textContent = message;
document.body.appendChild(toast);
setTimeout(() => {
toast.remove();
}, 3000);
}
// Event Listeners
newJokeBtn.addEventListener('click', displayNewJoke);
copyBtn.addEventListener('click', copyJokeToClipboard);
shareBtn.addEventListener('click', shareJoke);
rateButtons.forEach(button => {
button.addEventListener('click', () => {
rateJoke(button.dataset.rating);
});
});
// Initialize with a joke
displayNewJoke();
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=MarcusCorvus/dad-joke-generator" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>