Skip to content

Commit

Permalink
Resolve missed conflicts (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
hmellor authored Apr 23, 2023
1 parent efafa67 commit 7c48f82
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 71 deletions.
11 changes: 0 additions & 11 deletions js/auctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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")
Expand Down
68 changes: 8 additions & 60 deletions js/popups.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand All @@ -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) {
Expand Down Expand Up @@ -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) => {
Expand All @@ -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
Expand Down

0 comments on commit 7c48f82

Please sign in to comment.