From 1d04b0f64ca0793345122f00f8f816b9cddf90dc Mon Sep 17 00:00:00 2001 From: Caleb Fultz Date: Wed, 21 Aug 2024 08:40:48 -0400 Subject: [PATCH] Corrected issue with the autofilling of ID's --- app.js | 34 +++++++++++++++++++++++++++++++--- index.html | 50 +++++++++++++++++++++++++++++++------------------- offline.html | 6 ++++++ styles.css | 9 +++++++++ 4 files changed, 77 insertions(+), 22 deletions(-) diff --git a/app.js b/app.js index a2bd126..45c8ca7 100644 --- a/app.js +++ b/app.js @@ -90,18 +90,46 @@ async function fetchCardDetails(cardName, setCode) { async function addCard() { const cardName = document.getElementById('card-name').value; - const setCode = document.getElementById('set-code').value; + const setCodeInput = document.getElementById('set-code'); + const cardIdInput = document.getElementById('card-id'); // Fetch card details using the card name and set code + let setCode = setCodeInput.value; + let cardId = cardIdInput.value; + + // Always fetch card details const cardDetails = await fetchCardDetails(cardName, setCode); if (cardDetails) { - updateCardDetails(cardDetails); + // If set code or card ID is not filled, auto-fill them + if (!setCode) { + setCode = cardDetails.set; + setCodeInput.value = setCode; + } + if (!cardId) { + cardId = cardDetails.card_id; + cardIdInput.value = cardId; + } + + // Update card details with either user input or fetched data + updateCardDetails({ + name: cardName, + set: setCode, + card_id: cardId, + mana_cost: cardDetails.mana_cost, + power: cardDetails.power, + toughness: cardDetails.toughness, + type: cardDetails.type, + rarity: cardDetails.rarity, + price: cardDetails.price, + imageUrl: cardDetails.imageUrl + }); } else { - alert("Card not found with the given name and set code."); + alert("Card not found with the given name."); } } + function updateCardDetails(printing) { document.getElementById('set-code').value = printing.set; document.getElementById('card-id').value = printing.card_id; diff --git a/index.html b/index.html index b2c3e5c..d870f7b 100644 --- a/index.html +++ b/index.html @@ -30,34 +30,45 @@

MTG Card CSV Generator

-
-
- - -
+ +
+ + +
-
- - + +
+ + +
-
- - + +
+ + +
-
- - + +
+ + +
-
- - + +
- + + - + + +
@@ -75,5 +86,6 @@ navigator.serviceWorker.register('sw.js') } + diff --git a/offline.html b/offline.html index b31cad6..e0db80a 100644 --- a/offline.html +++ b/offline.html @@ -8,6 +8,8 @@ + +
@@ -25,5 +27,9 @@ This app is not affiliated with Wizards of the Coast or Hasbro. All rights and trademarks are owned by their respective owners.

+ + diff --git a/styles.css b/styles.css index 33074b2..aa0d8aa 100644 --- a/styles.css +++ b/styles.css @@ -6,6 +6,14 @@ --button-hover: #005fa3; } +.material-theme { + --background-color: #ffffff; + --text-color: #000000; + --card-background: #f8f8f8; + --button-background: #6200ee; + --button-hover: #3700b3; +} + .theme-white { --background-color: #f9f8f6; --text-color: #1e1e1e; @@ -86,6 +94,7 @@ --button-background: #2e7d32; --button-hover: #388e3c; } + }