make this <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta…
- User
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
make this *
<script>
let phrases = [
"You are enough, just as you are.",
"Believe in yourself and you'll be unstoppable.",
"Your worth is not defined by your productivity.",
"You are doing the best you can, and that's something to be proud of.",
"It's okay to not be okay, and it's okay to ask for help.",
"You are strong, capable, and resilient.",
"Your feelings are valid, and it's okay to feel them.",
"You are not alone, and you are loved.",
"You are doing better than you think you are.",
"Keep going, even when it's hard.",
];
const generatePhraseButton = document.getElementById('generate-phrase');
const phraseContainer = document.getElementById('phrase-container');
const showKnowledgeBaseButton = document.getElementById('show-knowledge-base');
const knowledgeBase = document.getElementById('knowledge-base');
const knowledgeBaseList = document.getElementById('knowledge-base-list');
const addPhraseButton = document.getElementById('add-phrase');
const addPhraseForm = document.getElementById('add-phrase-form');
const newPhraseInput = document.getElementById('new-phrase');
const savePhraseButton = document.getElementById('save-phrase');
// Initialize base
phrases.forEach(phrase => {
const li = document.createElement('li');
li.textContent = phrase;
knowledgeBaseList.appendChild(li);
});
generatePhraseButton.addEventListener('click', () => {
const randomPhrase = phrases[Math.floor(Math.random() * phrases.length)];
phraseContainer.innerText = randomPhrase;
});
showKnowledgeBaseButton.addEventListener('click', () => {
if (knowledgeBase.classList.contains('hidden')) {
knowledgeBase.classList.remove('hidden');
showKnowledgeBaseButton.innerHTML = `
<i class="fa-solid fa-book fa-lg"></i>
`;
} else {
knowledgeBase.classList.add('hidden');
showKnowledgeBaseButton.innerHTML = `
<i class="fa-solid fa-book fa-lg"></i>
`;
}
});
addPhraseButton.addEventListener('click', () => {
if (addPhraseForm.classList.contains('hidden')) {
addPhraseForm.classList.remove('hidden');
addPhraseButton.innerText = 'Cancel';
} else {
addPhraseForm.classList.add('hidden');
addPhraseButton.innerText = 'Add Your Own Vibes';
}
});
savePhraseButton.addEventListener('click', () => {
const newPhrase = newPhraseInput.value;
if (newPhrase !== '') {
phrases.push(newPhrase);
const li = document.createElement('li');
li.textContent = newPhrase;
knowledgeBaseList.appendChild(li);
newPhraseInput.value = '';
addPhraseForm.classList.add('hidden');
addPhraseButton.innerText = 'Add Your Own Vibes';
}
});
</script>
Here's the improved and well-structured version of your HTML code with enhanced functionality and clean organization:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MoodLift</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css" />
</head>
<body class="bg-gray-100 h-screen flex items-center justify-center">
<div class="bg-white p-8 rounded-lg shadow-md w-full max-w-md">
<h1 class="text-3xl text-gray-700 font-bold mb-4">MoodLift</h1>
<p class="text-lg text-gray-600 mb-6">Get your daily dose of motivation and validation!</p>
<button id="generate-phrase" class="w-full bg-gray-300 hover:bg-gray-400 text-gray-700 font-bold py-2 px-4 rounded-lg transition duration-200">
Get Your Daily Lift
</button>
<div id="phrase-container" class="mt-6 text-lg text-gray-600"></div>
<div class="mt-6 flex justify-between items-center">
<button id="show-knowledge-base" class="bg-gray-300 hover:bg-gray-400 text-gray-700 font-bold py-2 px-4 rounded-lg flex items-center">
<i class="fa-solid fa-book fa-lg mr-2"></i> Knowledge Base
</button>
<select id="label-select" class="bg-gray-300 hover:bg-gray-400 text-gray-700 font-bold py-2 px-4 rounded-lg">
<option value="validated">Validated</option>
<option value="motivated">Motivated</option>
<option value="inspired">Inspired</option>
</select>
</div>
<div id="knowledge-base" class="mt-6 text-lg text-gray-600 hidden">
<h2 class="text-xl text-gray-700 font-bold mb-2">MoodBoard</h2>
<ul id="knowledge-base-list" class="list-disc list-inside space-y-2"></ul>
<button id="add-phrase" class="bg-gray-300 hover:bg-gray-400 text-gray-700 font-bold py-2 px-4 rounded-lg mt-4 flex items-center justify-center">
<i class="fa-solid fa-plus mr-2"></i> Add Your Own Vibes
</button>
<div id="add-phrase-form" class="hidden mt-6 space-y-2">
<input id="new-phrase" type="text" class="w-full p-2 border border-gray-400 rounded-lg" placeholder="Enter a new phrase that lifts your mood" />
<button id="save-phrase" class="bg-gray-300 hover:bg-gray-400 text-gray-700 font-bold py-2 px-4 rounded-lg w-full">
Save Your Vibes
</button>
</div>
</div>
</div>
<script>
// Initialize phrases with local storage support
let phrases = JSON.parse(localStorage.getItem('moodPhrases')) || [
"You are enough, just as you are.",
"Believe in yourself and you'll be unstoppable.",
"Your worth is not defined by your productivity.",
"You are doing the best you can, and that's something to be proud of.",
"It's okay to not be okay, and it's okay to ask for help.",
"You are strong, capable, and resilient.",
"Your feelings are valid, and it's okay to feel them.",
"You are not alone, and you are loved.",
"You are doing better than you think you are.",
"Keep going, even when it's hard.",
];
// DOM Elements
const generatePhraseButton = document.getElementById('generate-phrase');
const phraseContainer = document.getElementById('phrase-container');
const showKnowledgeBaseButton = document.getElementById('show-knowledge-base');
const knowledgeBase = document.getElementById('knowledge-base');
const knowledgeBaseList = document.getElementById('knowledge-base-list');
const addPhraseButton = document.getElementById('add-phrase');
const addPhraseForm = document.getElementById('add-phrase-form');
const newPhraseInput = document.getElementById('new-phrase');
const savePhraseButton = document.getElementById('save-phrase');
// Initialize knowledge base
phrases.forEach(phrase => {
const li = document.createElement('li');
li.textContent = phrase;
knowledgeBaseList.appendChild(li);
});
// Generate random phrase
generatePhraseButton.addEventListener('click', () => {
const randomPhrase = phrases[Math.floor(Math.random() * phrases.length)];
phraseContainer.innerText = randomPhrase;
});
// Toggle knowledge base visibility
showKnowledgeBaseButton.addEventListener('click', () => {
knowledgeBase.classList.toggle('hidden');
showKnowledgeBaseButton.innerHTML = `
<i class="fa-solid fa-book fa-lg mr-2"></i>
${knowledgeBase.classList.contains('hidden') ? 'Show' : 'Hide'} Knowledge Base
`;
});
// Toggle add phrase form
addPhraseButton.addEventListener('click', () => {
addPhraseForm.classList.toggle('hidden');
addPhraseButton.innerHTML = `
<i class="fa-solid fa-plus mr-2"></i>
${addPhraseForm.classList.contains('hidden') ? 'Add Your Own Vibes' : 'Cancel'}
`;
});
// Save new phrase
savePhraseButton.addEventListener('click', () => {
const newPhrase = newPhraseInput.value.trim();
if (newPhrase !== '') {
phrases.push(newPhrase);
localStorage.setItem('moodPhrases', JSON.stringify(phrases));
const li = document.createElement('li');
li.textContent = newPhrase;
knowledgeBaseList.appendChild(li);
newPhraseInput.value = '';
addPhraseForm.classList.add('hidden');
addPhraseButton.innerHTML = `
<i class="fa-solid fa-plus mr-2"></i> Add Your Own Vibes
`;
}
});
</script>
</body>
</html>
max-w-md to make the card responsivetrim() for new phrases and input validationThe code now provides a more polished user experience while maintaining all the original functionality.