Skip to content
Snippets Groups Projects
Commit b90269f3 authored by Mamadu-lamarana Bah's avatar Mamadu-lamarana Bah :speech_balloon:
Browse files

gestion d'envoies de message entre bidder et auctioneer

parent 1b9ca5c9
No related branches found
No related tags found
No related merge requests found
......@@ -18,9 +18,9 @@
<div class="price-options">
<p>Enchères possibles :</p>
<button class="price-button" onclick="selectPrice('20€')">20€</button>
<button class="price-button" onclick="selectPrice('50€')">50€</button>
<button class="price-button" onclick="selectPrice('100€')">100€</button>
<button class="price-button">20€</button>
<button class="price-button">50€</button>
<button class="price-button">100€</button>
</div>
</body>
......
......@@ -8,7 +8,7 @@ const buttonStart = document.getElementById("start");
const buttonSale = document.getElementById("sale");
const prixActuel = document.getElementById("prixactuel");
prixActuel.textContent = inputValue.value;
prixActuel.textContent = inputValue.value+"";
function emptyInput() {
if(inputName.value.trim() === "") {
......@@ -22,12 +22,26 @@ function emptyInput() {
inputName.addEventListener("input", emptyInput);
buttonStart.addEventListener("click", startEnchere);
const ident = document.getElementById("ident-auc");
function startEnchere() {
prixActuel.textContent = inputValue.value+"";
buttonSale.disabled = false;
const ident = document.getElementById("ident-auc");
ident.textContent = `Debut de l'enchère pour ${inputName.value} à ${inputValue.value}`;
ident.textContent = `Debut de l'enchère pour ${inputName.value} à ${inputValue.value}€`;
socket.emit("infos", inputName.value, inputValue.value);
socket.on("prixActuel", (nouveauPrix, sock) => updatePrix(nouveauPrix, sock));
waitForNewEnchere();
}
function updatePrix(nouveauPrix, sock) {
prixActuel.textContent = nouveauPrix+"";
ident.textContent = `Nouvelle enchère réçu de ${sock}`;
}
function waitForNewEnchere() {
inputName.disabled = true;
inputValue.disabled = true;
buttonStart.disabled = true;
}
......@@ -6,20 +6,30 @@ const ident = document.getElementById("ident-bid");
const description = document.getElementsByClassName("description");
const prix = document.getElementsByClassName("prix");
let prixActuel = 0;
socket.on("infos", (name, value) => {
ident.textContent = `Une nouvelle enchère commence`;
console.log(name, value);
description.textContent = name;
enchereBegin(name, value);
});
function enchereBegin(name, value) {
description[0].textContent = name;
prix[0].textContent = value;
prix[0].textContent = value+"";
prixActuel += parseInt(prix[0].textContent);
}
function selectPrice(price) {
console.log(price);
const buttons = document.querySelectorAll("button");
for(const button of buttons) {
button.addEventListener("click", selectPrice);
}
function selectPrice(event) {
const selectedPrix = parseInt(event.target.textContent);
prixActuel += selectedPrix;
prix[0].textContent = prixActuel;
socket.emit("prixActuel", prixActuel);
socket.on("prixActuel", (nouveauPrix) => {prix[0].textContent = nouveauPrix});
ident.textContent = `Vous avez fait une enchère de +${selectedPrix}€`;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment