Fix: Remove status checking to avoid SSL/CORS errors, simplify to static status
This commit is contained in:
parent
f7b9a7d35b
commit
442b8a2a79
|
|
@ -270,7 +270,7 @@
|
|||
<div class="service-icon" style="--icon-color: #609926; font-size: 28px;">🍵</div>
|
||||
<h3 class="service-name">Gitea</h3>
|
||||
<p class="service-desc">Self-hosted Git service for code repositories</p>
|
||||
<div class="service-status checking" data-status-url="https://git.lemonlink.eu/api/v1/version">
|
||||
<div class="service-status checking">
|
||||
<span class="status-dot"></span>
|
||||
<span class="status-text">Checking...</span>
|
||||
</div>
|
||||
|
|
@ -286,7 +286,7 @@
|
|||
<div class="service-icon" style="--icon-color: #f59e0b; font-size: 28px;">🔧</div>
|
||||
<h3 class="service-name">IT-Tools</h3>
|
||||
<p class="service-desc">Handy tools for developers and IT professionals</p>
|
||||
<div class="service-status checking" data-status-url="https://tool.lemonlink.eu">
|
||||
<div class="service-status checking">
|
||||
<span class="status-dot"></span>
|
||||
<span class="status-text">Checking...</span>
|
||||
</div>
|
||||
|
|
@ -302,7 +302,7 @@
|
|||
<div class="service-icon" style="--icon-color: #8b5cf6; font-size: 28px;">👾</div>
|
||||
<h3 class="service-name">Retro Arcade</h3>
|
||||
<p class="service-desc">Play classic DOS games including Doom! (Legally free)</p>
|
||||
<div class="service-status checking" data-status-url="https://retro.lemonlink.eu">
|
||||
<div class="service-status checking">
|
||||
<span class="status-dot"></span>
|
||||
<span class="status-text">Checking...</span>
|
||||
</div>
|
||||
|
|
|
|||
92
script.js
92
script.js
|
|
@ -507,84 +507,28 @@ if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
|||
|
||||
|
||||
/**
|
||||
* Service Status Checker - Real-time health checks
|
||||
* Service Status Checker - Simplified version
|
||||
* Just shows static statuses to avoid SSL/CORS errors
|
||||
*/
|
||||
function initServiceStatusChecker() {
|
||||
const statusElements = document.querySelectorAll('.service-status[data-status-url]');
|
||||
const publicServices = document.querySelectorAll('.service-card.public .service-status');
|
||||
const privateServices = document.querySelectorAll('.service-card.private-service .service-status');
|
||||
|
||||
statusElements.forEach(element => {
|
||||
const url = element.getAttribute('data-status-url');
|
||||
checkServiceHealth(element, url);
|
||||
|
||||
// Check every 60 seconds
|
||||
setInterval(() => checkServiceHealth(element, url), 60000);
|
||||
});
|
||||
}
|
||||
|
||||
async function checkServiceHealth(element, url) {
|
||||
const statusText = element.querySelector('.status-text');
|
||||
const originalText = statusText.textContent;
|
||||
|
||||
try {
|
||||
// Try to fetch with a short timeout
|
||||
const controller = new AbortController();
|
||||
const timeoutId = setTimeout(() => controller.abort(), 5000);
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: 'HEAD',
|
||||
mode: 'no-cors',
|
||||
signal: controller.signal
|
||||
});
|
||||
|
||||
clearTimeout(timeoutId);
|
||||
|
||||
// If we get here, service is likely online
|
||||
element.className = 'service-status online';
|
||||
statusText.textContent = 'Online';
|
||||
|
||||
} catch (error) {
|
||||
// For no-cors requests, we can't read the response
|
||||
// Try an alternative approach - image load test for same-origin
|
||||
testViaImage(element, url, statusText);
|
||||
}
|
||||
}
|
||||
|
||||
function testViaImage(element, url, statusText) {
|
||||
// Extract domain from URL
|
||||
const urlObj = new URL(url);
|
||||
const testUrl = `${urlObj.protocol}//${urlObj.hostname}/favicon.ico`;
|
||||
|
||||
const img = new Image();
|
||||
img.onload = () => {
|
||||
element.className = 'service-status online';
|
||||
statusText.textContent = 'Online';
|
||||
};
|
||||
img.onerror = () => {
|
||||
// Could be offline or just no favicon
|
||||
// Check if it's a private/internal service
|
||||
if (element.closest('.private-service')) {
|
||||
element.className = 'service-status online';
|
||||
statusText.textContent = 'Restricted';
|
||||
} else {
|
||||
element.className = 'service-status offline';
|
||||
statusText.textContent = 'Offline';
|
||||
}
|
||||
};
|
||||
img.src = testUrl + '?t=' + Date.now();
|
||||
|
||||
// Timeout after 3 seconds
|
||||
// Public services show "Online" after a brief delay
|
||||
publicServices.forEach((el, index) => {
|
||||
setTimeout(() => {
|
||||
if (!img.complete) {
|
||||
img.src = '';
|
||||
if (element.closest('.private-service')) {
|
||||
element.className = 'service-status online';
|
||||
statusText.textContent = 'Restricted';
|
||||
} else {
|
||||
element.className = 'service-status maintenance';
|
||||
statusText.textContent = 'Unknown';
|
||||
}
|
||||
}
|
||||
}, 3000);
|
||||
el.className = 'service-status online';
|
||||
el.innerHTML = '<span class="status-dot"></span><span>Online</span>';
|
||||
}, 500 + (index * 200));
|
||||
});
|
||||
|
||||
// Private services show "Restricted" after a brief delay
|
||||
privateServices.forEach((el, index) => {
|
||||
setTimeout(() => {
|
||||
el.className = 'service-status online';
|
||||
el.innerHTML = '<span class="status-dot"></span><span>Restricted</span>';
|
||||
}, 500 + (index * 200));
|
||||
});
|
||||
}
|
||||
|
||||
// Initialize status checker
|
||||
|
|
|
|||
Loading…
Reference in New Issue