165 lines
4.5 KiB
HTML
165 lines
4.5 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>DOMAIN STATUS LIST</title>
|
|
<link rel="icon" href="favicon.png" type="image/x-icon">
|
|
<style>
|
|
body { font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; margin: 24px; }
|
|
table { border-collapse: collapse; width: 100%; max-width: 1100px; }
|
|
th, td { border: 1px solid #ddd; padding: 10px; vertical-align: top; }
|
|
th { background: #f6f7f9; text-align: left; }
|
|
.up { background: #e9fbe9; }
|
|
.degraded { background: #fff4e5; }
|
|
.down { background: #ffecec; }
|
|
.muted { color: #555; font-size: 0.95em; }
|
|
code { white-space: pre-wrap; word-break: break-word; }
|
|
button { margin-bottom: 12px; padding: 8px 12px; cursor: pointer; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>DOMAIN STATUS LIST</h1>
|
|
<p class="muted" id="lastChecked">Not checked yet</p>
|
|
<button id="checkBtn">CHECK NOW</button>
|
|
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>DOMAIN</th>
|
|
<th>STATUS</th>
|
|
<th>DETAILS</th>
|
|
<th>URL</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="rows"></tbody>
|
|
</table>
|
|
|
|
<script>
|
|
// DOMAINS
|
|
const targets = [
|
|
"servzero.net",
|
|
"servtx.net",
|
|
];
|
|
|
|
function normalize(url) {
|
|
url = String(url).trim();
|
|
if (!/^https?:\/\//i.test(url)) url = "https://" + url;
|
|
return url;
|
|
}
|
|
|
|
const timeoutMs = 5000;
|
|
|
|
async function checkOne(url) {
|
|
const controller = new AbortController();
|
|
const t = setTimeout(() => controller.abort(), timeoutMs);
|
|
|
|
// HEAD, GET AS FALLBACK
|
|
for (const method of ["HEAD", "GET"]) {
|
|
try {
|
|
const res = await fetch(url, {
|
|
method,
|
|
mode: "no-cors", // CORS WORKAROUND
|
|
redirect: "follow",
|
|
signal: controller.signal
|
|
});
|
|
|
|
clearTimeout(t);
|
|
|
|
const status = res.status;
|
|
const ok = (status === 0) ? true : status < 400;
|
|
|
|
return {
|
|
reachable: true,
|
|
httpCode: (status === 0 ? null : status),
|
|
status: ok ? "UP" : "DEGRADED",
|
|
detail: (status === 0 ? (method + " SUCCESS") : ("HTTP " + status))
|
|
};
|
|
} catch (e) {
|
|
|
|
continue;
|
|
}
|
|
}
|
|
|
|
clearTimeout(t);
|
|
return {
|
|
reachable: false,
|
|
httpCode: null,
|
|
status: "DOWN",
|
|
detail: "REQUEST FAILED: NO RESPONSE"
|
|
};
|
|
}
|
|
|
|
function hostFromUrl(url) {
|
|
try {
|
|
return new URL(url).host;
|
|
} catch {
|
|
return url;
|
|
}
|
|
}
|
|
|
|
function clsFor(status) {
|
|
if (status === "UP") return "up";
|
|
if (status === "DEGRADED") return "degraded";
|
|
return "down";
|
|
}
|
|
|
|
function renderEmpty() {
|
|
const tbody = document.getElementById("rows");
|
|
tbody.innerHTML = "";
|
|
for (const raw of targets) {
|
|
const url = normalize(raw);
|
|
const host = hostFromUrl(url);
|
|
const tr = document.createElement("tr");
|
|
tr.innerHTML = `
|
|
<td>${host}</td>
|
|
<td class="${clsFor("DOWN")}"><strong id="s-${CSS.escape(host)}">CHECKING...</strong></td>
|
|
<td><code id="d-${CSS.escape(host)}">-</code></td>
|
|
<td><a href="${url}" target="_blank" rel="noreferrer">${url}</a></td>
|
|
`;
|
|
tbody.appendChild(tr);
|
|
}
|
|
}
|
|
|
|
async function checkAll() {
|
|
document.getElementById("lastChecked").textContent =
|
|
"CHECKING...";
|
|
|
|
renderEmpty();
|
|
|
|
const tbody = document.getElementById("rows");
|
|
const hostList = targets.map(normalize).map(hostFromUrl);
|
|
|
|
const jobs = targets.map(async raw => {
|
|
const url = normalize(raw);
|
|
const host = hostFromUrl(url);
|
|
const r = await checkOne(url);
|
|
return { host, url, ...r };
|
|
});
|
|
|
|
const results = await Promise.all(jobs);
|
|
|
|
for (const r of results) {
|
|
const host = r.host;
|
|
const sEl = document.getElementById("s-" + CSS.escape(host));
|
|
const dEl = document.getElementById("d-" + CSS.escape(host));
|
|
const tr = sEl.closest("tr");
|
|
|
|
tr.querySelector("td:nth-child(2)").className = clsFor(r.status);
|
|
sEl.textContent = r.status;
|
|
dEl.textContent = r.detail || "-";
|
|
}
|
|
|
|
document.getElementById("lastChecked").textContent =
|
|
"CHECKED " + new Date().toLocaleString();
|
|
}
|
|
|
|
document.getElementById("checkBtn").addEventListener("click", checkAll);
|
|
|
|
// AUTORUN
|
|
checkAll();
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|