diff --git a/.gitignore b/.gitignore index 1dcef2d..02c607c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules -.env \ No newline at end of file +.env +data \ No newline at end of file diff --git a/data/ebay_items.db b/data/ebay_items.db index e8ff1d8..5e41937 100644 Binary files a/data/ebay_items.db and b/data/ebay_items.db differ diff --git a/public/index.html b/public/index.html index 6bb4745..8b33f25 100644 --- a/public/index.html +++ b/public/index.html @@ -334,7 +334,7 @@ let currentProfileId = null; let items = []; let isScanning = false; - + const API_URL = "https://logs1.danielvu.com/ebay-price-check" const fmat = (v) => new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(v || 0); async function init() { @@ -347,7 +347,7 @@ } async function fetchProfiles() { - const res = await fetch('/api/profiles'); + const res = await fetch(API_URL+'/api/profiles'); profiles = await res.json(); renderTabs(); } @@ -372,7 +372,7 @@ async function fetchItems() { if (!currentProfileId) return; - const res = await fetch(`/api/items?profile_id=${currentProfileId}`); + const res = await fetch(API_URL+`/api/items?profile_id=${currentProfileId}`); items = await res.json(); renderItems(); } @@ -420,7 +420,7 @@ } async function fetchStatus() { - const res = await fetch('/api/status'); + const res = await fetch(API_URL+'/api/status'); const data = await res.json(); isScanning = data.isScanning; document.getElementById('status-dot').className = `status-dot ${isScanning ? 'active' : ''}`; @@ -449,7 +449,7 @@ async function triggerScan(target) { const pid = target === 'all' ? 'all' : currentProfileId; if (!pid) return; - await fetch('/api/scan', { + await fetch(API_URL+'/api/scan', { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ profile_id: pid }) @@ -458,7 +458,7 @@ } async function updateStatus(id, status) { - await fetch(`/api/items/${id}/status`, { + await fetch(API_URL+`/api/items/${id}/status`, { method: 'PUT', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ status }) @@ -516,7 +516,7 @@ if (!name) return; const method = editingProfileId ? 'PUT' : 'POST'; - const url = editingProfileId ? `/api/profiles/${editingProfileId}` : '/api/profiles'; + const url = editingProfileId ? API_URL+`/api/profiles/${editingProfileId}` : API_URL+'/api/profiles'; await fetch(url, { method, @@ -532,7 +532,7 @@ } async function deleteProfile(id) { if (!confirm('Delete this profile and ALL associated data?')) return; - await fetch(`/api/profiles/${id}`, { method: 'DELETE' }); + await fetch(API_URL+`/api/profiles/${id}`, { method: 'DELETE' }); await fetchProfiles(); if (currentProfileId == id) currentProfileId = profiles[0]?.id || null; renderProfileList(); @@ -559,7 +559,7 @@ } let currentKeywordsData = []; async function fetchKeywords() { - const res = await fetch(`/api/profiles/${currentProfileId}/keywords`); + const res = await fetch(API_URL+`/api/profiles/${currentProfileId}/keywords`); currentKeywordsData = await res.json(); const tbody = document.getElementById('kw-tbody'); tbody.innerHTML = currentKeywordsData.map(kw => ` @@ -595,7 +595,7 @@ const keywords = list.split(',').map(s => s.trim()).filter(Boolean); const method = editingKeywordId ? 'PUT' : 'POST'; - const url = editingKeywordId ? `/api/keywords/${editingKeywordId}` : `/api/profiles/${currentProfileId}/keywords`; + const url = editingKeywordId ? API_URL+`/api/keywords/${editingKeywordId}` : API_URL+`/api/profiles/${currentProfileId}/keywords`; await fetch(url, { method, @@ -607,7 +607,7 @@ await fetchKeywords(); } async function deleteKeyword(id) { - await fetch(`/api/keywords/${id}`, { method: 'DELETE' }); + await fetch(API_URL+`/api/keywords/${id}`, { method: 'DELETE' }); await fetchKeywords(); } @@ -646,7 +646,7 @@ return; } - await fetch(`/api/profiles/${currentProfileId}/keywords/bulk`, { + await fetch(API_URL+`/api/profiles/${currentProfileId}/keywords/bulk`, { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify({ items }) diff --git a/server.js b/server.js index 9bd51f5..33bcd70 100644 --- a/server.js +++ b/server.js @@ -23,6 +23,7 @@ if (!fs.existsSync(publicDir)) { } // Track scanning state +let isScanning = false; let lastRunTime = null; let scanProgress = { current: 0, total: 0, profileName: '' };