Infusion AI Prompt Generator

Click the button to generate a prompt!

Select Categories:

Add Custom Prompt:

/* styles.css */ body { font-family: Arial, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; } h1 { text-align: center; } #prompt-display { font-size: 24px; margin-bottom: 20px; text-align: center; } button { display: block; margin: 20px auto; padding: 10px 20px; font-size: 18px; } #category-selection { margin-bottom: 20px; } #category-selection label { display: block; margin-bottom: 5px; } #category-selection input[type="checkbox"]:checked + span { font-weight: bold; } #custom-prompt { margin-bottom: 20px; } #custom-prompt input { width: 70%; padding: 5px; font-size: 16px; } #custom-prompt button { display: inline-block; margin: 0; } #custom-prompts-list { margin-bottom: 20px; } .custom-prompt-item { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; } .remove-prompt-btn { background: none; border: none; color: red; cursor: pointer; font-size: 18px; padding: 0; margin: 0; } @media screen and (max-width: 600px) { body { padding: 10px; } h1 { font-size: 24px; } #prompt-display { font-size: 20px; } } // script.js const prompts = { Writing: [ "Write a short story about a character who discovers a hidden talent.", "Compose a poem inspired by a favorite childhood memory.", "Create a dialogue between two characters with opposing viewpoints on a controversial topic." ], Art: [ "Draw a portrait of a person from a different era.", "Create a digital illustration that combines elements from two different animals.", "Design a unique pattern inspired by nature." ], Music: [ "Write lyrics for a song about overcoming adversity.", "Compose a melody using only three chords.", "Create a rhythm pattern that evokes a specific emotion." ], Custom: [] }; const promptDisplay = document.getElementById('prompt-display'); const generateBtn = document.getElementById('generate-btn'); const categoryCheckboxes = document.querySelectorAll('#category-selection input[type="checkbox"]'); const customPromptInput = document.getElementById('custom-prompt-input'); const addCustomBtn = document.getElementById('add-custom-btn'); const savePreferencesBtn = document.getElementById('save-preferences-btn'); const customPromptsList = document.getElementById('custom-prompts-list'); let filteredPrompts = []; generateBtn.addEventListener('click', generatePrompt); addCustomBtn.addEventListener('click', addCustomPrompt); savePreferencesBtn.addEventListener('click', savePreferences); categoryCheckboxes.forEach(checkbox => checkbox.addEventListener('change', updateFilteredPrompts)); loadPreferences(); updateFilteredPrompts(); renderCustomPrompts(); function generatePrompt() { if (filteredPrompts.length === 0) { promptDisplay.textContent = "Please select at least one category with available prompts."; return; } const randomIndex = Math.floor(Math.random() * filteredPrompts.length); promptDisplay.textContent = filteredPrompts[randomIndex]; } function updateFilteredPrompts() { const selectedCategories = getSelectedCategories(); filteredPrompts = selectedCategories.flatMap(category => prompts[category]); } function getSelectedCategories() { return Array.from(categoryCheckboxes) .filter(checkbox => checkbox.checked) .map(checkbox => checkbox.value); } function addCustomPrompt() { const customPrompt = customPromptInput.value.trim(); if (customPrompt === "") { alert("Custom prompt cannot be empty."); return; } if (prompts.Custom.includes(customPrompt)) { alert("This custom prompt already exists."); return; } prompts.Custom.push(customPrompt); customPromptInput.value = ""; updateFilteredPrompts(); renderCustomPrompts(); } function removeCustomPrompt(index) { prompts.Custom.splice(index, 1); updateFilteredPrompts(); renderCustomPrompts(); } function renderCustomPrompts() { customPromptsList.innerHTML = ''; prompts.Custom.forEach((prompt, index) => { const promptItem = document.createElement('div'); promptItem.className = 'custom-prompt-item'; promptItem.innerHTML = ` ${prompt} `; customPromptsList.appendChild(promptItem); }); } function savePreferences() { const selectedCategories = getSelectedCategories(); localStorage.setItem('selectedCategories', JSON.stringify(selectedCategories)); localStorage.setItem('customPrompts', JSON.stringify(prompts.Custom)); } function loadPreferences() { const storedCategories = localStorage.getItem('selectedCategories'); if (storedCategories) { const selectedCategories = JSON.parse(storedCategories); categoryCheckboxes.forEach(checkbox => { checkbox.checked = selectedCategories.includes(checkbox.value); }); } const storedCustomPrompts = localStorage.getItem('customPrompts'); if (storedCustomPrompts) { prompts.Custom = JSON.parse(storedCustomPrompts); } }