mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2024-12-27 09:59:10 +00:00
fixed teamlogic
This commit is contained in:
parent
060a77f4b7
commit
251390fddf
@ -32,12 +32,9 @@
|
|||||||
<h2>Team Membership</h2>
|
<h2>Team Membership</h2>
|
||||||
<div id="newstuff">
|
<div id="newstuff">
|
||||||
<div>
|
<div>
|
||||||
<input type="button" name="CNT" value="Create New Team" class="btn" onclick="cnt(document.getElementById('ntn').value);">
|
<input type="button" name="CNT" value="Request to Join a Team" class="btn" onclick="reqjt(document.getElementById('etn').value,document.getElementById('jcn').value);">
|
||||||
<input type="text" name="TMN" value="" placeholder="Team Name" id="ntn">
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<input type="button" name="CNT" value="Request to Join a Team" class="btn" onclick="reqjt(document.getElementById('etn').value);">
|
|
||||||
<input type="text" name="TMN" value="" placeholder="Team Name" id="etn">
|
<input type="text" name="TMN" value="" placeholder="Team Name" id="etn">
|
||||||
|
<input type="text" name="JC" value="" placeholder="Join Code" id="jcn">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<table id="teammem">
|
<table id="teammem">
|
||||||
|
@ -47,6 +47,7 @@ window.onload = function() {
|
|||||||
} else {
|
} else {
|
||||||
window.location.replace('../');
|
window.location.replace('../');
|
||||||
}
|
}
|
||||||
|
firebase.firestore.settings({timestampsInSnapshots: true})
|
||||||
teamAssoc = firebase.firestore().collection('UserAssociations').doc(user.uid);
|
teamAssoc = firebase.firestore().collection('UserAssociations').doc(user.uid);
|
||||||
teamAssoc.get().then(function(doc) {
|
teamAssoc.get().then(function(doc) {
|
||||||
if (doc.exists) {
|
if (doc.exists) {
|
||||||
@ -85,6 +86,38 @@ function cnt(tn) {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
function checkKeyMatch(dt,tn,key){
|
||||||
|
for(i=0; i<Object.keys(dt).length; i++){
|
||||||
|
if (Object.keys(dt)[i]=="code-"+key){
|
||||||
|
if (dt[Object.keys(dt)[i]]==tn){
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
function reqjt(tn,tc){
|
||||||
|
user=firebase.auth().currentUser;
|
||||||
|
dict=firebase.firestore().collection('teamData').doc('joinCodes').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 += "<tr><td>" + teamNums[i] + "</td><td>" + list[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;
|
||||||
|
Loading…
Reference in New Issue
Block a user