9bfd25a485
<div id="daysPassed"></div><script>
const startDate = new Date("2025-08-04");
const today = new Date();
const timeDiff = today - startDate;
const daysPassed = Math.floor(timeDiff / (1000 * 60 * 60 * 24)) + 1;
document.getElementById("daysPassed").innerHTML = "<b>Days passed:</b> " + daysPassed + " days";
</script><hr>
244 lines
7.3 KiB
HTML
244 lines
7.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<title>Domain Uptime Monitor</title>
|
|
<style>
|
|
body {
|
|
font-family: sans-serif;
|
|
background: #f8f9fa;
|
|
margin: 2rem;
|
|
}
|
|
h1 {
|
|
text-align: center;
|
|
color: #28a745;
|
|
}
|
|
.service {
|
|
background: white;
|
|
padding: 1rem;
|
|
border-radius: 8px;
|
|
margin-bottom: 2rem;
|
|
box-shadow: 0 0 8px rgba(0,0,0,0.05);
|
|
}
|
|
.service-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 1rem;
|
|
}
|
|
.service-name {
|
|
font-size: 1.2rem;
|
|
font-weight: bold;
|
|
}
|
|
.status {
|
|
font-weight: bold;
|
|
padding: 0.2rem 0.6rem;
|
|
border-radius: 4px;
|
|
}
|
|
.status.up { color: #28a745; }
|
|
.status.down { color: #dc3545; }
|
|
.bar {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 2px;
|
|
}
|
|
.bar-block {
|
|
width: 10px;
|
|
height: 20px;
|
|
border-radius: 2px;
|
|
background: #ccc;
|
|
cursor: pointer;
|
|
border: 1px solid transparent;
|
|
}
|
|
.bar-block.up { background: #28a745; }
|
|
.bar-block.down { background: #dc3545; }
|
|
.bar-block.selected {
|
|
border: 1px solid #000;
|
|
//box-sizing: border-box;
|
|
}
|
|
.uptime {
|
|
margin-top: 0.5rem;
|
|
font-size: 0.9rem;
|
|
color: #333;
|
|
}
|
|
.popup {
|
|
position: absolute;
|
|
background: white;
|
|
border: 1px solid #ccc;
|
|
padding: 0.5rem;
|
|
border-radius: 4px;
|
|
font-size: 0.85rem;
|
|
box-shadow: 0 2px 8px rgba(0,0,0,0.2);
|
|
display: none;
|
|
z-index: 1000;
|
|
max-width: 300px;
|
|
}
|
|
.popup .entry {
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
.popup .up { color: #28a745; }
|
|
.popup .down { color: #dc3545; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1><u>Domain Uptime </u>"<a target="_blank" href="https://alceawis.de/other/extra/scripts/fakesocialmedia/commentload.html?number=5000&text=When you don%27t want to ge" style=color:#28a745>Monitor</a>" <a href="http://127.0.0.1:8080/2025-08-04-UptimeCheck/sync.php" target="_blank" style=color:lightgrey>Sync</a> <a target="_blank" href="check.php" style=color:blue>⟳</a>
|
|
</h1>
|
|
<div id="daysPassed"></div><script>
|
|
const startDate = new Date("2025-08-04");
|
|
const today = new Date();
|
|
const timeDiff = today - startDate;
|
|
const daysPassed = Math.floor(timeDiff / (1000 * 60 * 60 * 24)) + 1;
|
|
document.getElementById("daysPassed").innerHTML = "<b>Days passed:</b> " + daysPassed + " days";
|
|
</script><hr>
|
|
<div id="container"></div>
|
|
<div id="popup" class="popup"></div>
|
|
<script>
|
|
const domainFiles = [
|
|
'alceawis.de.json',
|
|
'alceawis.com.json',
|
|
'alcea-wisteria.de.json'
|
|
];
|
|
|
|
function statusLabel(code) {
|
|
return code === 200 ? 'UP' : 'DOWN';
|
|
}
|
|
|
|
function getStatusClass(code) {
|
|
return code === 200 ? 'up' : 'down';
|
|
}
|
|
|
|
function getDateOnly(datetime) {
|
|
return datetime.split(' ')[0];
|
|
}
|
|
|
|
function filterUniquePerDay(entries) {
|
|
const map = new Map();
|
|
|
|
for (let entry of entries) {
|
|
const day = getDateOnly(entry.date);
|
|
if (!map.has(day)) {
|
|
map.set(day, []);
|
|
}
|
|
map.get(day).push(entry);
|
|
}
|
|
|
|
// Create array with all entries per day
|
|
const daysArray = Array.from(map.entries()).map(([day, entries]) => {
|
|
// Sort entries within the day (newest first)
|
|
entries.sort((a, b) => new Date(b.date) - new Date(a.date));
|
|
// Prefer DOWN status if any exists for the day
|
|
const latestEntry = entries.find(entry => entry.response_code !== 200) || entries[0];
|
|
return { day, entry: latestEntry, allEntries: entries };
|
|
});
|
|
|
|
// Sort days by date (newest first)
|
|
daysArray.sort((a, b) => new Date(b.day) - new Date(a.day));
|
|
|
|
return daysArray;
|
|
}
|
|
|
|
async function loadDomainData(filename) {
|
|
try {
|
|
const url = `${filename}?t=${new Date().getTime()}`;
|
|
const res = await fetch(url, {
|
|
headers: {
|
|
'Cache-Control': 'no-store',
|
|
}
|
|
});
|
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
const data = await res.json();
|
|
return Array.isArray(data) ? data : [];
|
|
} catch(err) {
|
|
console.error(`Error loading ${filename}:`, err);
|
|
return [];
|
|
}
|
|
}
|
|
|
|
function renderService(domain, entries) {
|
|
const filtered = filterUniquePerDay(entries);
|
|
|
|
// Calculate uptime percentage from all days
|
|
const upCount = filtered.filter(entry => entry.entry.response_code === 200).length;
|
|
const total = filtered.length;
|
|
const uptimePercent = total ? ((upCount / total) * 100).toFixed(3) : '0.000';
|
|
|
|
// Status is determined by newest entry (first in our sorted array)
|
|
const newestEntry = filtered.length > 0 ? filtered[0].entry : null;
|
|
const status = newestEntry && newestEntry.response_code === 200 ? 'Operational' : 'Issues';
|
|
const statusClass = newestEntry && newestEntry.response_code === 200 ? 'up' : 'down';
|
|
|
|
const service = document.createElement('div');
|
|
service.className = 'service';
|
|
service.innerHTML = `
|
|
<div class="service-header">
|
|
<div class="service-name">${domain}</div>
|
|
<div class="status ${statusClass}">${status} (${uptimePercent}%)</div>
|
|
</div>
|
|
<div class="bar"></div>
|
|
<div class="uptime">${total} day(s) monitored</div>
|
|
`;
|
|
|
|
const bar = service.querySelector('.bar');
|
|
let lastSelectedBlock = null;
|
|
|
|
// Display days in reverse chronological order (newest first, left to right)
|
|
filtered.forEach(({ day, entry, allEntries }) => {
|
|
const block = document.createElement('div');
|
|
block.className = `bar-block ${getStatusClass(entry.response_code)}`;
|
|
block.title = `${entry.date}: ${statusLabel(entry.response_code)}`;
|
|
block.dataset.day = day;
|
|
block.dataset.entries = JSON.stringify(allEntries);
|
|
block.addEventListener('click', (evt) => {
|
|
if (lastSelectedBlock) {
|
|
lastSelectedBlock.classList.remove('selected');
|
|
}
|
|
block.classList.add('selected');
|
|
lastSelectedBlock = block;
|
|
showPopup(evt, JSON.parse(block.dataset.entries));
|
|
});
|
|
bar.appendChild(block);
|
|
});
|
|
|
|
document.getElementById('container').appendChild(service);
|
|
}
|
|
|
|
function showPopup(evt, entriesForDay) {
|
|
const popup = document.getElementById('popup');
|
|
popup.innerHTML = entriesForDay.map(entry => {
|
|
return `
|
|
<div class="entry">
|
|
<strong>${entry.domainname}</strong><br/>
|
|
Date: ${entry.date}<br/>
|
|
Response Code: <span class="${getStatusClass(entry.response_code)}">${statusLabel(entry.response_code)}</span><br/>
|
|
Mode: ${entry.mode}
|
|
</div>
|
|
`;
|
|
}).join('');
|
|
|
|
popup.style.display = 'block';
|
|
popup.style.left = evt.pageX + 10 + 'px';
|
|
popup.style.top = evt.pageY + 10 + 'px';
|
|
}
|
|
|
|
document.addEventListener('click', e => {
|
|
if (!e.target.classList.contains('bar-block')) {
|
|
document.getElementById('popup').style.display = 'none';
|
|
const selectedBlocks = document.querySelectorAll('.bar-block.selected');
|
|
selectedBlocks.forEach(block => block.classList.remove('selected'));
|
|
}
|
|
});
|
|
|
|
async function init() {
|
|
for (const file of domainFiles) {
|
|
const data = await loadDomainData(file);
|
|
if (data.length) {
|
|
const domain = file.replace('.json','');
|
|
renderService(domain, data);
|
|
}
|
|
}
|
|
}
|
|
|
|
init();
|
|
</script>
|
|
</body>
|
|
</html> |