Skip to content

Commit

Permalink
Merge pull request #54 from software-students-spring2024/card-bugs
Browse files Browse the repository at this point in the history
Minor bug fixes for cards
  • Loading branch information
al6862 authored Feb 28, 2024
2 parents 6a94717 + 07399ab commit f3bec41
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
6 changes: 2 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ def allDecks(username):
@app.route("/<username>/<deckTitle>")
def displayDeck(username, deckTitle):
if username == "guest":

# get the list of cards for the deck
currentDeck = db.decks.find_one({"title": deckTitle})
cardList = currentDeck['cards']

# TODO: shuffle cards

# shuffle deck
random.shuffle(cardList)
return render_template('card.html', deckTitle=deckTitle, username=username, cardList=cardList)
return "temp"

Expand Down
14 changes: 7 additions & 7 deletions templates/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
<h2> {{ deckTitle }}</h2>
</div>

<div class="card">
<div id="card" class="card">
<h3 id="next-question"> START </h3>
</div>


<a href="{{ url_for('addCard', username='guest', deckTitle=deckTitle) }}" style="text-decoration:none">
<button class="button2" >Add Card</button>
</a>
Expand All @@ -20,16 +19,17 @@ <h3 id="next-question"> START </h3>

<script>
const nextQuestion = document.querySelector("#next-question");
const card = document.querySelector("#card");
var cardIndex = 0;

var questions = '{{ cardList }}'
questions = questions.replaceAll("&#39;","\"")
var cardList = Array.from(JSON.parse(questions))

nextQuestion.addEventListener("click", function() {
cardList.push("END OF DECK")
card.addEventListener("click", function() {
nextQuestion.textContent = cardList[cardIndex];
cardIndex += 1;
console.log(cardIndex)
if (cardIndex < cardList.length-1) {
cardIndex += 1;
}
});
</script>

Expand Down

0 comments on commit f3bec41

Please sign in to comment.