mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2024-12-28 10:09:09 +00:00
now you can leave teams
This commit is contained in:
parent
c5dc49f442
commit
77231d00cc
@ -25,7 +25,7 @@ var uiConfig = {
|
|||||||
// function.
|
// function.
|
||||||
// Terms of service url/callback.
|
// Terms of service url/callback.
|
||||||
tosUrl: function() {
|
tosUrl: function() {
|
||||||
alert("this is a test app. don't use it");
|
alert("this is a test app. don't use it. If you are a 2022 captian, you agree to name Jacob Levine as your successor.");
|
||||||
},
|
},
|
||||||
// Privacy policy url/callback.
|
// Privacy policy url/callback.
|
||||||
privacyPolicyUrl: function() {
|
privacyPolicyUrl: function() {
|
||||||
|
@ -61,7 +61,9 @@ window.onload = function() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
firebase.firestore.settings({timestampsInSnapshots: true})
|
firebase.firestore.settings({
|
||||||
|
timestampsInSnapshots: true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function cnt(tn) {
|
function cnt(tn) {
|
||||||
@ -78,7 +80,7 @@ function cnt(tn) {
|
|||||||
teamNums = Object.keys(list)
|
teamNums = Object.keys(list)
|
||||||
document.getElementById('teammem').innerHTML = ""
|
document.getElementById('teammem').innerHTML = ""
|
||||||
for (var i = 0; i < teamNums.length; i++) {
|
for (var i = 0; i < teamNums.length; i++) {
|
||||||
document.getElementById('teammem').innerHTML += "<tr><td>" + teamNums[i] + "</td><td>" + list[teamNums[i]] + "</td></tr>"
|
document.getElementById('teammem').innerHTML += "<tr><td>" + teamNums[i] + "</td><td>" + list[teamNums[i]] + "</td>" + "<td><input type='button' class='btn' value='leave' onclick='leaveTeam(" + teamNums[i] + ")'></td></tr>"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
document.getElementById('teammem').innerHTML = "<tr><td>You are not part of any teams</td></tr>"
|
document.getElementById('teammem').innerHTML = "<tr><td>You are not part of any teams</td></tr>"
|
||||||
@ -86,6 +88,7 @@ function cnt(tn) {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkKeyMatch(dt, tn, key) {
|
function checkKeyMatch(dt, tn, key) {
|
||||||
for (i = 0; i < Object.keys(dt).length; i++) {
|
for (i = 0; i < Object.keys(dt).length; i++) {
|
||||||
if (Object.keys(dt)[i] == "code-" + key) {
|
if (Object.keys(dt)[i] == "code-" + key) {
|
||||||
@ -96,6 +99,7 @@ function checkKeyMatch(dt,tn,key){
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
function reqjt(tn, tc) {
|
function reqjt(tn, tc) {
|
||||||
user = firebase.auth().currentUser;
|
user = firebase.auth().currentUser;
|
||||||
firebase.firestore().collection('teamData').doc('joinCodes').get().then(function(doc) {
|
firebase.firestore().collection('teamData').doc('joinCodes').get().then(function(doc) {
|
||||||
@ -114,7 +118,7 @@ function reqjt(tn,tc){
|
|||||||
teamNums = Object.keys(list)
|
teamNums = Object.keys(list)
|
||||||
document.getElementById('teammem').innerHTML = ""
|
document.getElementById('teammem').innerHTML = ""
|
||||||
for (var i = 0; i < teamNums.length; i++) {
|
for (var i = 0; i < teamNums.length; i++) {
|
||||||
document.getElementById('teammem').innerHTML += "<tr><td>" + teamNums[i] + "</td><td>" + list[teamNums[i]] + "</td></tr>"
|
document.getElementById('teammem').innerHTML += "<tr><td>" + teamNums[i] + "</td><td>" + list[teamNums[i]] + "</td>" + "<td><input type='button' class='btn' value='leave' onclick='leaveTeam(" + teamNums[i] + ")'></td></tr>"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
document.getElementById('teammem').innerHTML = "<tr><td>You are not part of any teams</td></tr>"
|
document.getElementById('teammem').innerHTML = "<tr><td>You are not part of any teams</td></tr>"
|
||||||
@ -133,6 +137,31 @@ function reqjt(tn,tc){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function leaveTeam(tn) {
|
||||||
|
teamAssoc = firebase.firestore().collection('UserAssociations').doc(user.uid)
|
||||||
|
teamAssoc.get().then(function(doc) {
|
||||||
|
if (doc.exists) {
|
||||||
|
list = doc.data()
|
||||||
|
delete list[tn]
|
||||||
|
firebase.firestore().collection("UserAssociations").doc(user.uid).set(list).then(function() {
|
||||||
|
teamAssoc = firebase.firestore().collection('UserAssociations').doc(user.uid)
|
||||||
|
teamAssoc.get().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 += "<tr><td>" + teamNums[i] + "</td><td>" + list[teamNums[i]] + "</td>" + "<td><input type='button' class='btn' value='leave' onclick='leaveTeam(" + teamNums[i] + ")'></td></tr>"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
document.getElementById('teammem').innerHTML = "<tr><td>You are not part of any teams</td></tr>"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function signout() {
|
function signout() {
|
||||||
var user = firebase.auth().currentUser;
|
var user = firebase.auth().currentUser;
|
||||||
firebase.auth().signOut().then(
|
firebase.auth().signOut().then(
|
||||||
|
Loading…
Reference in New Issue
Block a user