|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <title>Mutator Debug</title> |
| 6 | +</head> |
| 7 | +<body> |
| 8 | + <h1>Mutator Debug</h1> |
| 9 | + |
| 10 | + <div id="status">Loading…</div> |
| 11 | + |
| 12 | + <h2>Current</h2> |
| 13 | + <table id="currentTable" border="1"> |
| 14 | + <thead> |
| 15 | + <tr><th>Level ID</th><th>Level Name</th><th>Mutator ID</th><th>Mutator Name</th></tr> |
| 16 | + </thead> |
| 17 | + <tbody></tbody> |
| 18 | + </table> |
| 19 | + |
| 20 | + <h2>Last 24h (12 buckets)</h2> |
| 21 | + <table id="pastTable" border="1"> |
| 22 | + <thead> |
| 23 | + <tr><th>#</th><th>Level ID</th><th>Level Name</th><th>Mutator ID</th><th>Mutator Name</th></tr> |
| 24 | + </thead> |
| 25 | + <tbody></tbody> |
| 26 | + </table> |
| 27 | + |
| 28 | + <h2>Next 30d (360 buckets)</h2> |
| 29 | + <table id="futureTable" border="1"> |
| 30 | + <thead> |
| 31 | + <tr><th>#</th><th>Level ID</th><th>Level Name</th><th>Mutator ID</th><th>Mutator Name</th></tr> |
| 32 | + </thead> |
| 33 | + <tbody></tbody> |
| 34 | + </table> |
| 35 | + |
| 36 | + <script> |
| 37 | + // ----- config ----- |
| 38 | + const API_ENDPOINT = "https://your-netlify-site.netlify.app/.netlify/functions/current-mutator"; |
| 39 | + |
| 40 | + // Lookup tables (must match your backend order) |
| 41 | + const LEVELS = [ |
| 42 | + "Skidrow", // 0 |
| 43 | + "Quarantine Center", // 1 |
| 44 | + "Union Tower", // 2 |
| 45 | + "Chinatown", // 3 |
| 46 | + "The Relay", // 4 |
| 47 | + "Boulevard", // 5 |
| 48 | + "Downtown", // 6 |
| 49 | + "Subway", // 7 |
| 50 | + "Hospital" // 8 |
| 51 | + ]; |
| 52 | + |
| 53 | + const MUTATORS = [ |
| 54 | + "SpeedRunner", // 0 |
| 55 | + "GunSlinger", // 1 |
| 56 | + "SnappingTurtle",// 2 |
| 57 | + "CrowdControl", // 3 |
| 58 | + "SnowPlow" // 4 |
| 59 | + ]; |
| 60 | + |
| 61 | + // ----- render helpers ----- |
| 62 | + function addRow(tbody, cells) { |
| 63 | + const tr = document.createElement("tr"); |
| 64 | + cells.forEach(text => { |
| 65 | + const td = document.createElement("td"); |
| 66 | + td.textContent = text; |
| 67 | + tr.appendChild(td); |
| 68 | + }); |
| 69 | + tbody.appendChild(tr); |
| 70 | + } |
| 71 | + |
| 72 | + function renderCurrent(cPair) { |
| 73 | + const [lId, mId] = cPair; |
| 74 | + const tbody = document.querySelector("#currentTable tbody"); |
| 75 | + tbody.innerHTML = ""; |
| 76 | + addRow(tbody, [lId, LEVELS[lId], mId, MUTATORS[mId]]); |
| 77 | + } |
| 78 | + |
| 79 | + function renderList(tableSelector, pairs) { |
| 80 | + const tbody = document.querySelector(tableSelector + " tbody"); |
| 81 | + tbody.innerHTML = ""; |
| 82 | + pairs.forEach((pair, i) => { |
| 83 | + const [lId, mId] = pair; |
| 84 | + addRow(tbody, [i, lId, LEVELS[lId], mId, MUTATORS[mId]]); |
| 85 | + }); |
| 86 | + } |
| 87 | + |
| 88 | + // ----- main ----- |
| 89 | + (async function init() { |
| 90 | + try { |
| 91 | + const res = await fetch(API_ENDPOINT); |
| 92 | + const data = await res.json(); // { t, c, p, f } |
| 93 | + |
| 94 | + document.getElementById("status").textContent = "Loaded at: " + data.t; |
| 95 | + |
| 96 | + renderCurrent(data.c); |
| 97 | + renderList("#pastTable", data.p); |
| 98 | + renderList("#futureTable", data.f); |
| 99 | + } catch (e) { |
| 100 | + document.getElementById("status").textContent = "Failed to load: " + e; |
| 101 | + } |
| 102 | + })(); |
| 103 | + </script> |
| 104 | +</body> |
| 105 | +</html> |
0 commit comments