';
}
promptsHTML += `
`;
card.innerHTML = promptsHTML;
promptResults.appendChild(card);
resultsSection.style.display = "block";
historySection.style.display = "none";
});
historyItems.appendChild(historyItem);
});
}
function toggleHistory() {
if (historySection.style.display === "block") {
historySection.style.display = "none";
historyBtn.textContent = "History";
} else {
historySection.style.display = "block";
resultsSection.style.display = "none";
historyBtn.textContent = "Hide History";
}
}
function toggleDarkMode() {
document.body.classList.toggle('dark-mode');
if (document.body.classList.contains('dark-mode')) {
localStorage.setItem('darkMode', 'enabled');
} else {
localStorage.setItem('darkMode', 'disabled');
}
}
function toggleAdvancedOptions() {
if (advancedOptions.classList.contains('active')) {
advancedOptions.classList.remove('active');
toggleAdvanced.textContent = "â–¼ Show Advanced Options";
} else {
advancedOptions.classList.add('active');
toggleAdvanced.textContent = "â–² Hide Advanced Options";
}
}
function switchTab(tab) {
currentTab = tab;
tabs.forEach(t => t.classList.remove('active'));
document.querySelector(`.tab[data-tab="${tab}"]`).classList.add('active');
}
function clearForm() {
formInputs.forEach(input => {
if (input.type !== 'checkbox' && input.id !== 'count') {
input.value = input.id === 'style' ? 'any' : '';
}
});
resultsSection.style.display = "none";
historySection.style.display = "none";
}
function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&")
.replace(//g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
}
});
// Global functions
function copyToClipboard(text) {
navigator.clipboard.writeText(text)
.then(() => alert("Prompt copied!"))
.catch(() => alert("Failed to copy."));
}
function copyAllPrompts() {
const prompts = Array.from(document.querySelectorAll('.prompt-item p')).map(p => p.textContent);
if (prompts.length > 0) {
copyToClipboard(prompts.join('\n\n'));
} else {
const singlePrompt = document.querySelector('.prompt-card p')?.textContent;
if (singlePrompt) {
copyToClipboard(singlePrompt);
}
}
}