mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2025-09-07 07:27:20 +00:00
restructured file management
This commit is contained in:
45
data analysis/dep/2019/website/public/team/index.html
Normal file
45
data analysis/dep/2019/website/public/team/index.html
Normal file
@@ -0,0 +1,45 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" dir="ltr">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>titanscout</title>
|
||||
<script src="https://www.gstatic.com/firebasejs/5.7.2/firebase.js"></script>
|
||||
<script src="https://www.gstatic.com/firebasejs/5.8.0/firebase-firestore.js"></script>
|
||||
<script src="https://cdn.firebase.com/libs/firebaseui/3.5.1/firebaseui.js"></script>
|
||||
<link type="text/css" rel="stylesheet" href="https://cdn.firebase.com/libs/firebaseui/3.5.1/firebaseui.css" />
|
||||
<link rel="stylesheet" href="../style.css" type="text/css" />
|
||||
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
|
||||
<script type="text/javascript" src="scripts.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="mySidenav" class="sidenav">
|
||||
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
|
||||
<a href="#">Profile</a>
|
||||
<a href="../team">Team</a>
|
||||
<a href="../scout">Scout Matches</a>
|
||||
<a href="../stats">Tournament Stats</a>
|
||||
</div>
|
||||
<div id="main">
|
||||
<span onclick="openNav()" id="topbar">
|
||||
<img id="sideload" src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Hamburger_icon.svg/1200px-Hamburger_icon.svg.png">
|
||||
</span>
|
||||
<h1 id="mainhead">TitanScout- Your Teams</h1>
|
||||
<p id="status">Loading...</p>
|
||||
<input type="button" name="Sign Out" value="Sign Out" onclick="signout();" id="signout" class="btn">
|
||||
<input type="button" name="DelAcc" value="Delete Account" onclick="deleteAccount();" id="deleteacc" class="btn">
|
||||
<h2>Team Membership</h2>
|
||||
<div id="newstuff">
|
||||
<div>
|
||||
<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="etn">
|
||||
<input type="text" name="JC" value="" placeholder="Join Code" id="jcn">
|
||||
</div>
|
||||
</div>
|
||||
<table id="teammem">
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
182
data analysis/dep/2019/website/public/team/scripts.js
Normal file
182
data analysis/dep/2019/website/public/team/scripts.js
Normal file
@@ -0,0 +1,182 @@
|
||||
/* Set the width of the side navigation to 250px and the left margin of the page content to 250px and add a black background color to body */
|
||||
function openNav() {
|
||||
document.getElementById("mySidenav").style.width = "250px";
|
||||
document.getElementById("main").style.marginLeft = "250px";
|
||||
document.body.style.backgroundColor = "rgba(0,0,0,0.4)";
|
||||
for (var i = 0; i < document.getElementsByClassName("btn").length; i++) {
|
||||
document.getElementsByClassName("btn")[i].style.backgroundColor = "rgba(0,0,0,.2)"
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the width of the side navigation to 0 and the left margin of the page content to 0, and the background color of body to white */
|
||||
function closeNav() {
|
||||
document.getElementById("mySidenav").style.width = "0";
|
||||
document.getElementById("main").style.marginLeft = "0";
|
||||
document.body.style.backgroundColor = "white";
|
||||
for (var i = 0; i < document.getElementsByClassName("btn").length; i++) {
|
||||
document.getElementsByClassName("btn")[i].style.backgroundColor = "buttonface"
|
||||
}
|
||||
}
|
||||
|
||||
window.onload = function() {
|
||||
document.getElementById('sideload').style.display = 'block';
|
||||
var config = {
|
||||
apiKey: "(insert the TitanScout Api Key Here)",
|
||||
authDomain: "titanscoutandroid.firebaseapp.com",
|
||||
databaseURL: "https://titanscoutandroid.firebaseio.com",
|
||||
projectId: "titanscoutandroid",
|
||||
storageBucket: "titanscoutandroid.appspot.com",
|
||||
messagingSenderId: "1097635313476"
|
||||
};
|
||||
firebase.initializeApp(config);
|
||||
firebase.auth().onAuthStateChanged(function(user) {
|
||||
if (user != null) {
|
||||
if (user.displayName != null) {
|
||||
document.getElementById('status').innerHTML = "You are signed in as: " + user.displayName;
|
||||
//document.getElementById('newDN').innerHTML = user.displayName;
|
||||
} else if (user.email != null) {
|
||||
document.getElementById('status').innerHTML = "You are signed in as: " + user.email;
|
||||
} else if (user.phoneNumber != null) {
|
||||
document.getElementById('status').innerHTML = "You are signed in as: " + user.phoneNumber;
|
||||
} else {
|
||||
document.getElementById('status').innerHTML = "You are signed in.";
|
||||
}
|
||||
if (user.email != null) {
|
||||
document.getElementById('newEM').innerHTML = user.email;
|
||||
}
|
||||
} else {
|
||||
window.location.replace('../');
|
||||
}
|
||||
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>"
|
||||
}
|
||||
})
|
||||
});
|
||||
firebase.firestore.settings({
|
||||
timestampsInSnapshots: true
|
||||
})
|
||||
}
|
||||
|
||||
function cnt(tn) {
|
||||
user = firebase.auth().currentUser;
|
||||
push = {}
|
||||
push[tn] = 'captian'
|
||||
firebase.firestore().collection("UserAssociations").doc(user.uid).set(push, {
|
||||
merge: true
|
||||
}).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 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]] == "team-" + tn) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function reqjt(tn, tc) {
|
||||
user = firebase.auth().currentUser;
|
||||
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() {
|
||||
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>"
|
||||
}
|
||||
})
|
||||
})
|
||||
} 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!");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function leaveTeam(tn) {
|
||||
user = firebase.auth().currentUser;
|
||||
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() {
|
||||
var user = firebase.auth().currentUser;
|
||||
firebase.auth().signOut().then(
|
||||
window.location.href = '../');
|
||||
}
|
||||
|
||||
function deleteAccount() {
|
||||
try {
|
||||
firebase.auth().currentUser.delete().then(
|
||||
window.location.href = '../');
|
||||
} catch (error) {
|
||||
if (error.code == 'auth/requires-recent-login') {
|
||||
alert("Please sign in again to delete your account.")
|
||||
window.location.href = '../';
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user