Skip to content

Commit

Permalink
made winner selection work with detailed vev
Browse files Browse the repository at this point in the history
  • Loading branch information
erikpersson0884 committed Dec 4, 2023
1 parent 6e5177d commit 1c250e5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
28 changes: 18 additions & 10 deletions public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export function getCurrentTime() {


function updateWinner(vev, winner) {
console.log("updateWinner");
// Send a POST request to the server
const eventData = {
vev: vev,
Expand Down Expand Up @@ -284,8 +285,10 @@ function createAPastVev(vev){
vevElement.appendChild(DetailedVevInfoDiv);

// Add an event listener to the vevElement
vevElement.addEventListener("click", function() {
vevElement.addEventListener("click", function(event) {
toggleDetailedVev(vevElement, DetailedVevInfoDiv);
event.stopPropagation();

});
return vevElement;
};
Expand All @@ -297,31 +300,36 @@ function createBasicVevInfo(vev){
basicVevInfoDiv.classList.add("VevsLiDiv");

// Create three p tags and set their text content
const div1 = document.createElement("div");
div1.classList.add("DisplayVevsUser")

const p1 = document.createElement("p");
p1.classList.add("DisplayVevsUser")
p1.textContent = vev.user;
p1.addEventListener("click", function() { // Eventlistener for updatig the winner
if (vev = currentDetailedVev){
updateWinner(vev, vev.user);
}
updateWinner(vev, vev.user);
});
div1.appendChild(p1);

const div2 = document.createElement("div");
div2.classList.add("DisplayVevsOpponent")

const p2 = document.createElement("p");
p2.classList.add("DisplayVevsOpponent")
p2.textContent = vev.opponent;

p2.addEventListener("click", function() { // Eventlistener for updatig the winner
if (vev = currentDetailedVev){
updateWinner(vev, vev.opponent);
}
console.log("clicked");
updateWinner(vev, vev.opponent);
});
div2.appendChild(p2);

const p3 = document.createElement("p");
p3.classList.add("DisplayVevsTime")
p3.textContent = vev.time;

// Append the p tags to the vevElement
basicVevInfoDiv.appendChild(p1);
basicVevInfoDiv.appendChild(p2);
basicVevInfoDiv.appendChild(div1);
basicVevInfoDiv.appendChild(div2);
basicVevInfoDiv.appendChild(p3);

// Code for showing the winner, not working currently as the winner cannot be changed in detail view
Expand Down
14 changes: 8 additions & 6 deletions public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,16 @@ body {
justify-content: space-between;
}



.sidebar > div {
border-bottom: 5px #fff solid;
}

.DisplayVevsUser p {
width: min-content;
}

.sidebar .DisplayVevsUser {
width: 40%;
}
Expand Down Expand Up @@ -237,6 +243,8 @@ h2 {
/* Code for footer */

footer {
font-size: 1.1rem;

position: absolute;
bottom: 0;
left: 0;
Expand Down Expand Up @@ -558,9 +566,3 @@ body {
.DetailedVevInfo button {
display: none;
}



.activeDetailedVev {
display: none;
}

0 comments on commit 1c250e5

Please sign in to comment.