<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dad Joke Visualizer</title>
<style>
body {
font-family: 'Comic Sans MS', cursive, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
margin: 0;
padding: 20px;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.container {
background: white;
border-radius: 20px;
padding: 40px;
box-shadow: 0 20px 40px rgba(0,0,0,0.1);
max-width: 600px;
text-align: center;
animation: slideIn 0.8s ease-out;
}
@keyframes slideIn {
from { opacity: 0; transform: translateY(30px); }
to { opacity: 1; transform: translateY(0); }
}
h1 {
color: #333;
margin-bottom: 30px;
font-size: 2.5em;
text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}
.subtitle {
color: #666;
font-size: 1.2em;
margin-bottom: 40px;
}
.input-group {
margin-bottom: 30px;
}
label {
display: block;
margin-bottom: 10px;
color: #555;
font-size: 1.1em;
}
input[type="text"] {
width: 100%;
padding: 15px;
border: 2px solid #ddd;
border-radius: 10px;
font-size: 1.1em;
box-sizing: border-box;
}
input[type="text"]:focus {
outline: none;
border-color: #667eea;
}
select.rating-selector {
width: 100%;
padding: 15px;
border: 2px solid #ddd;
border-radius: 10px;
font-size: 1.1em;
background: white;
cursor: pointer;
box-sizing: border-box;
}
select.rating-selector:focus {
outline: none;
border-color: #667eea;
}
select.rating-selector option {
padding: 10px;
font-size: 1em;
}
.generate-button {
background: linear-gradient(45deg, #667eea, #764ba2);
color: white;
padding: 15px 40px;
border: none;
border-radius: 25px;
font-size: 1.3em;
cursor: pointer;
transition: transform 0.2s ease, box-shadow 0.2s ease;
margin-bottom: 20px;
}
.generate-button:hover {
transform: translateY(-2px);
box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}
.generate-button:disabled {
opacity: 0.6;
cursor: not-allowed;
transform: none;
}
.loading {
display: none;
color: #667eea;
font-size: 1.1em;
margin-top: 20px;
}
.spinner {
border: 3px solid #f3f3f3;
border-top: 3px solid #667eea;
border-radius: 50%;
width: 30px;
height: 30px;
animation: spin 1s linear infinite;
margin: 0 auto 10px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.error {
color: #e74c3c;
background: #fdf2f2;
padding: 15px;
border-radius: 10px;
margin-top: 20px;
display: none;
}
.success {
color: #27ae60;
background: #f0f9f0;
padding: 15px;
border-radius: 10px;
margin-top: 20px;
display: none;
}
.footer {
margin-top: 40px;
color: #888;
font-size: 0.9em;
}
</style>
</head>
<body>
<div class="container">
<h1>🎭 Dad Joke Visualizer</h1>
<p class="subtitle">Generate hilarious Dad Jokes with AI-powered visualizations!</p>
<div class="input-group">
<label for="topic">Optional Topic (e.g., "cats", "programming", "food"):</label>
<input type="text" id="topic" placeholder="Leave empty for a random Dad Joke">
</div>
<div class="input-group">
<label for="rating">Content Rating:</label>
<select id="rating" class="rating-selector">
<option value="PG">😊 PG - Clean & Family Friendly</option>
<option value="PG-13" selected>😄 PG-13 - Mild Adult Humor</option>
<option value="R">😏 R - Mature Audiences Only</option>
</select>
</div>
<button class="generate-button" onclick="generateJoke()">
🎪 Generate Dad Joke & Visualization
</button>
<div class="loading" id="loading">
<div class="spinner"></div>
<div>Creating your Dad Joke masterpiece...</div>
</div>
<div class="error" id="error"></div>
<div class="success" id="success"></div>
<div class="footer">
<p>Powered by AI • Made with ❤️ for Dad Joke enthusiasts</p>
</div>
</div>
<script>
async function generateJoke() {
const topic = document.getElementById('topic').value.trim();
const rating = document.getElementById('rating').value;
const button = document.querySelector('.generate-button');
const loading = document.getElementById('loading');
const error = document.getElementById('error');
const success = document.getElementById('success');
// Reset UI
error.style.display = 'none';
success.style.display = 'none';
button.disabled = true;
loading.style.display = 'block';
try {
// Call the actual MCP server to generate the joke
const response = await fetch('/api/generate-joke', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ topic, rating }),
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
if (data.success) {
// Create inline joke visualization
success.innerHTML = `
<div style="margin-top: 20px;">
<div style="background: white; border-radius: 20px; padding: 30px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); margin-top: 20px;">
<div style="display: flex; gap: 15px; margin-bottom: 15px; flex-wrap: wrap;">
<span style="background: #FFD700; padding: 5px 15px; border-radius: 15px; font-size: 0.9em; font-weight: bold; color: #8B4513;">
${data.topic.toUpperCase()}
</span>
<span style="background: #FF9800; padding: 5px 15px; border-radius: 15px; font-size: 0.9em; font-weight: bold; color: white;">
${data.rating}
</span>
</div>
<div style="font-size: 1.4em; color: #333; margin-bottom: 25px; line-height: 1.5; font-style: italic;">
"${data.joke}"
</div>
<div style="text-align: center;">
<img src="${data.imageUrl}" alt="Dad Joke Visualization" style="max-width: 100%; border-radius: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.2);" />
</div>
<div style="margin-top: 20px; text-align: center;">
<button onclick="generateJoke()" class="generate-button" style="margin-bottom: 10px;">
🎪 Generate Another Joke
</button>
</div>
</div>
</div>
`;
success.style.display = 'block';
// Clear the form for the next joke
document.getElementById('topic').value = '';
document.getElementById('rating').value = 'PG-13';
} else {
throw new Error(data.error || 'Failed to generate joke');
}
} catch (err) {
error.innerHTML = `<strong>❌ Error:</strong> ${err.message}`;
error.style.display = 'block';
} finally {
button.disabled = false;
loading.style.display = 'none';
}
}
// Allow Enter key to trigger generation
document.getElementById('topic').addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
generateJoke();
}
});
</script>
</body>
</html>