From 8747588222f1bd434af802262b1479ef5b606097 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Fri, 21 Jan 2022 01:23:50 +0100 Subject: actually loads thunderstore now --- src/app/browser.js | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) (limited to 'src/app/browser.js') diff --git a/src/app/browser.js b/src/app/browser.js index ae3e453..50cabfe 100644 --- a/src/app/browser.js +++ b/src/app/browser.js @@ -1,22 +1,39 @@ -function Browser(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") +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") -};Browser() + 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 + }) + } + } +}; Browser.toggle() +Browser.loadfront() document.body.addEventListener("keyup", (e) => { - if (e.key == "Escape") {Browser(false)} + if (e.key == "Escape") {Browser.toggle(false)} }) function BrowserEl(properties) { @@ -36,6 +53,8 @@ function BrowserEl(properties) {
${properties.title}
${properties.description} - by ${properties.author}
+ +
` -- cgit v1.2.3