2024-11-04 15:42:18 +01:00
|
|
|
|
// animation speeds (ms)
|
|
|
|
|
const TYPING_SPEED = 180;
|
|
|
|
|
const ERASE_SPEED = 100;
|
|
|
|
|
const STATUS_UPDATE_INTERVAL = 60000; // 1min
|
|
|
|
|
const TIME_UPDATE_INTERVAL = 1; // 1ms (still terrible)
|
|
|
|
|
|
|
|
|
|
// status thresholds
|
|
|
|
|
const LATENCY_WARNING_THRESHOLD = 500000;
|
|
|
|
|
|
|
|
|
|
// mapping for group names because i'm lazy
|
|
|
|
|
const GROUP_NAMES = {
|
|
|
|
|
4: "INFRASTRUCTURE",
|
|
|
|
|
5: "SERVICES",
|
|
|
|
|
6: "API",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// fancy text typing animation for nav labels
|
|
|
|
|
// overcomplicated as fuck but whatever
|
2024-11-04 12:11:42 +01:00
|
|
|
|
function writeoutnavlabel(label) {
|
|
|
|
|
if (label.getAttribute("data-animating") === "true") return;
|
|
|
|
|
|
|
|
|
|
const text = label.getAttribute("data-text") || label.textContent;
|
|
|
|
|
label.setAttribute("data-text", text);
|
2024-11-03 23:17:56 +01:00
|
|
|
|
label.textContent = "";
|
|
|
|
|
label.style.opacity = "1";
|
2024-11-04 12:11:42 +01:00
|
|
|
|
label.setAttribute("data-animating", "true");
|
2024-11-03 23:17:56 +01:00
|
|
|
|
|
|
|
|
|
let i = 0;
|
2024-11-04 12:11:42 +01:00
|
|
|
|
let animationInterval = setInterval(() => {
|
2024-11-03 23:17:56 +01:00
|
|
|
|
if (i < text.length) {
|
|
|
|
|
label.textContent += text.charAt(i);
|
|
|
|
|
i++;
|
2024-11-04 12:11:42 +01:00
|
|
|
|
} else {
|
|
|
|
|
clearInterval(animationInterval);
|
|
|
|
|
label.setAttribute("data-animating", "false");
|
|
|
|
|
const icon = label.closest(".nav-icon");
|
|
|
|
|
if (icon) {
|
|
|
|
|
icon.isAnimating = false;
|
|
|
|
|
icon.hoverAnimationDone = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-11-04 15:42:18 +01:00
|
|
|
|
}, TYPING_SPEED);
|
2024-11-04 12:11:42 +01:00
|
|
|
|
|
|
|
|
|
label.setAttribute("data-animation-interval", animationInterval);
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-04 15:42:18 +01:00
|
|
|
|
// erase animation for nav labels
|
|
|
|
|
// also terrible but consistent with the above
|
2024-11-04 12:11:42 +01:00
|
|
|
|
function eraselabel(label) {
|
|
|
|
|
if (label.getAttribute("data-animating") === "true") {
|
|
|
|
|
const existingInterval = label.getAttribute("data-animation-interval");
|
2024-11-04 15:42:18 +01:00
|
|
|
|
if (existingInterval) clearInterval(existingInterval);
|
2024-11-03 23:17:56 +01:00
|
|
|
|
}
|
2024-11-04 12:11:42 +01:00
|
|
|
|
|
|
|
|
|
label.setAttribute("data-animating", "true");
|
|
|
|
|
|
|
|
|
|
let eraseInterval = setInterval(() => {
|
|
|
|
|
const currentText = label.textContent;
|
|
|
|
|
if (currentText.length > 0) {
|
|
|
|
|
label.textContent = currentText.slice(0, -1);
|
|
|
|
|
} else {
|
|
|
|
|
clearInterval(eraseInterval);
|
|
|
|
|
label.setAttribute("data-animating", "false");
|
|
|
|
|
label.style.opacity = "0";
|
|
|
|
|
}
|
2024-11-04 15:42:18 +01:00
|
|
|
|
}, ERASE_SPEED);
|
2024-11-04 12:11:42 +01:00
|
|
|
|
|
|
|
|
|
label.setAttribute("data-animation-interval", eraseInterval);
|
2024-11-03 23:17:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-04 15:42:18 +01:00
|
|
|
|
// time display updater
|
|
|
|
|
// still updates way too frequently but whatever
|
2024-11-03 23:17:56 +01:00
|
|
|
|
function updateTime() {
|
|
|
|
|
const now = new Date();
|
|
|
|
|
const timeString = now
|
|
|
|
|
.toLocaleString("en-US", {
|
|
|
|
|
month: "2-digit",
|
|
|
|
|
day: "2-digit",
|
|
|
|
|
year: "numeric",
|
|
|
|
|
hour: "2-digit",
|
|
|
|
|
minute: "2-digit",
|
|
|
|
|
second: "2-digit",
|
|
|
|
|
fractionalSecondDigits: 3,
|
|
|
|
|
hour12: true,
|
|
|
|
|
})
|
|
|
|
|
.toUpperCase();
|
|
|
|
|
document.getElementById("current-time").textContent = timeString;
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-04 15:42:18 +01:00
|
|
|
|
// status helper functions
|
2024-11-03 23:17:56 +01:00
|
|
|
|
function calculateAverageUptime(services) {
|
|
|
|
|
if (!services || services.length === 0) return 0;
|
|
|
|
|
const totalUptime = services.reduce(
|
|
|
|
|
(sum, service) => sum + service.online_24_hours,
|
|
|
|
|
0,
|
|
|
|
|
);
|
|
|
|
|
return (totalUptime / services.length).toFixed(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatLatency(latency) {
|
|
|
|
|
return (Math.round((latency / 1000) * 10) / 10).toFixed(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatUptime(uptime) {
|
|
|
|
|
return uptime.toFixed(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getStatusClass(service) {
|
|
|
|
|
if (!service.online) return "status-offline";
|
2024-11-04 15:42:18 +01:00
|
|
|
|
if (service.latency > LATENCY_WARNING_THRESHOLD) return "status-warning";
|
2024-11-03 23:17:56 +01:00
|
|
|
|
return "status-online";
|
|
|
|
|
}
|
2024-11-04 15:42:18 +01:00
|
|
|
|
|
2024-11-03 23:17:56 +01:00
|
|
|
|
function getGroupName(groupId) {
|
2024-11-04 15:42:18 +01:00
|
|
|
|
return GROUP_NAMES[groupId] || `GROUP ${groupId}`;
|
2024-11-03 23:17:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-04 15:42:18 +01:00
|
|
|
|
// creates the HTML for the status page
|
|
|
|
|
// groups services by their group_id
|
2024-11-03 23:17:56 +01:00
|
|
|
|
function createStatusHTML(services) {
|
|
|
|
|
const groups = services.reduce((acc, service) => {
|
|
|
|
|
const groupId = service.group_id;
|
|
|
|
|
if (!acc[groupId]) acc[groupId] = [];
|
|
|
|
|
acc[groupId].push(service);
|
|
|
|
|
return acc;
|
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
|
|
return Object.entries(groups)
|
|
|
|
|
.map(
|
|
|
|
|
([groupId, groupServices]) => `
|
2024-11-04 15:42:18 +01:00
|
|
|
|
<div class="status-group">
|
|
|
|
|
<div class="subsection-title">${getGroupName(parseInt(groupId))}</div>
|
|
|
|
|
${groupServices
|
|
|
|
|
.map(
|
|
|
|
|
(service) => `
|
|
|
|
|
<div class="status-item">
|
|
|
|
|
<div class="entry" data-service="${service.permalink}">
|
|
|
|
|
<span class="status-indicator ${getStatusClass(service)}"></span>
|
|
|
|
|
<span class="service-name">${service.name.toUpperCase()}</span>
|
|
|
|
|
<span class="service-status">${service.online ? "OPERATIONAL" : "OFFLINE"}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="status-details">
|
|
|
|
|
<div class="status-metric">Latency: ${formatLatency(service.latency)}ms</div>
|
|
|
|
|
<div class="status-metric">Uptime 24h: ${formatUptime(service.online_24_hours)}%</div>
|
|
|
|
|
<div class="status-metric">7-day Uptime: ${formatUptime(service.online_7_days)}%</div>
|
2024-11-03 23:17:56 +01:00
|
|
|
|
</div>
|
2024-11-04 15:42:18 +01:00
|
|
|
|
</div>
|
2024-11-03 23:17:56 +01:00
|
|
|
|
`,
|
2024-11-04 15:42:18 +01:00
|
|
|
|
)
|
|
|
|
|
.join("")}
|
|
|
|
|
</div>
|
|
|
|
|
`,
|
2024-11-03 23:17:56 +01:00
|
|
|
|
)
|
|
|
|
|
.join("");
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-04 15:42:18 +01:00
|
|
|
|
// main status update function
|
2024-11-03 23:17:56 +01:00
|
|
|
|
function updateStatus() {
|
|
|
|
|
const statusContainer = document.getElementById("status-container");
|
|
|
|
|
const averageUptimeElement = document.getElementById("average-uptime");
|
|
|
|
|
|
|
|
|
|
fetch("https://status.elia.network/api/services")
|
|
|
|
|
.then((response) => response.json())
|
|
|
|
|
.then((data) => {
|
|
|
|
|
statusContainer.innerHTML = createStatusHTML(data);
|
|
|
|
|
const averageUptime = calculateAverageUptime(data);
|
|
|
|
|
averageUptimeElement.textContent = `UPTIME ${averageUptime}%`;
|
|
|
|
|
|
|
|
|
|
document.querySelectorAll(".status-item").forEach((item) => {
|
|
|
|
|
item.addEventListener("click", function () {
|
|
|
|
|
const details = this.querySelector(".status-details");
|
|
|
|
|
details.classList.toggle("expanded");
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
statusContainer.innerHTML = `
|
2024-11-04 15:42:18 +01:00
|
|
|
|
<div class="error-message">
|
|
|
|
|
a(42, 90, 90, 0.3), 0 0 40px rgba(42, 90, 90, 0.2); } to { text-shadow: 0 0 40px rgba(42, 90, 90, 0.5), 0 0 80px rgba(42, 90, 90, 0.3); } }"
|
|
|
|
|
);
|
|
|
|
|
}); UNABLE TO FETCH STATUS DATA
|
|
|
|
|
<div style="font-size: 0.8em; margin-top: 5px;">
|
|
|
|
|
${error.message}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
`;
|
2024-11-03 23:17:56 +01:00
|
|
|
|
averageUptimeElement.textContent = "UPTIME ERROR";
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-04 15:42:18 +01:00
|
|
|
|
// project expansion handlers
|
|
|
|
|
document.querySelectorAll(".project-item").forEach((item) => {
|
|
|
|
|
item.addEventListener("click", function () {
|
|
|
|
|
const content = this.querySelector(".project-content");
|
|
|
|
|
const icon = this.querySelector(".expand-icon");
|
2024-11-03 23:17:56 +01:00
|
|
|
|
|
2024-11-04 15:42:18 +01:00
|
|
|
|
// close other expanded items
|
|
|
|
|
document.querySelectorAll(".project-item").forEach((otherItem) => {
|
|
|
|
|
if (otherItem !== item) {
|
|
|
|
|
otherItem
|
|
|
|
|
.querySelector(".project-content")
|
|
|
|
|
.classList.remove("expanded");
|
|
|
|
|
otherItem.querySelector(".expand-icon").textContent = "+";
|
|
|
|
|
}
|
2024-11-03 23:17:56 +01:00
|
|
|
|
});
|
2024-11-04 15:42:18 +01:00
|
|
|
|
|
|
|
|
|
content.classList.toggle("expanded");
|
|
|
|
|
icon.textContent = content.classList.contains("expanded") ? "−" : "+";
|
|
|
|
|
});
|
2024-11-03 23:17:56 +01:00
|
|
|
|
});
|
|
|
|
|
|
2024-11-04 15:42:18 +01:00
|
|
|
|
// smooth scroll navigation
|
2024-11-03 23:17:56 +01:00
|
|
|
|
document.querySelectorAll('a[href^="#"]').forEach((anchor) => {
|
|
|
|
|
anchor.addEventListener("click", function (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
document.querySelector(this.getAttribute("href")).scrollIntoView({
|
|
|
|
|
behavior: "smooth",
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2024-11-04 15:42:18 +01:00
|
|
|
|
// active nav icon updater
|
2024-11-03 23:17:56 +01:00
|
|
|
|
window.addEventListener("scroll", () => {
|
|
|
|
|
let current = "";
|
|
|
|
|
document.querySelectorAll("section").forEach((section) => {
|
|
|
|
|
const sectionTop = section.offsetTop;
|
|
|
|
|
if (scrollY >= sectionTop - 60) {
|
|
|
|
|
current = section.getAttribute("id");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
document.querySelectorAll(".nav-icon").forEach((icon) => {
|
2024-11-04 12:11:42 +01:00
|
|
|
|
const label = icon.querySelector(".nav-label");
|
|
|
|
|
const isCurrentSection = icon.getAttribute("href") === `#${current}`;
|
|
|
|
|
const wasActive = icon.classList.contains("active");
|
|
|
|
|
|
|
|
|
|
if (isCurrentSection) {
|
|
|
|
|
if (!wasActive) {
|
|
|
|
|
icon.classList.add("active");
|
|
|
|
|
if (icon.isAnimating) {
|
|
|
|
|
const text = label.getAttribute("data-text") || label.textContent;
|
|
|
|
|
label.textContent = text;
|
|
|
|
|
label.setAttribute("data-animating", "false");
|
|
|
|
|
clearInterval(
|
|
|
|
|
parseInt(label.getAttribute("data-animation-interval")),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
if (!icon.hoverAnimationDone) {
|
|
|
|
|
writeoutnavlabel(label);
|
|
|
|
|
}
|
|
|
|
|
icon.hoverAnimationDone = true;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (wasActive) {
|
|
|
|
|
eraselabel(label);
|
|
|
|
|
icon.classList.remove("active");
|
|
|
|
|
icon.hoverAnimationDone = false;
|
|
|
|
|
icon.isAnimating = false;
|
|
|
|
|
}
|
2024-11-03 23:17:56 +01:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2024-11-04 15:42:18 +01:00
|
|
|
|
// nav icon hover animations
|
2024-11-04 12:11:42 +01:00
|
|
|
|
document.querySelectorAll(".nav-icon").forEach((icon) => {
|
|
|
|
|
icon.hoverAnimationDone = false;
|
|
|
|
|
icon.isAnimating = false;
|
|
|
|
|
|
|
|
|
|
icon.addEventListener("mouseenter", () => {
|
|
|
|
|
if (!icon.classList.contains("active") && !icon.isAnimating) {
|
|
|
|
|
const label = icon.querySelector(".nav-label");
|
|
|
|
|
writeoutnavlabel(label);
|
|
|
|
|
icon.isAnimating = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
icon.addEventListener("mouseleave", () => {
|
|
|
|
|
if (!icon.classList.contains("active")) {
|
|
|
|
|
const label = icon.querySelector(".nav-label");
|
|
|
|
|
eraselabel(label);
|
|
|
|
|
icon.isAnimating = false;
|
|
|
|
|
icon.hoverAnimationDone = false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2024-11-04 15:42:18 +01:00
|
|
|
|
icon.addEventListener("click", () => {
|
2024-11-04 12:11:42 +01:00
|
|
|
|
const label = icon.querySelector(".nav-label");
|
|
|
|
|
if (icon.isAnimating) {
|
|
|
|
|
icon.hoverAnimationDone = true;
|
2024-11-04 15:42:18 +01:00
|
|
|
|
} else if (!icon.hoverAnimationDone) {
|
2024-11-04 12:11:42 +01:00
|
|
|
|
writeoutnavlabel(label);
|
|
|
|
|
icon.isAnimating = true;
|
|
|
|
|
icon.hoverAnimationDone = true;
|
|
|
|
|
}
|
|
|
|
|
label.style.opacity = "1";
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2024-11-04 15:42:18 +01:00
|
|
|
|
// initialization
|
2024-11-03 23:17:56 +01:00
|
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
2024-11-04 15:42:18 +01:00
|
|
|
|
// start time updates
|
|
|
|
|
updateTime();
|
|
|
|
|
setInterval(updateTime, TIME_UPDATE_INTERVAL);
|
|
|
|
|
|
|
|
|
|
// start status updates
|
|
|
|
|
updateStatus();
|
|
|
|
|
setInterval(updateStatus, STATUS_UPDATE_INTERVAL);
|
|
|
|
|
|
|
|
|
|
// init active nav icon
|
2024-11-04 12:11:42 +01:00
|
|
|
|
const activeNavIcon = document.querySelector(".nav-icon.active");
|
|
|
|
|
if (activeNavIcon) {
|
|
|
|
|
const label = activeNavIcon.querySelector(".nav-label");
|
|
|
|
|
if (label) writeoutnavlabel(label);
|
|
|
|
|
}
|
2024-11-04 15:42:18 +01:00
|
|
|
|
|
|
|
|
|
// fancy console log because why not
|
2024-11-03 23:17:56 +01:00
|
|
|
|
console.log(
|
|
|
|
|
"%cELIA.NETWORK",
|
2024-11-04 15:42:18 +01:00
|
|
|
|
"color: #2a5a5a; font-size: 24px; font-weight: bold; text-shadow: 2px 2px 4px rgba(42, 90, 90, 0.3);",
|
2024-11-03 23:17:56 +01:00
|
|
|
|
);
|
|
|
|
|
});
|