diff --git a/app.py b/app.py index c0e0793..6f3e735 100644 --- a/app.py +++ b/app.py @@ -3,6 +3,7 @@ from authentication import * from db import * import random +import json app = Flask(__name__) login_manager.init_app(app) @@ -56,7 +57,7 @@ def displayDeck(username, deckTitle): cardList = currentDeck['cards'] # shuffle deck random.shuffle(cardList) - return render_template('card.html', deckTitle=deckTitle, username=username, cardList=cardList, isAuth=False) + return render_template('card.html', deckTitle=deckTitle, username=username, cardList=json.dumps(cardList), isAuth=False) else: # authenticate user if (not current_user.is_authenticated or current_user.id != username): @@ -72,7 +73,7 @@ def displayDeck(username, deckTitle): cardList = currentDeck['cards'] # shuffle deck random.shuffle(cardList) - return render_template('card.html', deckTitle=deckTitle, username=username, cardList=cardList, isAuth=True) + return render_template('card.html', deckTitle=deckTitle, username=username, cardList=json.dumps(cardList), isAuth=True) # TODO: change createDeck to addDeck for naming consistency @app.route("//create", methods=["POST"]) diff --git a/templates/card.html b/templates/card.html index 43ecf9c..b867925 100644 --- a/templates/card.html +++ b/templates/card.html @@ -50,7 +50,8 @@

START

var cardIndex = -1; var questions = '{{ cardList }}' - questions = questions.replaceAll("'","\"") + questions = questions.replaceAll("'","'") + questions = questions.replaceAll(""","\"") questions = questions.replaceAll("\r","") questions = questions.replaceAll("\n","")