From b0782ed74ed00206614ee626378f5cfdc29129e7 Mon Sep 17 00:00:00 2001 From: Jacob Levine Date: Thu, 7 Mar 2019 19:47:35 -0600 Subject: [PATCH] test bugfix --- website/public/team/scripts.js | 44 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/website/public/team/scripts.js b/website/public/team/scripts.js index 34a3bade..fae84a65 100644 --- a/website/public/team/scripts.js +++ b/website/public/team/scripts.js @@ -98,36 +98,36 @@ function checkKeyMatch(dt,tn,key){ } function reqjt(tn,tc){ user=firebase.auth().currentUser; - dict={} firebase.firestore().collection('teamData').doc('joinCodes').get().then(function(doc){ if (doc.exists) { dict=doc.data(); + if (checkKeyMatch(dict,tn,tc)){ + push={}; + push[tn]='scout'; + firebase.firestore().collection("UserAssociations").doc(user.uid).set(push, { + merge: true + }).then(function(doc) { + if (doc.exists) { + list = doc.data() + teamNums = Object.keys(list) + document.getElementById('teammem').innerHTML = "" + for (var i = 0; i < teamNums.length; i++) { + document.getElementById('teammem').innerHTML += "" + teamNums[i] + "" + list[teamNums[i]] + "" + } + } else { + document.getElementById('teammem').innerHTML = "You are not part of any teams" + } + }) + }else{ + alert("You don't have a correct join key. Please check it and try again.") + console.log(dict) + } } else { // doc.data() will be undefined in this case console.log("No such document!"); } }); - if (checkKeyMatch(dict,tn,tc)){ - push={}; - push[tn]='scout'; - firebase.firestore().collection("UserAssociations").doc(user.uid).set(push, { - merge: true - }).then(function(doc) { - if (doc.exists) { - list = doc.data() - teamNums = Object.keys(list) - document.getElementById('teammem').innerHTML = "" - for (var i = 0; i < teamNums.length; i++) { - document.getElementById('teammem').innerHTML += "" + teamNums[i] + "" + list[teamNums[i]] + "" - } - } else { - document.getElementById('teammem').innerHTML = "You are not part of any teams" - } - }) - }else{ - alert("You don't have a correct join key. Please check it and try again.") - console.log(dict) - } + } function signout() {