Repository navigation
Expand file tree
/
Copy pathmap-packs.js
More file actions
51 lines (41 loc) · 1.56 KB
/
Copy pathmap-packs.js
File metadata and controls
51 lines (41 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
fetch("map-packs.csv")
.then(response => {
if (!response.ok) {
throw new Error("Could not load lists.csv");
}
return response.text();
})
.then(csv => {
const result = Papa.parse(csv, {
header: true,
skipEmptyLines: true
});
const lists = result.data;
const container = document.getElementById("lists-container");
container.innerHTML = "";
if (lists.length === 0) {
container.textContent = "No lists found.";
return;
}
lists.forEach(list => {
const card = document.createElement("div");
card.className = "list-card";
const title = document.createElement("h3");
title.textContent = list.name || "Unnamed List";
const description = document.createElement("p");
description.textContent = list.description || "No description.";
const creator = document.createElement("p");
creator.textContent = "Created by: " + (list.creator || "Unknown");
card.append(title, description, creator);
card.addEventListener("click", () => {
window.location.href =
`list-details.html?id=${encodeURIComponent(list.id.trim())}`;
});
container.appendChild(card);
});
})
.catch(error => {
console.error(error);
document.getElementById("lists-container").textContent =
"Could not load lists. Check the CSV file and console.";
});