blob: eb18fe57cb670b192a23d4b954ec072be59ab372 (
plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
var Browser = {
toggle: (state) => {
if (state) {
overlay.classList.add("shown")
browser.classList.add("shown")
return
} else if (! state) {
if (state != undefined) {
overlay.classList.remove("shown")
browser.classList.remove("shown")
return
}
}
overlay.classList.toggle("shown")
browser.classList.toggle("shown")
},
loadfront: async () => {
let packages = await (await fetch("https://northstar.thunderstore.io/api/v1/package/")).json();
for (let i in packages) {
let pkg = {...packages[i], ...packages[i].versions[0]};
new BrowserEl({
title: pkg.name,
image: pkg.icon,
author: pkg.owner,
description: pkg.description
})
}
},
loading: () => {
if (! browserEntries.querySelector(".loading")) {
browserEntries.innerHTML = `<div class="loading">${lang("gui.browser.loading")}</div>`;
}
}
}; Browser.toggle()
Browser.loadfront()
document.body.addEventListener("keyup", (e) => {
if (e.key == "Escape") {Browser.toggle(false)}
})
function BrowserEl(properties) {
properties = {
title: "No name",
image: "icons/no-image.png",
author: "Unnamed Pilot",
description: "No description",
...properties
}
if (browserEntries.querySelector(".loading")) {
browserEntries.innerHTML = "";
}
browserEntries.innerHTML += `
<div class="el">
<div class="image">
<img src="${properties.image}">
</div>
<div class="text">
<div class="title">${properties.title}</div>
<div class="description">${properties.description} - ${lang("gui.browser.madeby")} ${properties.author}</div>
<button>Install</button>
<button>Info</button>
</div>
</div>
`
}
|