Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marcos branch #12

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion y/app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
<<<<<<< Updated upstream





//setup M Components of CSS
// document.addEventListener('DOMContentLoaded', function() {
// var modals = document.querySelectorAll('.modal');
// M.Modal.init(modals);

// var items = document.querySelectorAll('.collapsible');
// M.Collapsible.init(items);
// })
=======
import M from "materialize-css"
document.addEventListener('DOMContentLoaded', function() {
var modals = document.querySelectorAll('.modal');
M.Modal.init(modals);

var items = document.querySelectorAll('.collapsible');
M.Collapsible.init(items);
})
});
>>>>>>> Stashed changes
71 changes: 71 additions & 0 deletions y/calendar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />

<!-------------------- Font Awwsome -------------------->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css"
/>

<!-------------------- CSS -------------------->
<title>Calendar</title>
<link rel="stylesheet" href="calendar.css" />
</head>

<body>
<!-- <header>
<h1>Calendar Page</h1>
</header> -->

<div class="page-content">
<div class="row">
<div class="container-left">
<div class="calendar">
<div class="month">
<i class="fas fa-angle-left prev"></i>
<div class="date">
<h1></h1>
<!-- <p></p> -->
</div>
<i class="fas fa-angle-right next"></i>
</div>
<div class="weekdays">
<div>Sun</div>
<div>Mon</div>
<div>Tue</div>
<div>Wed</div>
<div>Thu</div>
<div>Fri</div>
<div>Sat</div>
</div>
<div class="days"></div>
</div>
</div>
<div class="container-right">
<div class="event-placeholder">
<div class="event-container">
<div class="event"></div>
<!-- <div class="event"></div>
<div class="event"></div>
<div class="event"></div>
<div class="event"></div>
<div class="event"></div>
<div class="event"></div>
<div class="event"></div>
<div class="event"></div>
<div class="event"></div>
<div class="event"></div>
<div class="event"></div>
<div class="event"></div> -->
</div>
<button class="fas fa-plus add-event"></button>
</div>
</div>
</div>
<script src="calendar.js"></script>
</body>
</html>
30 changes: 23 additions & 7 deletions y/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
<head>
<meta charset="utf-8">
<!-- firebase -->
<script defer src="/__/firebase/9.0.2/firebase-app-compat.js"></script>
<!-- <script defer src="/__/firebase/9.0.2/firebase-app-compat.js"></script> -->
<!-- include only the Firebase features as you need -->
<script defer src="/__/firebase/9.0.2/firebase-auth-compat.js"></script>
<!-- <script defer src="/__/firebase/9.0.2/firebase-auth-compat.js"></script>
<script defer src="/__/firebase/9.0.2/firebase-database-compat.js"></script>
<script defer src="/__/firebase/9.0.2/firebase-firestore-compat.js"></script>
<script defer src="/__/firebase/9.0.2/firebase-functions-compat.js"></script>
<script defer src="/__/firebase/9.0.2/firebase-messaging-compat.js"></script>
<script defer src="/__/firebase/9.0.2/firebase-storage-compat.js"></script>
<script defer src="/__/firebase/9.0.2/firebase-analytics-compat.js"></script>
<script defer src="/__/firebase/9.0.2/firebase-remote-config-compat.js"></script>
<script defer src="/__/firebase/9.0.2/firebase-performance-compat.js"></script>
<script defer src="/__/firebase/9.0.2/firebase-performance-compat.js"></script> -->
<!--
initialize the SDK after all desired features are loaded, set useEmulator to false
to avoid connecting the SDK to running emulators.
-->
<script defer src="/__/firebase/init.js?useEmulator=true"></script>
<!-- <script defer src="/__/firebase/init.js?useEmulator=true"></script> -->
<title>Login + Firebase Database</title>
<!-- Cool Google Fonts -->
<link rel="preconnect" href="https://fonts.gstatic.com">
Expand All @@ -45,9 +45,6 @@ <h1>Login</h1>
<label>Password</label>
</div>
<button type="submit"> Login </button>
<!-- <div class="pass">Forgot Password?</div> -->
<!-- <input type="submit" value="Login"> -->
<!-- <button type="Facebook" onclick="facebookLogin()">Log in with Facebook</button> -->

<button type="Google" onclick="googleLogin()">Log in with Google </button>
<div class="signup_link">
Expand All @@ -59,14 +56,33 @@ <h1>Login</h1>
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/8.6.8/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.6.8/firebase.js"></script>
<<<<<<< Updated upstream


=======
>>>>>>> Stashed changes
<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="https://www.gstatic.com/firebasejs/8.6.8/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.6.8/firebase-database.js"></script>
<script>
const firebaseConfig = {
apiKey: "AIzaSyDTux8kStcOHDEmLKB_fbqGbxNE2lLKHL4",
authDomain: "paw-lender.firebaseapp.com",
databaseURL: "https://paw-lender-default-rtdb.firebaseio.com",
projectId: "paw-lender",
storageBucket: "paw-lender.appspot.com",
messagingSenderId: "156009579264",
appId: "1:156009579264:web:e9123a4fd752386f0669e5",
measurementId: "G-ZSRT2Q966P"
};
firebase.initializeApp(firebaseConfig);
const auth = firebase.auth();
const db = firebase.firestore();
</script>

<!-- Our script must be loaded after firebase references -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script src="index.js"></script>
<script src="app.js"></script>

Expand Down
73 changes: 52 additions & 21 deletions y/index.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,72 @@

// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyDTux8kStcOHDEmLKB_fbqGbxNE2lLKHL4",
authDomain: "paw-lender.firebaseapp.com",
databaseURL: "https://paw-lender-default-rtdb.firebaseio.com",
projectId: "paw-lender",
storageBucket: "paw-lender.appspot.com",
messagingSenderId: "156009579264",
appId: "1:156009579264:web:e9123a4fd752386f0669e5",
measurementId: "G-ZSRT2Q966P"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
// Initialize variables
const auth = firebase.auth();
const database = firebase.realtime();
// const firebaseConfig = {
// apiKey: "AIzaSyDTux8kStcOHDEmLKB_fbqGbxNE2lLKHL4",
// authDomain: "paw-lender.firebaseapp.com",
// databaseURL: "https://paw-lender-default-rtdb.firebaseio.com",
// projectId: "paw-lender",
// storageBucket: "paw-lender.appspot.com",
// messagingSenderId: "156009579264",
// appId: "1:156009579264:web:e9123a4fd752386f0669e5",
// measurementId: "G-ZSRT2Q966P"
// };
// firebase.initializeApp(firebaseConfig);
firebase.auth.Auth.Persistence.SESSION;


if (!firebase.apps.length) {
firebase.initializeApp(firebaseConfig);
}
else {
firebase.app(); // if already initialized, use that one
}
//const auth = firebase.auth();
//const database = firebase.firestore();


db.collection('users').get().then(snapshot => {
console.log(snapshot.docs);
});
//listen for auth status change



//firebase.auth().onAuthStateChanged(user => {
//if(user) {
// window.location = 'home.html'; //After successful login, user will be redirected to home.html
//}
//});
auth.onAuthStateChanged(user => {
//console.log(user)

if(user){
console.log('user logged in', user);
db.collection('users').get().then(snapshot => {
//code here
setupUsers(snapshot.docs);
});
// console.log('user logged in', user);
}
else {
setupUsers([]);
console.log('user logged out');
}
})

});
if(user) {
window.location = 'home.html'; //redirect user to home page after login is successful
}
// <---------- SignUp ----------->
// const firestore = firebase.firestore();
//google log in
function googleLogin() {
e.preventDefault();
const provider1 = new firebase.auth.GoogleAuthProvider();
firebase.auth().signInWithPopup(provider1)
.then(result => {
const user = result.user;
})
}
function facebookLogin() {
e.preventDefault();
const provider = new firebase.auth.FacebookAuthProvider();
firebase.auth().signInWithPopup(provider)
.then(result => {
Expand Down Expand Up @@ -73,16 +104,16 @@ logout.addEventListener('click', (e) => {
const signinForm = document.querySelector('#signin-Form');
signinForm.addEventListener('submit', (e) => {
e.preventDefault();

//get user info
const email = signinForm['login-email'].value;
const password = signinForm['login-password'].value;

auth.signInWithEmailAndPassword(email, password).then(cred => {
auth.signInWithEmailAndPassword(email, password).then((cred) => {
//console.log(cred.user);
//close login module reset form
const modal = document.querySelector('#modal-login')
M.Modal.getInstance(modal).close();
signinForm.reset();
});
});
});
window.onload = "http://www.google.com/"