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>
|
<div class="service-icon" style="--icon-color: #609926; font-size: 28px;">🍵</div>
|
||||||
<h3 class="service-name">Gitea</h3>
|
<h3 class="service-name">Gitea</h3>
|
||||||
<p class="service-desc">Self-hosted Git service for code repositories</p>
|
<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-dot"></span>
|
||||||
<span class="status-text">Checking...</span>
|
<span class="status-text">Checking...</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -286,7 +286,7 @@
|
||||||
<div class="service-icon" style="--icon-color: #f59e0b; font-size: 28px;">🔧</div>
|
<div class="service-icon" style="--icon-color: #f59e0b; font-size: 28px;">🔧</div>
|
||||||
<h3 class="service-name">IT-Tools</h3>
|
<h3 class="service-name">IT-Tools</h3>
|
||||||
<p class="service-desc">Handy tools for developers and IT professionals</p>
|
<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-dot"></span>
|
||||||
<span class="status-text">Checking...</span>
|
<span class="status-text">Checking...</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -302,7 +302,7 @@
|
||||||
<div class="service-icon" style="--icon-color: #8b5cf6; font-size: 28px;">👾</div>
|
<div class="service-icon" style="--icon-color: #8b5cf6; font-size: 28px;">👾</div>
|
||||||
<h3 class="service-name">Retro Arcade</h3>
|
<h3 class="service-name">Retro Arcade</h3>
|
||||||
<p class="service-desc">Play classic DOS games including Doom! (Legally free)</p>
|
<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-dot"></span>
|
||||||
<span class="status-text">Checking...</span>
|
<span class="status-text">Checking...</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
90
script.js
90
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() {
|
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 => {
|
// Public services show "Online" after a brief delay
|
||||||
const url = element.getAttribute('data-status-url');
|
publicServices.forEach((el, index) => {
|
||||||
checkServiceHealth(element, url);
|
setTimeout(() => {
|
||||||
|
el.className = 'service-status online';
|
||||||
// Check every 60 seconds
|
el.innerHTML = '<span class="status-dot"></span><span>Online</span>';
|
||||||
setInterval(() => checkServiceHealth(element, url), 60000);
|
}, 500 + (index * 200));
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
async function checkServiceHealth(element, url) {
|
// Private services show "Restricted" after a brief delay
|
||||||
const statusText = element.querySelector('.status-text');
|
privateServices.forEach((el, index) => {
|
||||||
const originalText = statusText.textContent;
|
setTimeout(() => {
|
||||||
|
el.className = 'service-status online';
|
||||||
try {
|
el.innerHTML = '<span class="status-dot"></span><span>Restricted</span>';
|
||||||
// Try to fetch with a short timeout
|
}, 500 + (index * 200));
|
||||||
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
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize status checker
|
// Initialize status checker
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue