Skip to content

Commit 9d0881e

Browse files
Add install button and functionality to mod dashboard for easier mod installation
1 parent 68ddc10 commit 9d0881e

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

ui/chrome/css/main.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,22 @@ body {
2424

2525
#terminal pre .error {
2626
color: red;
27+
}
28+
29+
.project {
30+
display: flex;
31+
flex-direction: column;
32+
align-items: center;
33+
margin-top: 20px;
34+
/** Add an outer border to the project section */
35+
border: 1px solid #ccc;
36+
}
37+
38+
.project h3 {
39+
margin-bottom: 10px;
40+
}
41+
42+
.project p {
43+
margin: 0;
44+
font-size: 14px;
2745
}

ui/chrome/js/moddashboard.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ document.getElementById("search").addEventListener("click", async function() {
1717
<p>Downloads: ${project.downloads}</p>
1818
<p>Follows: ${project.follows}</p>
1919
<a href="https://modrinth.com/${project.project_type}/${project.slug}" target="_blank">View on Modrinth</a>
20+
<button class="install" onclick="installMod('${project.slug}')">Install</button>
2021
`
2122
resultDiv.appendChild(projectDiv)
2223
}

ui/chrome/moddashboard/index.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
<!DOCTYPE html>
22
<html lang="en">
3+
34
<head>
45
<meta charset="UTF-8">
56
<meta name="viewport" content="width=device-width, initial-scale=1.0">
67
<title>Mod Dashboard</title>
78
<link rel="stylesheet" href="../css/main.css">
9+
<script>
10+
async function installMod(modId) {
11+
const modrinthUrl = "https://api.modrinth.com/v2/project/" + modId + "/version?loaders=[\"neoforge\"]&game_versions=[\"1.21.1\"]"
12+
const modrinthResponse = await fetch(modrinthUrl)
13+
const modrinthData = await modrinthResponse.json()
14+
let latestversion = modrinthData[0]
15+
const versionData = await fetch("https://api.modrinth.com/v2/version/" + latestversion.id)
16+
const versionJson = await versionData.json()
17+
console.log(versionJson)
18+
}
19+
</script>
820
</head>
21+
922
<body>
1023
<header>
1124
<h1>Mod Dashboard</h1>
@@ -16,8 +29,9 @@ <h1>Mod Dashboard</h1>
1629
<button id="search">Search</button>
1730
</div>
1831
<div id="result">
19-
32+
2033
</div>
2134
</main>
2235
<script src="../js/moddashboard.js" defer type="module"></script>
36+
2337
</html>

0 commit comments

Comments
 (0)