getting modpack ids

This commit is contained in:
Cuptain 2024-06-23 14:12:41 +10:00
parent 4ffaf29645
commit 1fe3be506c
3 changed files with 24 additions and 17 deletions

View File

@ -8,11 +8,9 @@
<script type="module" src="/main.js" defer></script> <script type="module" src="/main.js" defer></script>
</head> </head>
<style>
body {
background-image: src="assets/CityBase.png";
}
</style>
<body onload="load();"> <body onload="load();">
@ -27,7 +25,9 @@
<select name="modSelect" id="Modpacks"> <select name="modSelect" id="Modpacks">
</select> </select>
<button id="idsButton" type="button">Show Id</button>
<p type="text" id="showTheId"></p>
</div> </div>
</body> </body>
</html> </html>

View File

@ -10,17 +10,13 @@ async function greet() {
} }
window.addEventListener("DOMContentLoaded", () => { window.addEventListener("DOMContentLoaded", () => {
greetInputEl = document.querySelector("#greet-input");
greetMsgEl = document.querySelector("#greet-msg"); document.getElementById("idsButton").addEventListener("click", viewIds);
document.querySelector("#greet-form").addEventListener("submit", (e) => { console.log("testing");
e.preventDefault();
greet();
});
}); });
function packSelect() { function packSelect() {
document.getElementById("myDropdown").classList.toggle("show"); document.getElementById("myDropdown").classList.toggle("show");
} }
function load() { function load() {
@ -38,16 +34,23 @@ window.onload = async function() {
} }
function addModpacks(modpacks) { function addModpacks(modpacks) {
var dropdown = document.getElementById("Modpacks"); var dropdown = document.getElementById("Modpacks");
modpacks.sort(); modpacks.sort();
modpacks.reverse(); modpacks.reverse();
for (let i = 0; i < modpacks.length; i++){ for (let i = 0; i < modpacks.length; i++){
var opt = document.createElement("option"); var opt = document.createElement("option");
opt.text = modpacks[i]; opt.text = modpacks[i].name;
opt.value = 'somethings value'; opt.value = modpacks[i].id;
dropdown.options.add(opt); dropdown.options.add(opt);
} }
} }
function viewIds() {
var packId = document.getElementById("Modpacks");
var selectedId = packId.value;
document.getElementById("showTheId").textContent = selectedId;
console.log(selectedId);
}
//window.onclick = function(event) { //window.onclick = function(event) {

View File

@ -68,10 +68,14 @@ button {
font-size: 1em; font-size: 1em;
font-weight: 500; font-weight: 500;
font-family: inherit; font-family: inherit;
color: #0f0f0f; color: #4df3ff;
background-color: #ffffff; background-color: #ffffff;
transition: border-color 0.25s; transition: border-color 0.25s;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2); box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
width: 300px;
display: flex;
justify-content: center;
align-self: center;
} }
button { button {
@ -141,7 +145,7 @@ button {
z-index: 1; z-index: 1;
} }
.dropdown-content a { #text {
color: black; color: black;
padding: 12px 16px; padding: 12px 16px;
text-decoration: none; text-decoration: none;