// ScatBoi Art Gen JavaScript class ScatBoiArtGenerator { constructor() { this.gallery = document.getElementById('gallery'); this.promptInput = document.getElementById('promptInput'); this.generateBtn = document.getElementById('generateBtn'); this.loadingState = document.getElementById('loadingState'); this.initializeEventListeners(); this.loadSampleImages(); } initializeEventListeners() { this.generateBtn.addEventListener('click', () => this.generateArt()); this.promptInput.addEventListener('keypress', (e) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); this.generateArt(); } }); } async generateArt() { const prompt = this.promptInput.value.trim(); if (!prompt) { this.showNotification('Please enter a prompt first! 💩', 'warning'); return; } // Check if prompt contains relevant keywords if (!this.isValidPrompt(prompt)) { this.showNotification('Your prompt should be more scatboi-related! 💩', 'warning'); return; } this.showLoading(true); try { // Simulate AI generation delay await new Promise(resolve => setTimeout(resolve, 2000)); // Generate unique image based on prompt const imageData = await this.createUniqueImage(prompt); this.displayGeneratedImage(imageData); this.showNotification('Your scatboi art has been generated! 🎨', 'success'); } catch (error) { this.showNotification('Oops! Something went wrong. Try again! 💩', 'error'); } finally { this.showLoading(false); } } isValidPrompt(prompt) { const keywords = ['boy', 'poop', 'toilet', 'bathroom', 'scat', 'dump', 'turd', 'crap']; return keywords.some(keyword => prompt.toLowerCase().includes(keyword)); } async createUniqueImage(prompt) { // Create a unique hash from the prompt const hash = this.hashCode(prompt); // Use placeholder service with consistent seed const seed = Math.abs(hash % 1000); const category = ['people', 'minimal', 'abstract'][Math.abs(hash % 3)]; return { url: `http://static.photos/${category}/640x360/${seed}`, prompt: prompt, timestamp: new Date().toISOString(), id: Math.random().toString(36).substr(2, 9) }; } hashCode(str) { let hash = 0; for (let i = 0; i < str.length; i++) { const char = str.charCodeAt(i); hash = ((hash << 5) - hash) + char; hash = hash & hash; } return hash; } displayGeneratedImage(imageData) { const imageCard = this.createImageCard(imageData); this.gallery.insertBefore(imageCard, this.gallery.firstChild); // Add fade-in animation setTimeout(() => { imageCard.classList.add('fade-in'); }, 100); // Clear input this.promptInput.value = ''; } createImageCard(imageData) { const card = document.createElement('div'); card.className = 'image-card bg-white rounded-2xl shadow-lg overflow-hidden'; card.innerHTML = `
${imageData.prompt}