-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscripts.js
More file actions
46 lines (39 loc) · 1.5 KB
/
scripts.js
File metadata and controls
46 lines (39 loc) · 1.5 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
let apps = [];
let categories = [];
fetch('apps/apps.json', { cache: "no-store" })
.then(res => res.json())
.then(data => {
apps = data;
// Trigger the rest of the script after fetching apps
const appList = document.getElementById("app-list");
apps.forEach((app, index) => {
fetch(`apps/${app}/info.json`, { cache: "no-store" })
.then(res => res.json())
.then(data => {
let download_links = "";
const card = document.createElement("div");
const download_os = Object.keys(data.download);
download_os.forEach(os => {
download_links += `<a href="${data.download[os]}" target="_blank">${os.toUpperCase()}</a> `;
});
card.className = "app-card";
card.innerHTML = `
<img src="${data.image}" alt="${data.name}" width="100" />
<h2>${data.name}</h2>
<p>${data.description}</p>
<p>Download: ${download_links}</p>
`;
// Determine row placement
const row = Math.floor((Math.sqrt(8 * index + 1) - 1) / 2);
const rowContainerId = `row-${row}`;
let rowContainer = document.getElementById(rowContainerId);
if (!rowContainer) {
rowContainer = document.createElement("div");
rowContainer.id = rowContainerId;
rowContainer.className = "app-row";
appList.appendChild(rowContainer);
}
rowContainer.appendChild(card);
});
});
});