Skip to content

Commit

Permalink
remvoed edit and add card for first and last card
Browse files Browse the repository at this point in the history
  • Loading branch information
al6862 committed Mar 2, 2024
1 parent 41b5587 commit a82c963
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion templates/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h3 id="next-question"> START </h3>
{% if isAuth %}

<button id="add-card-button" class="button2" >Add Card</button>
<button id="edit-card-button" class="button2">Edit</button>
<button id="edit-card-button" class="button2" style="display: none">Edit</button>

<form method="post" id="card-form" style="display: none">
<svg id="close-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" width="120px" height="120px">
Expand Down Expand Up @@ -51,18 +51,30 @@ <h3 id="next-question"> START </h3>
if (cardIndex > 0) {
cardIndex -= 1;
nextQuestion.textContent = cardList[cardIndex];
document.querySelector("#add-card-button").style.display="initial"
document.querySelector("#edit-card-button").style.display="initial"
} else {
nextQuestion.textContent = "START";
document.querySelector("#add-card-button").style.display="initial"
document.querySelector("#edit-card-button").style.display="none"
}
}

prev.addEventListener("click", prevCard);

// event listener for both card click and next button click
function nextCard() {
if (cardIndex == -1) {
document.querySelector("#add-card-button").style.display="initial"
document.querySelector("#edit-card-button").style.display="initial"
}
if (cardIndex < cardList.length-1) {
cardIndex += 1;
nextQuestion.textContent = cardList[cardIndex];
if (cardIndex == cardList.length-1) {
document.querySelector("#add-card-button").style.display="none"
document.querySelector("#edit-card-button").style.display="none"
}
}
}

Expand Down

0 comments on commit a82c963

Please sign in to comment.