From 7c48f82a9c7e53f785be453b1641c065761b091b Mon Sep 17 00:00:00 2001 From: Harry Mellor <19981378+HMellor@users.noreply.github.com> Date: Sun, 23 Apr 2023 10:47:41 +0100 Subject: [PATCH] Resolve missed conflicts (#27) --- js/auctions.js | 11 -------- js/popups.js | 68 ++++++-------------------------------------------- 2 files changed, 8 insertions(+), 71 deletions(-) diff --git a/js/auctions.js b/js/auctions.js index 60c3f90e..13160f5b 100644 --- a/js/auctions.js +++ b/js/auctions.js @@ -230,11 +230,6 @@ function resetItem(i) { const itemId = `item${i.toString().padStart(5, "0")}` // Find all bids for item i let initialState = {} -<<<<<<< Updated upstream -======= - let amount = auctions[i].startingPrice - let title = document.getElementById(`auction-${i}`).dataset.title ->>>>>>> Stashed changes getDoc(docRef).then((doc) => { console.debug("resetItem() read from auction/items") let keys = Object.keys(doc.data()).sort() @@ -252,13 +247,7 @@ function resetAll() { let initialState = {} for (let i = 0; i < auctions.length; i++) { let field = `item${i.toString().padStart(5, "0")}_bid00000` -<<<<<<< Updated upstream initialState[field] = { amount: auctions[i].startingPrice } -======= - let amount = auctions[i].startingPrice - let title = document.getElementById(`auction-${i}`).dataset.title - initialState[field] = { amount: amount, title: title } ->>>>>>> Stashed changes } setDoc(doc(db, "auction", "items"), initialState) console.debug("resetAll() write to auction/items") diff --git a/js/popups.js b/js/popups.js index 0e217042..747e6c1a 100644 --- a/js/popups.js +++ b/js/popups.js @@ -66,22 +66,12 @@ const bidModalTitle = bidModal.querySelector("strong") const bidModalInput = bidModal.querySelector("input") const bidModalSubmit = bidModal.querySelector(".btn-primary") -<<<<<<< Updated upstream // Populate bidModal with the correct information before it is visible bidModal.addEventListener("show.bs.modal", (event) => { const button = event.relatedTarget - const card = button.closest(".card") || document.getElementById(bidModal.dataset.bsActiveAuction) - bidModalTitle.innerText = card.dataset.bsTitle - bidModal.dataset.bsActiveAuction = card.id -======= - // Populate bidModal with the correct information before it is visible - bidModal.addEventListener("show.bs.modal", (event) => { - const button = event.relatedTarget - const card = button.closest(".card") || document.getElementById(bidModal.dataset.activeAuction) - bidModalTitle.innerText = card.dataset.title - bidModal.dataset.activeAuction = card.id ->>>>>>> Stashed changes - + const card = button.closest(".card") || document.getElementById(bidModal.dataset.activeAuction) + bidModalTitle.innerText = card.dataset.title + bidModal.dataset.activeAuction = card.id }) // Focus the amount input once bidModal is visible @@ -106,12 +96,11 @@ bidModal.addEventListener("hidden.bs.modal", () => { bidModalSubmit.addEventListener("click", () => { placeBid() }) bidModalInput.addEventListener("keydown", (event) => { if (event.key == 'Enter') { placeBid() } }) -<<<<<<< Updated upstream // Function that handles bidding logic function placeBid() { let nowTime = new Date().getTime(); bidModalSubmit.setAttribute('disabled', '') // disable the button while we check - let i = bidModal.dataset.bsActiveAuction.match("[0-9]+"); + let i = bidModal.dataset.activeAuction.match("[0-9]+"); let feedback = bidModal.querySelector(".invalid-feedback") // Cleanse input let amountElement = bidModal.querySelector("input") @@ -122,29 +111,6 @@ function placeBid() { setTimeout(() => { bidModalObject.hide(); amountElement.classList.remove("is-invalid"); -======= - // Function that handles bidding logic - function placeBid() { - let nowTime = new Date().getTime(); - bidModalSubmit.setAttribute('disabled', '') // disable the button while we check - let i = bidModal.dataset.activeAuction.match("[0-9]+"); - let feedback = bidModal.querySelector(".invalid-feedback") - // Cleanse input - let amountElement = bidModal.querySelector("input") - let amount = Number(amountElement.value) - if (auctions[i].endTime - nowTime < 0) { - feedback.innerText = "The auction is already over!" - amountElement.classList.add("is-invalid") - setTimeout(() => { - bidModalObject.hide(); - amountElement.classList.remove("is-invalid"); - bidModalSubmit.removeAttribute('disabled', ''); - }, 1000); - } else if (amount == 0) { - // amount was empty - feedback.innerText = "Please specify an amount!" - amountElement.classList.add("is-invalid") ->>>>>>> Stashed changes bidModalSubmit.removeAttribute('disabled', ''); }, 1000); } else if (amount == 0) { @@ -190,24 +156,6 @@ function placeBid() { // -- Info modal -- const infoModal = document.getElementById('info-modal') -<<<<<<< Updated upstream -======= -if (infoModal) { - // Populate infoModal with the correct information before it is visible - infoModal.addEventListener("show.bs.modal", (event) => { - const infoModalTitle = infoModal.querySelector('.modal-title') - const infoModalDetail = infoModal.querySelector('.modal-body > p') - const infoModalSecondaryImage = infoModal.querySelector('.modal-body > img') - // Update variable content elements - const button = event.relatedTarget - const card = button.closest(".card") - infoModalTitle.innerText = card.dataset.title - infoModalDetail.innerText = card.dataset.detail - infoModalSecondaryImage.src = card.dataset.secondaryImage - // Add the auction ID to the bidModal, in case the user clicks "Submit bid" in infoModal - bidModal.dataset.activeAuction = card.id - }) ->>>>>>> Stashed changes // Populate infoModal with the correct information before it is visible infoModal.addEventListener("show.bs.modal", (event) => { @@ -217,11 +165,11 @@ infoModal.addEventListener("show.bs.modal", (event) => { // Update variable content elements const button = event.relatedTarget const card = button.closest(".card") - infoModalTitle.innerText = card.dataset.bsTitle - infoModalDetail.innerText = card.dataset.bsDetail - infoModalSecondaryImage.src = card.dataset.bsSecondaryImage + infoModalTitle.innerText = card.dataset.title + infoModalDetail.innerText = card.dataset.detail + infoModalSecondaryImage.src = card.dataset.secondaryImage // Add the auction ID to the bidModal, in case the user clicks "Submit bid" in infoModal - bidModal.dataset.bsActiveAuction = card.id + bidModal.dataset.activeAuction = card.id }) // Clear the auction specific information from bidModal when hiding infoModal