" +
"
" +
"
" +
"" + stationAssets[st.name].tip + "
" +
"" +
"" +
"" +
"" +
"" +
"
";
sDiv.appendChild(card);
st.am.forEach(function(acr, pIdx) { card.querySelector("#cont-" + sIdx + "-am").appendChild(createItem(acr, "station-" + sIdx + "-am", pIdx)); });
st.pm.forEach(function(acr, pIdx) { card.querySelector("#cont-" + sIdx + "-pm").appendChild(createItem(acr, "station-" + sIdx + "-pm", pIdx)); });
});
filterNames();
}
function createItem(acr, ctx, idx) {
var div = document.createElement("div");
div.className = "p-item"; div.dataset.ctx = ctx; div.dataset.idx = idx;
div.innerHTML = "" + (roster[acr] || acr) + " " + acr + "";
div.onclick = function() { handleTap(div, ctx, idx); };
if (selection && selection.ctx === ctx && selection.idx === idx) div.classList.add("selected");
return div;
}
function handleTap(el, ctx, idx) {
if (!selection) { select(el, ctx, idx); return; }
if (selection.ctx === ctx && selection.idx === idx) { clearSelection(); return; }
swap(selection.ctx, selection.idx, ctx, idx);
}
function select(el, ctx, idx) {
clearSelection(); selection = { ctx: ctx, idx: idx }; el.classList.add("selected");
document.getElementById("sel-banner").style.display = "flex";
document.querySelector(".sel-text").innerText = el.querySelector(".p-name").innerText + " Selected";
}
function clearSelection() {
selection = null; document.querySelectorAll(".selected").forEach(function(e) { e.classList.remove("selected"); });
document.getElementById("sel-banner").style.display = "none";
}
function swap(ctx1, idx1, ctx2, idx2) {
var arr1 = getArray(ctx1), arr2 = getArray(ctx2);
var temp = arr1[idx1]; arr1[idx1] = arr2[idx2]; arr2[idx2] = temp;
saveData(); clearSelection(); render();
}
function editSelected() {
if (!selection) return;
var arr = getArray(selection.ctx);
var newVal = prompt("Edit Name:", arr[selection.idx]);
if (newVal) { arr[selection.idx] = newVal; if (!roster[newVal]) roster[newVal] = newVal; saveData(); render(); clearSelection(); }
}
function getArray(ctx) {
var day = activeData[currentDayIdx];
if (ctx === "rover") return day.rovers;
var p = ctx.split("-"); return day.stations[p[1]][p[2]];
}
function toggleRef(id) { var el = document.getElementById(id); el.style.display = el.style.display === "block" ? "none" : "block"; }
function handleUpload(input, stationName) {
if (input.files[0]) {
var file = input.files[0];
if (file.size > 3 * 1024 * 1024) { alert("โ ๏ธ Image too large (Max 3MB)."); return; }
var r = new FileReader();
r.onload = function(e) {
try {
customImages[stationName] = e.target.result;
localStorage.setItem("hyroxImages", JSON.stringify(customImages));
var safeName = stationName.replace(/\s/g, "");
var imgEl = document.getElementById("img-" + safeName);
if(imgEl) imgEl.src = e.target.result;
render();
} catch (err) { alert("โ ๏ธ Browser storage full."); }
}
r.readAsDataURL(file);
}
}
function filterNames() {
var q = document.getElementById("search-bar").value.toUpperCase();
var items = document
๐
AM (08:00 - 13:00)
๐ PM (13:00 - 21:00)