Spaces:
Running
Running
Download script.js from aakgur/google-data-sync-wizard: direct link, hf CLI and curl.
- Browser
- Download file 3.85 kB
-
https://huggingface.co/spaces/aakgur/google-data-sync-wizard/resolve/main/script.js
- Command line
-
hf download hf://spaces/aakgur/google-data-sync-wizard/script.js
-
curl -L -o script.js https://huggingface.co/spaces/aakgur/google-data-sync-wizard/resolve/main/script.js
3.85 kB
| document.addEventListener('DOMContentLoaded', function() { | |
| // Sample activity data - in a real app this would come from an API | |
| const activities = [ | |
| { | |
| type: 'Search Console', | |
| status: 'Completed', | |
| items: 142, | |
| date: new Date(Date.now() - 3600000).toLocaleString(), | |
| icon: 'search' | |
| }, | |
| { | |
| type: 'Analytics', | |
| status: 'In Progress', | |
| items: 327, | |
| date: new Date(Date.now() - 7200000).toLocaleString(), | |
| icon: 'bar-chart-2' | |
| }, | |
| { | |
| type: 'Search Console', | |
| status: 'Failed', | |
| items: 83, | |
| date: new Date(Date.now() - 86400000).toLocaleString(), | |
| icon: 'search' | |
| }, | |
| { | |
| type: 'Analytics', | |
| status: 'Completed', | |
| items: 256, | |
| date: new Date(Date.now() - 172800000).toLocaleString(), | |
| icon: 'bar-chart-2' | |
| } | |
| ]; | |
| const activityTable = document.getElementById('activityTable'); | |
| // Populate the activity table | |
| activities.forEach(activity => { | |
| const row = document.createElement('tr'); | |
| // Status color | |
| let statusColor = 'bg-green-100 text-green-800'; | |
| if (activity.status === 'In Progress') { | |
| statusColor = 'bg-blue-100 text-blue-800'; | |
| } else if (activity.status === 'Failed') { | |
| statusColor = 'bg-red-100 text-red-800'; | |
| } | |
| row.innerHTML = ` | |
| <td class="px-6 py-4 whitespace-nowrap"> | |
| <div class="flex items-center"> | |
| <i data-feather="${activity.icon}" class="w-4 h-4 mr-2"></i> | |
| <span class="text-sm font-medium text-gray-900">${activity.type}</span> | |
| </div> | |
| </td> | |
| <td class="px-6 py-4 whitespace-nowrap"> | |
| <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${statusColor}"> | |
| ${activity.status} | |
| </span> | |
| </td> | |
| <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"> | |
| ${activity.items} items | |
| </td> | |
| <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500"> | |
| ${activity.date} | |
| </td> | |
| `; | |
| activityTable.appendChild(row); | |
| }); | |
| // Initialize feather icons again after adding dynamic content | |
| feather.replace(); | |
| }); | |
| // Google Sign-In handler | |
| async function handleGoogleSignIn(response) { | |
| try { | |
| const res = await fetch('/auth/google'); | |
| if (res.redirected) { | |
| window.location.href = res.url; | |
| } | |
| } catch (error) { | |
| console.error('Google Sign-In error:', error); | |
| } | |
| } | |
| // Search Console Submit | |
| async function submitSearchConsole(urls, siteUrl) { | |
| try { | |
| const response = await fetch('/api/search-console/submit', { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json' | |
| }, | |
| body: JSON.stringify({ urls, siteUrl }) | |
| }); | |
| return await response.json(); | |
| } catch (error) { | |
| console.error('Search Console submit error:', error); | |
| return { error: 'Failed to submit URLs' }; | |
| } | |
| } | |
| // Analytics Submit | |
| async function submitAnalyticsEvents(events, trackingId) { | |
| try { | |
| const response = await fetch('/api/analytics/submit', { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json' | |
| }, | |
| body: JSON.stringify({ events, trackingId }) | |
| }); | |
| return await response.json(); | |
| } catch (error) { | |
| console.error('Analytics submit error:', error); | |
| return { error: 'Failed to submit events' }; | |
| } | |
| } | |