// Initialize data let sites = JSON.parse(localStorage.getItem('sites')) || []; let ads = JSON.parse(localStorage.getItem('ads')) || []; // Default sites data if empty if (sites.length === 0) { sites = [ { id: 1, name: "Stable Diffusion", category: "ai", url: "https://stability.ai", replaces: "Midjourney, DALL-E", description: "Open-source AI image generation model that creates detailed images from text descriptions. Free to use with local installation.", image: "http://static.photos/ai/640x360/1", affiliate: "" }, { id: 2, name: "GIMP", category: "design", url: "https://www.gimp.org", replaces: "Adobe Photoshop", description: "GNU Image Manipulation Program is a free and open-source raster graphics editor used for image retouching and editing.", image: "http://static.photos/design/640x360/2", affiliate: "" }, { id: 3, name: "Krita", category: "design", url: "https://krita.org", replaces: "Adobe Illustrator", description: "Professional free and open source painting program made by artists for artists.", image: "http://static.photos/art/640x360/3", affiliate: "" }, { id: 4, name: "DaVinci Resolve", category: "audio", url: "https://www.blackmagicdesign.com/products/davinciresolve", replaces: "Adobe Premiere", description: "Professional video editing, color correction, visual effects and audio post production software with a free version.", image: "http://static.photos/technology/640x360/4", affiliate: "" }, { id: 5, name: "Audacity", category: "audio", url: "https://www.audacityteam.org", replaces: "Adobe Audition", description: "Free, open source, cross-platform audio software for multi-track recording and editing.", image: "http://static.photos/audio/640x360/5", affiliate: "" }, { id: 6, name: "LibreOffice", category: "productivity", url: "https://www.libreoffice.org", replaces: "Microsoft Office", description: "Free and open-source office suite, a project of The Document Foundation.", image: "http://static.photos/office/640x360/6", affiliate: "" }, { id: 7, name: "Notion Free", category: "productivity", url: "https://www.notion.so", replaces: "Evernote Premium", description: "All-in-one workspace for notes, tasks, wikis, and databases. Generous free tier available.", image: "http://static.photos/workspace/640x360/7", affiliate: "" }, { id: 8, name: "OBS Studio", category: "ai", url: "https://obsproject.com", replaces: "Streamlabs paid", description: "Free and open source software for video recording and live streaming.", image: "http://static.photos/technology/640x360/8", affiliate: "" }, { id: 9, name: "League of Legends", category: "gaming", url: "https://www.leagueoflegends.com", replaces: "Paid AAA games", description: "Free-to-play multiplayer online battle arena game with millions of active players worldwide.", image: "http://static.photos/gaming/640x360/9", affiliate: "" }, { id: 10, name: "Blender", category: "design", url: "https://www.blender.org", replaces: "Maya, 3ds Max", description: "Free and open-source 3D computer graphics software toolset used for creating animated films, visual effects, art, and more.", image: "http://static.photos/technology/640x360/10", affiliate: "" }, { id: 11, name: "WooCommerce", category: "commerce", url: "https://woocommerce.com", replaces: "Shopify", description: "Open-source e-commerce plugin for WordPress. Free to use with hosting costs only.", image: "http://static.photos/commerce/640x360/11", affiliate: "" }, { id: 12, name: "Strava Free", category: "sports", url: "https://www.strava.com", replaces: "Premium fitness apps", description: "Track your running and cycling, analyze your performance, compete with friends all for free.", image: "http://static.photos/sport/640x360/12", affiliate: "" }, { id: 13, name: "OpenAI Playground", category: "ai", url: "https://platform.openai.com", replaces: "ChatGPT Plus", description: "Access GPT models with free credits when you sign up. Great for experimenting with AI.", image: "http://static.photos/technology/640x360/13", affiliate: "" }, { id: 14, name: "Udio Free", category: "audio", url: "https://www.udio.ai", replaces: "Suno AI", description: "AI music generation platform with free tier allowing you to create songs from text prompts.", image: "http://static.photos/music/640x360/14", affiliate: "" }, { id: 15, name: "Canva Free", category: "design", url: "https://www.canva.com", replaces: "Adobe Creative Suite", description: "Graphic design platform with robust free tier for creating social media graphics, presentations, and more.", image: "http://static.photos/design/640x360/15", affiliate: "" } ]; localStorage.setItem('sites', JSON.stringify(sites)); } // Default ads if empty if (ads.length === 0) { ads = [ { id: 1, title: "Premium Web Hosting", advertiser: "HostMaster Pro", content: "
Get 50% Off Hosting
Reliable hosting for your free sites!
", position: "top", startDate: "2025-01-01", endDate: "2025-12-31", price: 99.99, active: true }, { id: 2, title: "AI Tools Bundle", advertiser: "AITools Inc", content: "

Premium AI Tools

Upgrade your workflow today!

", position: "sidebar1", startDate: "2025-01-01", endDate: "2025-12-31", price: 149.99, active: true }, { id: 3, title: "Design Course", advertiser: "DesignAcademy", content: "

Master Design

Learn from pros

", position: "sidebar2", startDate: "2025-01-01", endDate: "2025-12-31", price: 79.99, active: true }, { id: 4, title: "VPN Service", advertiser: "SecureNet", content: "

Secure Your Connection

30% off Premium VPN

", position: "bottom", startDate: "2025-01-01", endDate: "2025-12-31", price: 199.99, active: true } ]; localStorage.setItem('ads', JSON.stringify(ads)); } // Render sites function renderSites(filter = 'all', search = '') { const grid = document.getElementById('sitesGrid'); let filteredSites = sites; if (filter !== 'all') { filteredSites = sites.filter(site => site.category === filter); } if (search) { filteredSites = filteredSites.filter(site => site.name.toLowerCase().includes(search.toLowerCase()) || site.description.toLowerCase().includes(search.toLowerCase()) || site.replaces.toLowerCase().includes(search.toLowerCase()) ); } if (filteredSites.length === 0) { grid.innerHTML = '

No sites found. Try a different search or category.

'; lucide.createIcons(); return; } grid.innerHTML = filteredSites.map(site => `
${site.name}
${site.category}
Free Alternative to ${site.replaces}

${site.name}

${site.description}

Visit Site ${site.affiliate ? `` : ''}
`).join(''); lucide.createIcons(); } // Filter functionality function filterCategory(category) { // Update active button document.querySelectorAll('.category-btn').forEach(btn => { btn.classList.remove('category-active'); btn.classList.remove('text-white'); }); event.target.classList.add('category-active'); const searchValue = document.getElementById('searchInput').value; renderSites(category, searchValue); } // Search functionality document.getElementById('searchInput').addEventListener('input', function(e) { const activeCategory = document.querySelector('.category-active').textContent.toLowerCase(); const categoryMap = { 'all': 'all', 'ai tools': 'ai', 'design': 'design', 'audio/music': 'audio', 'gaming': 'gaming', 'e-commerce': 'commerce', 'sports': 'sports', 'productivity': 'productivity' }; const cat = categoryMap[activeCategory] || 'all'; renderSites(cat, e.target.value); }); // Ad rotation and display function displayAds() { const today = new Date().toISOString().split('T')[0]; const activeAds = ads.filter(ad => ad.startDate <= today && ad.endDate >= today && ad.active); // Group by position const topAds = activeAds.filter(ad => ad.position === 'top'); const sidebar1Ads = activeAds.filter(ad => ad.position === 'sidebar1'); const sidebar2Ads = activeAds.filter(ad => ad.position === 'sidebar2'); const bottomAds = activeAds.filter(ad => ad.position === 'bottom'); // Rotate ads randomly function getRandomAd(adArray) { if (adArray.length === 0) return null; return adArray[Math.floor(Math.random() * adArray.length)]; } // Display ads const topAd = getRandomAd(topAds); const sidebar1Ad = getRandomAd(sidebar1Ads); const sidebar2Ad = getRandomAd(sidebar2Ads); const bottomAd = getRandomAd(bottomAds); if (topAd) { document.getElementById('adTop').innerHTML = `
${topAd.content}
`; } else { document.getElementById('adTop').style.display = 'none'; } if (sidebar1Ad) { document.getElementById('sidebarAd1').innerHTML = `
${sidebar1Ad.content}
`; } else { document.getElementById('sidebarAd1').style.display = 'none'; } if (sidebar2Ad) { document.getElementById('sidebarAd2').innerHTML = `
${sidebar2Ad.content}
`; } else { document.getElementById('sidebarAd2').style.display = 'none'; } if (bottomAd) { document.getElementById('adBottomContent').innerHTML = `
${bottomAd.content}
`; } else { document.getElementById('adBottom').style.display = 'none'; } } // Close bottom ad function closeBottomAd() { document.getElementById('adBottom').style.display = 'none'; } // Toggle pricing fields visibility function togglePricingFields() { const type = document.getElementById('inquiryType').value; const pricingFields = document.getElementById('pricingFields'); const submitBtnText = document.getElementById('submitBtnText'); const paymentNote = document.getElementById('paymentNote'); if (type === 'ad-pricing' || type === 'place-ad') { pricingFields.classList.remove('hidden'); submitBtnText.textContent = type === 'place-ad' ? 'Submit Ad Request' : 'Request Pricing Info'; if (type === 'place-ad') { paymentNote.classList.remove('hidden'); } else { paymentNote.classList.add('hidden'); } } else { pricingFields.classList.add('hidden'); submitBtnText.textContent = 'Send Inquiry'; paymentNote.classList.add('hidden'); } lucide.createIcons(); } // Inquiry Form Handler document.getElementById('inquiryForm')?.addEventListener('submit', function(e) { e.preventDefault(); const name = document.getElementById('inquiryName').value; const email = document.getElementById('inquiryEmail').value; const phone = document.getElementById('inquiryPhone').value; const company = document.getElementById('inquiryCompany').value; const type = document.getElementById('inquiryType').value; const message = document.getElementById('inquiryMessage').value; const subscribe = document.getElementById('subscribeUpdates').checked; // Get pricing info if applicable let pricingInfo = ''; let totalAmount = ''; if (type === 'ad-pricing' || type === 'place-ad') { const selectedDuration = document.querySelector('input[name="adDuration"]:checked'); if (selectedDuration) { const durationMap = { '1week': '1 Week - $5.00', '3weeks': '3 Weeks - $10.00', '1month': '1 Month - $15.00' }; pricingInfo = durationMap[selectedDuration.value]; const amountMap = { '1week': '5', '3weeks': '10', '1month': '15' }; totalAmount = amountMap[selectedDuration.value]; } const position = document.getElementById('adPosition')?.value || 'Not specified'; pricingInfo += `%0D%0AAd Position: ${position}`; } // Create email body with all details let subject = `Inquiry: ${type.split('-').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ')} - Free Sites 4 You`; let body = `Name: ${name}%0D%0AEmail: ${email}%0D%0APhone: ${phone || 'Not provided'}%0D%0ACompany: ${company || 'Not provided'}%0D%0AInquiry Type: ${type}%0D%0A`; if (pricingInfo) { body += `Selected Package: ${pricingInfo}%0D%0A`; body += `PayPal Payment: https://www.paypal.com/paypalme/levytmwale/${totalAmount}%0D%0A`; } body += `%0D%0AMessage:%0D%0A${message}%0D%0A`; if (subscribe) { body += `%0D%0A[User opted in to receive updates]`; } // Open email client window.location.href = `mailto:levtmwale@gmail.com?subject=${subject}&body=${body}`; // Show success message with different text based on inquiry type let successMsg = 'Thank you for your inquiry! Your email client should open with a pre-filled message.'; if (type === 'place-ad') { successMsg += ' Please complete payment at https://www.paypal.com/paypalme/levytmwale/' + totalAmount + ' to finalize your ad placement.'; } if (!subscribe) { successMsg += ' Don\'t miss out - consider subscribing to updates!'; } alert(successMsg); this.reset(); togglePricingFields(); }); // Email Signup Form Handler document.getElementById('emailSignupForm')?.addEventListener('submit', function(e) { e.preventDefault(); const name = document.getElementById('signupName').value; const email = document.getElementById('signupEmail').value; const interest = document.getElementById('signupInterest').value; // Send confirmation email const interestText = { 'pricing': 'Advertising Pricing Updates', 'new-tools': 'New Free Tools', 'both': 'Both Updates', 'partnerships': 'Partnership Opportunities' }; const subject = 'New Subscriber - Free Sites 4 You Updates'; const body = `New subscriber request:%0D%0A%0D%0AName: ${name}%0D%0AEmail: ${email}%0D%0AInterest: ${interestText[interest]}%0D%0A%0D%0APlease add to mailing list.`; window.location.href = `mailto:levtmwale@gmail.com?subject=${subject}&body=${body}`; // Also save to local storage for admin const subscribers = JSON.parse(localStorage.getItem('subscribers') || '[]'); subscribers.push({ name, email, interest, date: new Date().toISOString(), id: Date.now() }); localStorage.setItem('subscribers', JSON.stringify(subscribers)); alert(`Thank you for subscribing, ${name}! You'll receive updates about ${interestText[interest].toLowerCase()} at ${email}. Check your email to confirm.`); this.reset(); }); // Donation amount selector function donateAmount(amount) { window.open(`https://www.paypal.com/paypalme/levtmwale/${amount}`, '_blank'); } // Initialize document.addEventListener('DOMContentLoaded', function() { renderSites(); displayAds(); // Rotate ads every 30 seconds setInterval(displayAds, 30000); // Recreate icons for new elements if (typeof lucide !== 'undefined') { lucide.createIcons(); } });