Download index.html from MarcRyan/geopulse: direct link, hf CLI and curl.
- Browser
- Download file 37.3 kB
-
https://huggingface.co/spaces/MarcRyan/geopulse/resolve/main/index.html
- Command line
-
hf download hf://spaces/MarcRyan/geopulse/index.html
-
curl -L -o index.html https://huggingface.co/spaces/MarcRyan/geopulse/resolve/main/index.html
37.3 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>GeoPulse - Hyper-Local SEO Marketing Tool</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> | |
| <style> | |
| @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap'); | |
| body { | |
| font-family: 'Poppins', sans-serif; | |
| background-color: #f8fafc; | |
| } | |
| .gradient-bg { | |
| background: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%); | |
| } | |
| .keyword-chip { | |
| transition: all 0.2s ease; | |
| } | |
| .keyword-chip:hover { | |
| transform: translateY(-2px); | |
| box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); | |
| } | |
| .pulse { | |
| animation: pulse 2s infinite; | |
| } | |
| @keyframes pulse { | |
| 0% { opacity: 1; } | |
| 50% { opacity: 0.5; } | |
| 100% { opacity: 1; } | |
| } | |
| .slide-in { | |
| animation: slideIn 0.5s ease-out forwards; | |
| } | |
| @keyframes slideIn { | |
| from { transform: translateY(20px); opacity: 0; } | |
| to { transform: translateY(0); opacity: 1; } | |
| } | |
| .horizontal-scroll { | |
| display: flex; | |
| overflow-x: auto; | |
| scroll-snap-type: x mandatory; | |
| gap: 1rem; | |
| padding-bottom: 1rem; | |
| } | |
| .horizontal-scroll > * { | |
| scroll-snap-align: start; | |
| flex: 0 0 auto; | |
| width: 90%; | |
| max-width: 500px; | |
| } | |
| @media (min-width: 1024px) { | |
| .horizontal-scroll > * { | |
| width: 45%; | |
| } | |
| } | |
| .scroll-container { | |
| scrollbar-width: thin; | |
| scrollbar-color: #3b82f6 #e5e7eb; | |
| } | |
| .scroll-container::-webkit-scrollbar { | |
| height: 8px; | |
| } | |
| .scroll-container::-webkit-scrollbar-track { | |
| background: #e5e7eb; | |
| border-radius: 10px; | |
| } | |
| .scroll-container::-webkit-scrollbar-thumb { | |
| background-color: #3b82f6; | |
| border-radius: 10px; | |
| } | |
| .results-container { | |
| max-height: 70vh; | |
| overflow-y: auto; | |
| } | |
| /* New styles for horizontal results layout */ | |
| .results-horizontal { | |
| display: flex; | |
| overflow-x: auto; | |
| gap: 1.5rem; | |
| padding: 1.5rem; | |
| scroll-snap-type: x mandatory; | |
| } | |
| .results-horizontal > * { | |
| flex: 0 0 auto; | |
| width: 90%; | |
| max-width: 600px; | |
| scroll-snap-align: start; | |
| } | |
| .result-card { | |
| min-width: 0; | |
| background: white; | |
| border-radius: 0.75rem; | |
| box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); | |
| } | |
| </style> | |
| </head> | |
| <body class="min-h-screen"> | |
| <div class="gradient-bg text-white py-6 shadow-lg"> | |
| <div class="container mx-auto px-4"> | |
| <div class="flex items-center justify-between"> | |
| <div class="flex items-center space-x-3"> | |
| <i class="fas fa-map-marker-alt text-3xl"></i> | |
| <h1 class="text-3xl font-bold">GeoPulse</h1> | |
| </div> | |
| <div class="hidden md:flex space-x-4"> | |
| <a href="#" class="hover:text-blue-200 transition">Features</a> | |
| <a href="#" class="hover:text-blue-200 transition">Pricing</a> | |
| <a href="#" class="hover:text-blue-200 transition">Docs</a> | |
| <a href="#" class="hover:text-blue-200 transition">Contact</a> | |
| </div> | |
| <button class="bg-white text-blue-600 px-4 py-2 rounded-lg font-medium hover:bg-blue-50 transition"> | |
| Sign In | |
| </button> | |
| </div> | |
| <div class="mt-8 text-center"> | |
| <h2 class="text-4xl font-bold mb-4">Unlock the Power of Local Search</h2> | |
| <p class="text-xl max-w-2xl mx-auto opacity-90"> | |
| Hyper-local SEO insights powered by AI to dominate your market | |
| </p> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="container mx-auto px-4 py-8 -mt-10"> | |
| <div class="bg-white rounded-xl shadow-xl overflow-hidden"> | |
| <div class="p-6 border-b border-gray-200"> | |
| <h3 class="text-xl font-semibold text-gray-800">SEO Analysis Dashboard</h3> | |
| <p class="text-gray-600">Enter your local market details to get started</p> | |
| </div> | |
| <div class="p-6"> | |
| <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-6"> | |
| <div> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Area Codes</label> | |
| <div class="relative"> | |
| <input type="text" id="area-codes" placeholder="e.g., 212, 310, 786" | |
| class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"> | |
| <div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none"> | |
| <i class="fas fa-map-pin text-gray-400"></i> | |
| </div> | |
| </div> | |
| <p class="mt-1 text-xs text-gray-500">Comma-separated list of area codes</p> | |
| </div> | |
| <div> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Keywords</label> | |
| <div class="relative"> | |
| <input type="text" id="keywords" placeholder="e.g., vegan restaurant, plant-based dining" | |
| class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"> | |
| <div class="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none"> | |
| <i class="fas fa-key text-gray-400"></i> | |
| </div> | |
| </div> | |
| <p class="mt-1 text-xs text-gray-500">Comma-separated list of keywords</p> | |
| </div> | |
| <div> | |
| <label class="block text-sm font-medium text-gray-700 mb-1">Time Range</label> | |
| <select id="time-range" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"> | |
| <option value="6m">Past 6 Months</option> | |
| <option value="1y">Past 1 Year</option> | |
| <option value="all">All Time</option> | |
| </select> | |
| </div> | |
| </div> | |
| <div class="flex justify-between items-center"> | |
| <div class="flex space-x-2" id="keyword-chips-container"> | |
| <!-- Keyword chips will be added here --> | |
| </div> | |
| <button onclick="fetchSEOData()" | |
| class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-lg font-medium transition flex items-center space-x-2"> | |
| <i class="fas fa-chart-line"></i> | |
| <span>Analyze SEO Data</span> | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <div id="loading-indicator" class="hidden mt-8 text-center"> | |
| <div class="inline-block p-6 bg-white rounded-xl shadow-md"> | |
| <div class="flex items-center space-x-4"> | |
| <div class="pulse"> | |
| <i class="fas fa-spinner fa-spin text-blue-600 text-2xl"></i> | |
| </div> | |
| <div> | |
| <h4 class="font-medium text-gray-800">Crunching the numbers...</h4> | |
| <p class="text-sm text-gray-600">Analyzing local search trends and competition</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- XXXL Results Card at Bottom with Horizontal Layout --> | |
| <div id="results-container" class="fixed bottom-0 left-0 right-0 bg-white shadow-2xl rounded-t-3xl overflow-hidden hidden"> | |
| <div class="p-4 border-b border-gray-200 flex justify-between items-center bg-gray-50"> | |
| <h3 class="text-xl font-semibold text-gray-800">SEO Analysis Results</h3> | |
| <button onclick="closeResults()" class="text-gray-500 hover:text-gray-700"> | |
| <i class="fas fa-times text-xl"></i> | |
| </button> | |
| </div> | |
| <div class="results-container p-6"> | |
| <div id="results" class="results-horizontal"> | |
| <!-- Results will be dynamically inserted here as horizontal cards --> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| // Enhanced backend proxy with more realistic data simulation including emails and websites | |
| const backendProxy = { | |
| aiAgentApiKey: 'demo_key_12345', // In production, this should be server-side | |
| endpoints: { | |
| llama: 'https://api.example.com/llama', | |
| aiAgent: 'https://api.example.com/ai-agent', | |
| searchAgent: 'https://api.example.com/agent/search', | |
| sentimentAgent: 'https://api.example.com/agent/sentiment', | |
| competitorAgent: 'https://api.example.com/agent/competitor', | |
| contactAgent: 'https://api.example.com/agent/contacts' | |
| }, | |
| // Simulate API calls with realistic delay and demo data | |
| async callApi(endpoint, payload) { | |
| console.log(`Calling ${endpoint} with payload:`, payload); | |
| // Simulate network delay | |
| await new Promise(resolve => setTimeout(resolve, 800 + Math.random() * 700)); | |
| // Generate demo data based on the endpoint | |
| if (endpoint.includes('search')) { | |
| return this.generateSearchData(payload); | |
| } else if (endpoint.includes('sentiment')) { | |
| return this.generateSentimentData(payload); | |
| } else if (endpoint.includes('competitor')) { | |
| return this.generateCompetitorData(payload); | |
| } else if (endpoint.includes('llama')) { | |
| return this.generateLlamaData(payload); | |
| } else if (endpoint.includes('contact')) { | |
| return this.generateContactData(payload); | |
| } else { | |
| return this.generateAIAgentData(payload); | |
| } | |
| }, | |
| // Generate realistic search volume data | |
| generateSearchData({ areaCode, keywords }) { | |
| const data = {}; | |
| keywords.forEach(keyword => { | |
| // Base volume with area code modifier | |
| const baseVolume = 1000 + (parseInt(areaCode) % 100) * 20; | |
| // Random fluctuation | |
| const fluctuation = Math.floor(Math.random() * 300) - 150; | |
| data[keyword] = { | |
| volume: Math.max(100, baseVolume + fluctuation), | |
| cpc: (1 + Math.random() * 4).toFixed(2), | |
| competition: (20 + Math.random() * 60).toFixed(1) | |
| }; | |
| }); | |
| return data; | |
| }, | |
| // Generate sentiment analysis data | |
| generateSentimentData({ keywords }) { | |
| const sentiments = ['Positive', 'Neutral', 'Negative']; | |
| const data = {}; | |
| keywords.forEach(keyword => { | |
| data[keyword] = { | |
| score: (Math.random() * 2 - 1).toFixed(2), // -1 to 1 | |
| sentiment: sentiments[Math.floor(Math.random() * 3)] | |
| }; | |
| }); | |
| return data; | |
| }, | |
| // Generate competitor data with emails and websites | |
| generateCompetitorData({ keywords, areaCode }) { | |
| const competitors = [ | |
| { name: "LocalBiz", email: "contact@localbiz.com", website: "www.localbiz.com" }, | |
| { name: "CityServices", email: "info@cityservices.com", website: "www.cityservices.com" }, | |
| { name: "TopRank", email: "support@toprank.com", website: "www.toprank.com" }, | |
| { name: "PrimeLocal", email: "hello@primelocal.com", website: "www.primelocal.com" }, | |
| { name: "BestChoice", email: "contact@bestchoice.com", website: "www.bestchoice.com" }, | |
| { name: "FirstOption", email: "info@firstoption.com", website: "www.firstoption.com" }, | |
| { name: "MainStreet", email: "contact@mainstreet.com", website: "www.mainstreet.com" }, | |
| { name: "UrbanChoice", email: "hello@urbanchoice.com", website: "www.urbanchoice.com" }, | |
| { name: "MetroService", email: "info@metroservice.com", website: "www.metroservice.com" }, | |
| { name: "DowntownCo", email: "contact@downtownco.com", website: "www.downtownco.com" } | |
| ]; | |
| const data = {}; | |
| keywords.forEach(keyword => { | |
| const randomCompetitor = competitors[Math.floor(Math.random() * competitors.length)]; | |
| data[keyword] = { | |
| top: randomCompetitor.name, | |
| count: 5 + Math.floor(Math.random() * 20), | |
| email: randomCompetitor.email, | |
| website: randomCompetitor.website | |
| }; | |
| }); | |
| return data; | |
| }, | |
| // Generate contact data for the area | |
| generateContactData({ areaCode }) { | |
| const domains = ["gmail.com", "yahoo.com", "outlook.com", "aol.com", "protonmail.com"]; | |
| const businessTypes = ["restaurant", "shop", "service", "store", "clinic", "salon"]; | |
| const contacts = []; | |
| const count = 5 + Math.floor(Math.random() * 10); // 5-15 contacts per area | |
| for (let i = 0; i < count; i++) { | |
| const firstName = ["John", "Sarah", "Mike", "Lisa", "David", "Emily"][Math.floor(Math.random() * 6)]; | |
| const lastName = ["Smith", "Johnson", "Williams", "Brown", "Jones", "Garcia"][Math.floor(Math.random() * 6)]; | |
| const businessName = `${firstName}'s ${businessTypes[Math.floor(Math.random() * businessTypes.length)]}`; | |
| const domain = domains[Math.floor(Math.random() * domains.length)]; | |
| const email = `${firstName.toLowerCase()}.${lastName.toLowerCase()}@${domain}`; | |
| const website = `www.${businessName.toLowerCase().replace(/\s+/g, '')}.com`; | |
| contacts.push({ | |
| name: `${firstName} ${lastName}`, | |
| business: businessName, | |
| email: email, | |
| website: website, | |
| phone: `${areaCode}-${Math.floor(100 + Math.random() * 900)}-${Math.floor(1000 + Math.random() * 9000)}` | |
| }); | |
| } | |
| return { contacts }; | |
| }, | |
| // Generate enhanced keywords from LLaMA | |
| generateLlamaData({ keywords }) { | |
| const enhancements = { | |
| "vegan restaurant": ["plant-based dining", "vegan cafe", "vegetarian restaurant"], | |
| "plant-based dining": ["vegan bistro", "meat-free restaurant", "vegetarian fine dining"], | |
| "coffee shop": ["artisan coffee", "specialty cafe", "third wave coffee"], | |
| "hair salon": ["beauty salon", "hairstylist", "barber shop"], | |
| "plumber": ["emergency plumbing", "pipe repair", "water heater installation"] | |
| }; | |
| const enhanced = []; | |
| keywords.forEach(keyword => { | |
| if (enhancements[keyword.toLowerCase()]) { | |
| enhanced.push(...enhancements[keyword.toLowerCase()]); | |
| } else { | |
| // Generate some variations if no predefined enhancements | |
| enhanced.push(`${keyword} near me`); | |
| enhanced.push(`best ${keyword}`); | |
| enhanced.push(`affordable ${keyword}`); | |
| } | |
| }); | |
| return { | |
| keywords: [...new Set([...keywords, ...enhanced])], // Remove duplicates | |
| suggestions: `Consider creating content around these related terms to capture more local search traffic.` | |
| }; | |
| }, | |
| // Generate demographics data | |
| generateAIAgentData({ areaCode }) { | |
| const ageGroups = ["18-24", "25-34", "35-44", "45-54", "55-64", "65+"]; | |
| const devices = ["Mobile", "Desktop", "Tablet"]; | |
| const incomes = ["$30k-$50k", "$50k-$75k", "$75k-$100k", "$100k+"]; | |
| return { | |
| demographics: { | |
| ageGroup: ageGroups[Math.floor(Math.random() * ageGroups.length)], | |
| device: devices[Math.floor(Math.random() * devices.length)], | |
| income: incomes[Math.floor(Math.random() * incomes.length)], | |
| areaName: `Area ${areaCode}` | |
| } | |
| }; | |
| }, | |
| // Coordinate all tasks | |
| async aggregateSEOData(areaCodes, keywords, timeRange) { | |
| const results = []; | |
| for (const areaCode of areaCodes) { | |
| const areaData = { areaCode, keywords: [] }; | |
| // Step 1: Get enhanced keywords from LLaMA | |
| const llamaResponse = await this.callApi(this.endpoints.llama, { | |
| areaCode, | |
| keywords, | |
| task: 'keyword_analysis' | |
| }); | |
| const enhancedKeywords = llamaResponse.keywords; | |
| // Step 2: Get search volume data | |
| const searchResponse = await this.callApi(this.endpoints.searchAgent, { | |
| areaCode, | |
| keywords: enhancedKeywords, | |
| timeRange | |
| }); | |
| // Step 3: Get sentiment analysis | |
| const sentimentResponse = await this.callApi(this.endpoints.sentimentAgent, { | |
| areaCode, | |
| keywords: enhancedKeywords | |
| }); | |
| // Step 4: Get competitor data | |
| const competitorResponse = await this.callApi(this.endpoints.competitorAgent, { | |
| areaCode, | |
| keywords: enhancedKeywords | |
| }); | |
| // Step 5: Get demographics | |
| const aiAgentResponse = await this.callApi(this.endpoints.aiAgent, { | |
| areaCode, | |
| keywords: enhancedKeywords, | |
| timeRange | |
| }); | |
| // Step 6: Get contact information | |
| const contactResponse = await this.callApi(this.endpoints.contactAgent, { | |
| areaCode | |
| }); | |
| // Combine all data | |
| enhancedKeywords.forEach(keyword => { | |
| areaData.keywords.push({ | |
| keyword, | |
| searchVolume: searchResponse[keyword]?.volume || 0, | |
| cpc: searchResponse[keyword]?.cpc || 0, | |
| competition: searchResponse[keyword]?.competition || 0, | |
| sentiment: sentimentResponse[keyword]?.sentiment || 'Neutral', | |
| sentimentScore: sentimentResponse[keyword]?.score || 0, | |
| topCompetitor: competitorResponse[keyword]?.top || 'Unknown', | |
| competitorEmail: competitorResponse[keyword]?.email || 'N/A', | |
| competitorWebsite: competitorResponse[keyword]?.website || 'N/A', | |
| competitorCount: competitorResponse[keyword]?.count || 0 | |
| }); | |
| }); | |
| areaData.demographics = aiAgentResponse.demographics; | |
| areaData.keywordSuggestions = llamaResponse.suggestions; | |
| areaData.localContacts = contactResponse.contacts; | |
| results.push(areaData); | |
| } | |
| return results; | |
| } | |
| }; | |
| // Display keyword chips as user types | |
| document.getElementById('keywords').addEventListener('input', function(e) { | |
| const container = document.getElementById('keyword-chips-container'); | |
| container.innerHTML = ''; | |
| const keywords = e.target.value.split(',').map(k => k.trim()).filter(k => k.length > 0); | |
| keywords.forEach(keyword => { | |
| const chip = document.createElement('div'); | |
| chip.className = 'keyword-chip bg-blue-100 text-blue-800 px-3 py-1 rounded-full text-sm flex items-center'; | |
| chip.innerHTML = `<span>${keyword}</span>`; | |
| container.appendChild(chip); | |
| }); | |
| }); | |
| // Main function to fetch and display SEO data | |
| async function fetchSEOData() { | |
| const areaCodesInput = document.getElementById('area-codes').value; | |
| const keywordsInput = document.getElementById('keywords').value; | |
| const timeRange = document.getElementById('time-range').value; | |
| if (!areaCodesInput || !keywordsInput) { | |
| showAlert('Please enter both area codes and keywords.', 'error'); | |
| return; | |
| } | |
| const areaCodes = areaCodesInput.split(',').map(code => code.trim()).filter(code => code.length > 0); | |
| const keywords = keywordsInput.split(',').map(keyword => keyword.trim()).filter(keyword => keyword.length > 0); | |
| // Show loading indicator | |
| document.getElementById('loading-indicator').classList.remove('hidden'); | |
| try { | |
| const seoData = await backendProxy.aggregateSEOData(areaCodes, keywords, timeRange); | |
| displayResults(seoData); | |
| updateCharts(seoData); | |
| showResultsCard(); | |
| } catch (error) { | |
| console.error('Error:', error); | |
| showAlert('Error fetching SEO data. Please try again later.', 'error'); | |
| } finally { | |
| document.getElementById('loading-indicator').classList.add('hidden'); | |
| } | |
| } | |
| // Show the results card | |
| function showResultsCard() { | |
| document.getElementById('results-container').classList.remove('hidden'); | |
| document.body.style.overflow = 'hidden'; | |
| } | |
| // Close the results card | |
| function closeResults() { | |
| document.getElementById('results-container').classList.add('hidden'); | |
| document.body.style.overflow = ''; | |
| } | |
| // Display results in horizontal cards | |
| function displayResults(data) { | |
| const resultsDiv = document.getElementById('results'); | |
| resultsDiv.innerHTML = ''; | |
| data.forEach((area, index) => { | |
| // Add animation delay based on index | |
| const delay = index * 100; | |
| // Create a card for each area | |
| const areaCard = document.createElement('div'); | |
| areaCard.className = `result-card slide-in`; | |
| areaCard.style.animationDelay = `${delay}ms`; | |
| areaCard.innerHTML = ` | |
| <div class="p-6 border-b border-gray-200 bg-gradient-to-r from-blue-50 to-indigo-50"> | |
| <div class="flex flex-col"> | |
| <div> | |
| <h3 class="text-xl font-semibold text-gray-800"> | |
| <i class="fas fa-map-marker-alt text-blue-500 mr-2"></i> | |
| Area ${area.areaCode} Analysis | |
| </h3> | |
| <p class="text-gray-600 mt-1">${area.demographics.areaName}</p> | |
| </div> | |
| <div class="mt-4 grid grid-cols-3 gap-4"> | |
| <div class="text-center"> | |
| <p class="text-sm text-gray-500">Primary Device</p> | |
| <p class="font-medium">${area.demographics.device}</p> | |
| </div> | |
| <div class="text-center"> | |
| <p class="text-sm text-gray-500">Age Group</p> | |
| <p class="font-medium">${area.demographics.ageGroup}</p> | |
| </div> | |
| <div class="text-center"> | |
| <p class="text-sm text-gray-500">Income Level</p> | |
| <p class="font-medium">${area.demographics.income}</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="p-6"> | |
| <div class="mb-6"> | |
| <h4 class="text-lg font-medium text-gray-800 mb-2">Keyword Suggestions</h4> | |
| <p class="text-gray-700 text-sm">${area.keywordSuggestions}</p> | |
| <div class="mt-3 flex flex-wrap gap-2"> | |
| ${area.keywords.slice(0, 5).map(kw => ` | |
| <span class="bg-blue-100 text-blue-800 px-2 py-1 rounded-full text-xs"> | |
| ${kw.keyword} | |
| </span> | |
| `).join('')} | |
| </div> | |
| </div> | |
| <!-- Search Volume Chart --> | |
| <div class="mb-6"> | |
| <h4 class="text-md font-medium text-gray-800 mb-2 flex items-center"> | |
| <i class="fas fa-chart-bar text-blue-500 mr-2 text-sm"></i> | |
| Search Volume | |
| </h4> | |
| <div class="h-40"> | |
| <canvas id="chart-volume-${area.areaCode}"></canvas> | |
| </div> | |
| </div> | |
| <!-- Competition Gauge --> | |
| <div class="mb-6"> | |
| <h4 class="text-md font-medium text-gray-800 mb-2 flex items-center"> | |
| <i class="fas fa-trophy text-yellow-500 mr-2 text-sm"></i> | |
| Competition | |
| </h4> | |
| <div class="h-40"> | |
| <canvas id="chart-gauge-${area.areaCode}"></canvas> | |
| </div> | |
| </div> | |
| <!-- Top Competitor --> | |
| <div class="mb-4"> | |
| <h4 class="text-md font-medium text-gray-800 mb-2 flex items-center"> | |
| <i class="fas fa-crown text-purple-500 mr-2 text-sm"></i> | |
| Top Competitor | |
| </h4> | |
| <div class="bg-gray-50 p-3 rounded-lg"> | |
| <p class="font-medium text-gray-800">${area.keywords[0]?.topCompetitor || 'N/A'}</p> | |
| <p class="text-xs text-gray-600 mt-1"> | |
| <i class="fas fa-envelope mr-1 text-blue-500"></i> ${area.keywords[0]?.competitorEmail || 'N/A'} | |
| </p> | |
| <p class="text-xs text-gray-600"> | |
| <i class="fas fa-globe mr-1 text-green-500"></i> ${area.keywords[0]?.competitorWebsite || 'N/A'} | |
| </p> | |
| </div> | |
| </div> | |
| </div> | |
| `; | |
| resultsDiv.appendChild(areaCard); | |
| // Render charts after the element is added to DOM | |
| setTimeout(() => { | |
| renderVolumeChart(`chart-volume-${area.areaCode}`, area.keywords); | |
| renderGaugeChart(`chart-gauge-${area.areaCode}`, area.keywords); | |
| }, 100); | |
| }); | |
| } | |
| // Render volume chart for an area | |
| function renderVolumeChart(canvasId, keywords) { | |
| const ctx = document.getElementById(canvasId).getContext('2d'); | |
| const labels = keywords.slice(0, 5).map(kw => kw.keyword); | |
| const data = keywords.slice(0, 5).map(kw => kw.searchVolume); | |
| new Chart(ctx, { | |
| type: 'bar', | |
| data: { | |
| labels: labels, | |
| datasets: [{ | |
| label: 'Search Volume', | |
| data: data, | |
| backgroundColor: '#3b82f6', | |
| borderColor: '#2563eb', | |
| borderWidth: 1 | |
| }] | |
| }, | |
| options: { | |
| responsive: true, | |
| maintainAspectRatio: false, | |
| scales: { | |
| y: { | |
| beginAtZero: true, | |
| grid: { | |
| drawBorder: false | |
| }, | |
| ticks: { | |
| font: { | |
| size: 10 | |
| } | |
| } | |
| }, | |
| x: { | |
| grid: { | |
| display: false | |
| }, | |
| ticks: { | |
| font: { | |
| size: 10 | |
| } | |
| } | |
| } | |
| }, | |
| plugins: { | |
| legend: { | |
| display: false | |
| }, | |
| tooltip: { | |
| backgroundColor: '#1e40af', | |
| titleFont: { | |
| size: 12, | |
| weight: 'bold' | |
| }, | |
| bodyFont: { | |
| size: 10 | |
| }, | |
| callbacks: { | |
| label: function(context) { | |
| return `Search Volume: ${context.raw}`; | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }); | |
| } | |
| // Render competition gauge chart | |
| function renderGaugeChart(canvasId, keywords) { | |
| const ctx = document.getElementById(canvasId).getContext('2d'); | |
| const avgCompetition = keywords.reduce((sum, kw) => sum + parseFloat(kw.competition), 0) / keywords.length; | |
| new Chart(ctx, { | |
| type: 'doughnut', | |
| data: { | |
| labels: ['Competition', 'Remaining'], | |
| datasets: [{ | |
| data: [avgCompetition, 100 - avgCompetition], | |
| backgroundColor: ['#3b82f6', '#e5e7eb'], | |
| borderWidth: 0 | |
| }] | |
| }, | |
| options: { | |
| responsive: true, | |
| maintainAspectRatio: false, | |
| cutout: '80%', | |
| rotation: -90, | |
| circumference: 180, | |
| plugins: { | |
| legend: { | |
| display: false | |
| }, | |
| tooltip: { | |
| enabled: false | |
| } | |
| }, | |
| animation: { | |
| animateScale: true, | |
| animateRotate: true | |
| } | |
| }, | |
| plugins: [{ | |
| id: 'gauge-text', | |
| afterDraw(chart) { | |
| const { ctx, data, chartArea: { width, height } } = chart; | |
| ctx.save(); | |
| const text = `${avgCompetition.toFixed(1)}%`; | |
| const text2 = 'Avg Competition'; | |
| ctx.font = 'bold 16px Poppins'; | |
| ctx.fillStyle = '#1e293b'; | |
| ctx.textAlign = 'center'; | |
| ctx.fillText(text, width / 2, height / 2 + 10); | |
| ctx.font = '10px Poppins'; | |
| ctx.fillStyle = '#64748b'; | |
| ctx.fillText(text2, width / 2, height / 2 + 30); | |
| ctx.restore(); | |
| } | |
| }] | |
| }); | |
| } | |
| // Show alert message | |
| function showAlert(message, type = 'info') { | |
| const alert = document.createElement('div'); | |
| alert.className = `fixed top-4 right-4 p-4 rounded-lg shadow-lg z-50 ${ | |
| type === 'error' ? 'bg-red-100 border-l-4 border-red-500 text-red-700' : | |
| type === 'success' ? 'bg-green-100 border-l-4 border-green-500 text-green-700' : | |
| 'bg-blue-100 border-l-4 border-blue-500 text-blue-700' | |
| }`; | |
| alert.innerHTML = ` | |
| <div class="flex items-center"> | |
| <i class="fas ${ | |
| type === 'error' ? 'fa-exclamation-circle' : | |
| type === 'success' ? 'fa-check-circle' : 'fa-info-circle' | |
| } mr-2"></i> | |
| <span>${message}</span> | |
| </div> | |
| `; | |
| document.body.appendChild(alert); | |
| setTimeout(() => { | |
| alert.remove(); | |
| }, 5000); | |
| } | |
| // Update charts (placeholder for future functionality) | |
| function updateCharts(data) { | |
| // This function can be used to update charts dynamically if needed | |
| console.log('Charts updated with new data:', data); | |
| } | |
| </script> | |
| <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=MarcRyan/geopulse" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body> | |
| </html> |