chore: delete dead progress.js (#4)
This commit is contained in:
@@ -1,97 +0,0 @@
|
|||||||
function fetchRatingsWithProgress() {
|
|
||||||
const progressSection = document.getElementById('progress-section');
|
|
||||||
const progressBar = document.getElementById('progress-bar');
|
|
||||||
const progressText = document.getElementById('progress-text');
|
|
||||||
const tableDiv = document.getElementById('ratings-table');
|
|
||||||
|
|
||||||
progressSection.style.display = 'block';
|
|
||||||
tableDiv.innerHTML = '';
|
|
||||||
|
|
||||||
const eventSource = new EventSource('/api/ratings/progress');
|
|
||||||
|
|
||||||
eventSource.onmessage = function(event) {
|
|
||||||
const data = JSON.parse(event.data);
|
|
||||||
|
|
||||||
if (data.status === 'loading') {
|
|
||||||
const percentage = Math.round((data.current / data.total) * 100);
|
|
||||||
progressBar.style.width = `${percentage}%`;
|
|
||||||
progressBar.textContent = `${percentage}%`;
|
|
||||||
progressText.textContent = `Loading player ${data.current}/${data.total}: PDGA #${data.pdgaNumber}`;
|
|
||||||
} else if (data.status === 'completed') {
|
|
||||||
const percentage = Math.round((data.current / data.total) * 100);
|
|
||||||
progressBar.style.width = `${percentage}%`;
|
|
||||||
progressBar.textContent = `${percentage}%`;
|
|
||||||
progressText.textContent = `Loaded ${data.name} (${data.current}/${data.total})`;
|
|
||||||
} else if (data.status === 'error') {
|
|
||||||
const percentage = Math.round((data.current / data.total) * 100);
|
|
||||||
progressBar.style.width = `${percentage}%`;
|
|
||||||
progressBar.textContent = `${percentage}%`;
|
|
||||||
progressText.textContent = `Error loading PDGA #${data.pdgaNumber} (${data.current}/${data.total})`;
|
|
||||||
} else if (data.status === 'complete') {
|
|
||||||
progressSection.style.display = 'none';
|
|
||||||
htmx.ajax('GET', '/partials/ratings-table', '#ratings-table');
|
|
||||||
eventSource.close();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
eventSource.onerror = function() {
|
|
||||||
progressSection.style.display = 'none';
|
|
||||||
tableDiv.textContent = 'Connection error. Please refresh the page.';
|
|
||||||
eventSource.close();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadAllPlayers() {
|
|
||||||
const button = document.getElementById('load-all-btn');
|
|
||||||
const originalText = button.textContent;
|
|
||||||
button.textContent = 'Loading...';
|
|
||||||
button.style.pointerEvents = 'none';
|
|
||||||
|
|
||||||
try {
|
|
||||||
const progressSection = document.getElementById('progress-section');
|
|
||||||
const progressBar = document.getElementById('progress-bar');
|
|
||||||
const progressText = document.getElementById('progress-text');
|
|
||||||
const tableDiv = document.getElementById('ratings-table');
|
|
||||||
|
|
||||||
progressSection.style.display = 'block';
|
|
||||||
tableDiv.textContent = '';
|
|
||||||
|
|
||||||
const eventSource = new EventSource('/api/load-all-players');
|
|
||||||
|
|
||||||
eventSource.onmessage = function(event) {
|
|
||||||
const data = JSON.parse(event.data);
|
|
||||||
|
|
||||||
if (data.status === 'loading' || data.status === 'completed' || data.status === 'error') {
|
|
||||||
const percentage = Math.round((data.current / data.total) * 100);
|
|
||||||
progressBar.style.width = `${percentage}%`;
|
|
||||||
progressBar.textContent = `${percentage}%`;
|
|
||||||
|
|
||||||
if (data.status === 'loading') {
|
|
||||||
progressText.textContent = `Loading player ${data.current}/${data.total}: PDGA #${data.pdgaNumber}`;
|
|
||||||
} else if (data.status === 'completed') {
|
|
||||||
progressText.textContent = `Loaded ${data.name} (${data.current}/${data.total})`;
|
|
||||||
} else if (data.status === 'error') {
|
|
||||||
progressText.textContent = `Error loading PDGA #${data.pdgaNumber} (${data.current}/${data.total})`;
|
|
||||||
}
|
|
||||||
} else if (data.status === 'complete') {
|
|
||||||
progressSection.style.display = 'none';
|
|
||||||
htmx.ajax('GET', '/partials/ratings-table', '#ratings-table');
|
|
||||||
eventSource.close();
|
|
||||||
button.textContent = originalText;
|
|
||||||
button.style.pointerEvents = 'auto';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
eventSource.onerror = function() {
|
|
||||||
progressSection.style.display = 'none';
|
|
||||||
tableDiv.textContent = 'Connection error. Please refresh the page.';
|
|
||||||
eventSource.close();
|
|
||||||
button.textContent = originalText;
|
|
||||||
button.style.pointerEvents = 'auto';
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error loading all players:', error);
|
|
||||||
button.textContent = originalText;
|
|
||||||
button.style.pointerEvents = 'auto';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user