Simplify access to deckJSON a bit
only needed a subsection
This commit is contained in:
parent
6e6f3189e1
commit
bb192cf535
@ -6,12 +6,12 @@ interact.dynamicDrop(true);
|
|||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
let xhr = new XMLHttpRequest();
|
let xhr = new XMLHttpRequest();
|
||||||
xhr.addEventListener("load", () => {
|
xhr.addEventListener("load", () => {
|
||||||
deckJSON = JSON.parse(xhr.responseText);
|
deckJSON = JSON.parse(xhr.responseText).ObjectStates[0];
|
||||||
piles.deck = deckJSON.ObjectStates[0].DeckIDs.map(c => c - 100);
|
piles.deck = deckJSON.DeckIDs.map(c => c - 100);
|
||||||
cardCount = piles.deck.length;
|
cardCount = piles.deck.length;
|
||||||
shuffle(piles.deck);
|
shuffle(piles.deck);
|
||||||
deckWidth = deckJSON.ObjectStates[0].CustomDeck["1"].NumWidth;
|
deckWidth = deckJSON.CustomDeck["1"].NumWidth;
|
||||||
deckHeight = deckJSON.ObjectStates[0].CustomDeck["1"].NumHeight;
|
deckHeight = deckJSON.CustomDeck["1"].NumHeight;
|
||||||
console.log(deckName);
|
console.log(deckName);
|
||||||
});
|
});
|
||||||
deckName = document.querySelector('#card-container').getAttribute("data-deckName");
|
deckName = document.querySelector('#card-container').getAttribute("data-deckName");
|
||||||
@ -185,7 +185,7 @@ interact('.card-pile')
|
|||||||
Array.from(cardList.children).forEach(card => {
|
Array.from(cardList.children).forEach(card => {
|
||||||
let input = event.target.value;
|
let input = event.target.value;
|
||||||
let cardNum = parseInt(card.getAttribute('data-num'));
|
let cardNum = parseInt(card.getAttribute('data-num'));
|
||||||
let cardData = deckJSON.ObjectStates[0].ContainedObjects.find(c => c.CardID === (cardNum + 100));
|
let cardData = deckJSON.ContainedObjects.find(c => c.CardID === (cardNum + 100));
|
||||||
card.style.display =
|
card.style.display =
|
||||||
(cardData.Nickname.toLowerCase().includes(input.toLowerCase()) ||
|
(cardData.Nickname.toLowerCase().includes(input.toLowerCase()) ||
|
||||||
cardData.Description.toLowerCase().includes(input.toLowerCase())) ?
|
cardData.Description.toLowerCase().includes(input.toLowerCase())) ?
|
||||||
|
Loading…
Reference in New Issue
Block a user