started teams page

This commit is contained in:
Jacob Levine 2019-02-12 20:20:30 -06:00
parent c6b2840e07
commit 45a4387c68
3 changed files with 100 additions and 23 deletions

View File

@ -52,14 +52,14 @@ window.onload = function() {
function signout() { function signout() {
var user = firebase.auth().currentUser; var user = firebase.auth().currentUser;
firebase.auth().signOut() firebase.auth().signOut().then(
window.location.href = '../'; window.location.href = '../');
} }
function deleteAccount() { function deleteAccount() {
try { try {
firebase.auth().currentUser.delete() firebase.auth().currentUser.delete().then(
window.location.href = '../'; window.location.href = '../');
} catch (error) { } catch (error) {
if (error.code == 'auth/requires-recent-login') { if (error.code == 'auth/requires-recent-login') {
alert("Please sign in again to delete your account.") alert("Please sign in again to delete your account.")
@ -68,6 +68,7 @@ function deleteAccount() {
} }
} }
function updun() { function updun() {
var user = firebase.auth().currentUser; var user = firebase.auth().currentUser;
user.updateProfile({ user.updateProfile({

View File

@ -1,30 +1,50 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en" dir="ltr"> <html lang="en" dir="ltr">
<head>
<head>
<meta charset="utf-8">
<title>
<meta charset="utf-8"> <meta charset="utf-8">
<title><meta charset="utf-8">
<title>titanscout</title> <title>titanscout</title>
<script src="https://www.gstatic.com/firebasejs/5.7.2/firebase.js"></script> <script src="https://www.gstatic.com/firebasejs/5.7.2/firebase.js"></script>
<script src="https://cdn.firebase.com/libs/firebaseui/3.5.1/firebaseui.js"></script> <script src="https://cdn.firebase.com/libs/firebaseui/3.5.1/firebaseui.js"></script>
<script src="https://www.gstatic.com/firebasejs/5.8.0/firebase-firestore.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.firebase.com/libs/firebaseui/3.5.1/firebaseui.css" /> <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 rel="stylesheet" href="../style.css" type="text/css" />
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<script type="text/javascript" src="scripts.js"></script> <script type="text/javascript" src="scripts.js"></script>
</head> </head>
<body>
<div id="mySidenav" class="sidenav"> <body>
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a> <div id="mySidenav" class="sidenav">
<a href="../profile">Profile</a> <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a>
<a href="#">Team</a> <a href="../profile">Profile</a>
<a href="../scout">Scout Matches</a> <a href="#">Team</a>
<a href="../stats">Torunament Stats</a> <a href="../scout">Scout Matches</a>
<a href="../stats">Torunament 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="Create New Team" class="btn" onclick="cnt(document.getElementById(ntn).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">
</div>
</div> </div>
<div id="main"> <table id="teammem">
<span onclick="openNav()" id="topbar"> </table>
<img id="sideload" src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Hamburger_icon.svg/1200px-Hamburger_icon.svg.png"> </div>
</span> </body>
<h1 id="mainhead">TitanScout- Your Teams</h1>
<p id="status">Loading...</p>
</div>
</body>
</html> </html>

View File

@ -3,6 +3,9 @@ function openNav() {
document.getElementById("mySidenav").style.width = "250px"; document.getElementById("mySidenav").style.width = "250px";
document.getElementById("main").style.marginLeft = "250px"; document.getElementById("main").style.marginLeft = "250px";
document.body.style.backgroundColor = "rgba(0,0,0,0.4)"; 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 */ /* 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 */
@ -10,6 +13,9 @@ function closeNav() {
document.getElementById("mySidenav").style.width = "0"; document.getElementById("mySidenav").style.width = "0";
document.getElementById("main").style.marginLeft = "0"; document.getElementById("main").style.marginLeft = "0";
document.body.style.backgroundColor = "white"; 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() { window.onload = function() {
@ -22,12 +28,12 @@ window.onload = function() {
storageBucket: "titanscoutandroid.appspot.com", storageBucket: "titanscoutandroid.appspot.com",
messagingSenderId: "1097635313476" messagingSenderId: "1097635313476"
}; };
//eventually find a less-jank way to do this tho
firebase.initializeApp(config); firebase.initializeApp(config);
firebase.auth().onAuthStateChanged(function(user) { firebase.auth().onAuthStateChanged(function(user) {
if (user != null) { if (user != null) {
if (user.displayName != null) { if (user.displayName != null) {
document.getElementById('status').innerHTML = "You are signed in as: " + user.displayName; document.getElementById('status').innerHTML = "You are signed in as: " + user.displayName;
document.getElementById('newDN').innerHTML = user.displayName;
} else if (user.email != null) { } else if (user.email != null) {
document.getElementById('status').innerHTML = "You are signed in as: " + user.email; document.getElementById('status').innerHTML = "You are signed in as: " + user.email;
} else if (user.phoneNumber != null) { } else if (user.phoneNumber != null) {
@ -35,8 +41,58 @@ window.onload = function() {
} else { } else {
document.getElementById('status').innerHTML = "You are signed in."; document.getElementById('status').innerHTML = "You are signed in.";
} }
if (user.email != null) {
document.getElementById('newEM').innerHTML = user.email;
}
} else { } else {
window.location.replace('../'); window.location.replace('../');
} }
teamAssoc=firebase.firestore().collections('UserAssociations').doc(user.uid);
teamAssoc.get().then(function(doc){
if(doc.exists)}{
list=doc.data()
teamNums=Object.keys(list)
document.getElementById(teammem).innerHTML = ""
for i in teamNums(){
document.getElementById(teammem).innerHTML +="<tr><td>"+i+"</td><td>"+list.i+"</td></tr>"
}
}else {
document.getElementById(teammem).innerHTML = "<tr><td>You are not part of any teams</td></tr>"
}
})
}); });
} }
function cnt(tn) {
firebase.firestore().collection("UserAssociations").doc(user.id).set({tn : 'captain'} , { merge: true }).then(
teamAssoc=firebase.firestore().collections('UserAssociations').doc(user.uid);
teamAssoc.get().then(function(doc){
if(doc.exists)}{
list=doc.data()
teamNums=Object.keys(list)
document.getElementById(teammem).innerHTML = ""
for i in teamNums(){
document.getElementById(teammem).innerHTML +="<tr><td>"+i+"</td><td>"+list.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 = '../';
}
}
}