From a9b1de227c2b6e99ea0169ec8918d1b0a5e7118f Mon Sep 17 00:00:00 2001 From: r7uaz0n Date: Tue, 6 Jun 2017 14:00:19 -0700 Subject: [PATCH 01/13] firebase-test-files --- firebase-test/firebasetest.js | 0 firebase-test/index.html | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 firebase-test/firebasetest.js create mode 100644 firebase-test/index.html diff --git a/firebase-test/firebasetest.js b/firebase-test/firebasetest.js new file mode 100644 index 0000000..e69de29 diff --git a/firebase-test/index.html b/firebase-test/index.html new file mode 100644 index 0000000..3ef4626 --- /dev/null +++ b/firebase-test/index.html @@ -0,0 +1,18 @@ + + + + + + + + Testing Firebase! + + + +

Testing Firebase!

+

+ + . + + + \ No newline at end of file From 9a828a8cc56dc1a9cc613fed5cd7ac39fb051c59 Mon Sep 17 00:00:00 2001 From: r7uaz0n Date: Tue, 6 Jun 2017 14:06:28 -0700 Subject: [PATCH 02/13] firebase-test-files --- firebase-test/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/firebase-test/index.html b/firebase-test/index.html index 3ef4626..aeafdc9 100644 --- a/firebase-test/index.html +++ b/firebase-test/index.html @@ -11,6 +11,7 @@

Testing Firebase!

+ . From de65f18e533a6a7ca6e26a76508d2a6bb969e7a7 Mon Sep 17 00:00:00 2001 From: r7uaz0n Date: Tue, 6 Jun 2017 14:21:13 -0700 Subject: [PATCH 03/13] firebase-test-files-revised --- firebase-test/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firebase-test/index.html b/firebase-test/index.html index aeafdc9..f50f884 100644 --- a/firebase-test/index.html +++ b/firebase-test/index.html @@ -11,9 +11,9 @@

Testing Firebase!

- + - . + \ No newline at end of file From 8847ec2d446c636e944aa4ecf5f98fd7a5d82d11 Mon Sep 17 00:00:00 2001 From: naoever Date: Fri, 9 Jun 2017 15:18:22 -0700 Subject: [PATCH 04/13] Update index.html --- firebase-test/index.html | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/firebase-test/index.html b/firebase-test/index.html index f50f884..7321b99 100644 --- a/firebase-test/index.html +++ b/firebase-test/index.html @@ -1,4 +1,3 @@ - @@ -9,11 +8,11 @@ -

Testing Firebase!

-

+

Testing Firebase!

+

- - + + - \ No newline at end of file + From 3c3b7629c56b4007b218db99f45e5d0d436093d6 Mon Sep 17 00:00:00 2001 From: naoever Date: Fri, 9 Jun 2017 15:19:33 -0700 Subject: [PATCH 05/13] Update firebasetest.js Display myname from Firebase. --- firebase-test/firebasetest.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/firebase-test/firebasetest.js b/firebase-test/firebasetest.js index e69de29..cab42c8 100644 --- a/firebase-test/firebasetest.js +++ b/firebase-test/firebasetest.js @@ -0,0 +1,25 @@ +// JavaScript Document + +// Initialize Firebase + var config = { + apiKey: "AIzaSyAAKWAWX9IYQjC1q7hjZL5nsTqWfEulU9I", + authDomain: "fir-test-5f0d3.firebaseapp.com", + databaseURL: "https://fir-test-5f0d3.firebaseio.com", + projectId: "fir-test-5f0d3", + storageBucket: "fir-test-5f0d3.appspot.com", + messagingSenderId: "852596610591" + }; + firebase.initializeApp(config); + + +// Create a JavaScript object for the HTML element that has id="message" +var messageBox = document.getElementById("message"); + +// Get a reference to the row of our database called "greeting" +var dbRef = firebase.database().ref().child("myname"); + +// Whenever our database reference is updated, show the data on our web page! +dbRef.on("value", function(dataSnapshot) { + messageBox.textContent = dataSnapshot.val(); +}); + From a1eac8db10bc63a07750c3b2df25279c6a6570ee Mon Sep 17 00:00:00 2001 From: naoever Date: Fri, 9 Jun 2017 18:15:09 -0700 Subject: [PATCH 06/13] Create firebasetest.js add dbGreeting, adUsername --- firebase-test/firebasetest.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/firebase-test/firebasetest.js b/firebase-test/firebasetest.js index cab42c8..da06794 100644 --- a/firebase-test/firebasetest.js +++ b/firebase-test/firebasetest.js @@ -11,12 +11,21 @@ }; firebase.initializeApp(config); + // Create a JavaScript object for the HTML element that has id="message" +var usernameBox = document.getElementById("username"); // Create a JavaScript object for the HTML element that has id="message" var messageBox = document.getElementById("message"); // Get a reference to the row of our database called "greeting" -var dbRef = firebase.database().ref().child("myname"); +// var dbRef = firebase.database().ref().child("myname"); + +var dbRef = firebase.database().ref(); + +// Get a reference to the "greeting" section of our database +var dbGreeting = dbRef.child("greeting"); +// Get a reference to the "myname" section of our database +var dbUsername = dbRef.child("myname"); // Whenever our database reference is updated, show the data on our web page! dbRef.on("value", function(dataSnapshot) { From 83aad408f2f8e88ec5b272a621c06698ba744971 Mon Sep 17 00:00:00 2001 From: naoever Date: Sat, 10 Jun 2017 13:25:45 -0700 Subject: [PATCH 07/13] Create firebasetest.js --- firebase-test/firebasetest.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/firebase-test/firebasetest.js b/firebase-test/firebasetest.js index da06794..2e56879 100644 --- a/firebase-test/firebasetest.js +++ b/firebase-test/firebasetest.js @@ -23,12 +23,23 @@ var messageBox = document.getElementById("message"); var dbRef = firebase.database().ref(); // Get a reference to the "greeting" section of our database +// var dbGreeting = dbRef.child("greeting"); var dbGreeting = dbRef.child("greeting"); // Get a reference to the "myname" section of our database var dbUsername = dbRef.child("myname"); // Whenever our database reference is updated, show the data on our web page! -dbRef.on("value", function(dataSnapshot) { +// Where is the event happening? On the dbRef object, which now points to the root of our Firebase database! +// Which event are we listening for? The "value" event, which is triggered any time a value changes inside this database location. +// What should happen when the event occurs? Run an anonymous function that will display the value of the new data inside the messageBox element on our web page. + +// textContent = text in the paragraph +dbGreeting.on("value", function(dataSnapshot) { messageBox.textContent = dataSnapshot.val(); + console.log( dataSnapshot.val() ); }); +dbUsername.on("value", function(dataSnapshot) { + usernameBox.textContent = dataSnapshot.val(); + console.log( dataSnapshot.val() ); +}); From 86b1c1465f718fd14bfdc08349e9cc6b56803be7 Mon Sep 17 00:00:00 2001 From: naoever Date: Sat, 10 Jun 2017 13:32:08 -0700 Subject: [PATCH 08/13] Create index.html --- firebase-test/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/firebase-test/index.html b/firebase-test/index.html index 7321b99..82e3048 100644 --- a/firebase-test/index.html +++ b/firebase-test/index.html @@ -10,6 +10,7 @@

Testing Firebase!

+

From 6d348f87084420f24b610d405ab7c2d3b89eba9e Mon Sep 17 00:00:00 2001 From: naoever Date: Sat, 10 Jun 2017 13:32:55 -0700 Subject: [PATCH 09/13] Update index.html --- firebase-test/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firebase-test/index.html b/firebase-test/index.html index 82e3048..7550dac 100644 --- a/firebase-test/index.html +++ b/firebase-test/index.html @@ -9,8 +9,8 @@

Testing Firebase!

-

-

+

+

From b26db84f9d92d2bb7a750d3e8dccd4bc1b18ef29 Mon Sep 17 00:00:00 2001 From: naoever Date: Fri, 16 Jun 2017 17:17:24 -0700 Subject: [PATCH 10/13] Update firebasetest.js --- firebase-test/firebasetest.js | 98 ++++++++++++++++++++++++++--------- 1 file changed, 73 insertions(+), 25 deletions(-) diff --git a/firebase-test/firebasetest.js b/firebase-test/firebasetest.js index 2e56879..e95b4e6 100644 --- a/firebase-test/firebasetest.js +++ b/firebase-test/firebasetest.js @@ -1,45 +1,93 @@ -// JavaScript Document - // Initialize Firebase - var config = { - apiKey: "AIzaSyAAKWAWX9IYQjC1q7hjZL5nsTqWfEulU9I", - authDomain: "fir-test-5f0d3.firebaseapp.com", - databaseURL: "https://fir-test-5f0d3.firebaseio.com", - projectId: "fir-test-5f0d3", - storageBucket: "fir-test-5f0d3.appspot.com", - messagingSenderId: "852596610591" - }; - firebase.initializeApp(config); - - // Create a JavaScript object for the HTML element that has id="message" -var usernameBox = document.getElementById("username"); +var config = { + apiKey: "AIzaSyCdoBkKYmhVlgvy46sBKLLknJUszf-TYAc", + authDomain: "test-web-app-4fde9.firebaseapp.com", + databaseURL: "https://test-web-app-4fde9.firebaseio.com", + projectId: "test-web-app-4fde9", + storageBucket: "test-web-app-4fde9.appspot.com", + messagingSenderId: "406177608219" +}; + +firebase.initializeApp(config); + +var provider = new firebase.auth.GithubAuthProvider(); // Create a JavaScript object for the HTML element that has id="message" var messageBox = document.getElementById("message"); +// Create a JavaScript object for the HTML element that has id="username" +var usernameBox = document.getElementById("username"); -// Get a reference to the row of our database called "greeting" -// var dbRef = firebase.database().ref().child("myname"); +var userInfoBox = document.getElementById("userinfo"); +var loginButton = document.getElementById("login"); +var logoutButton = document.getElementById("logout"); +// Get a reference to the root of our database var dbRef = firebase.database().ref(); - // Get a reference to the "greeting" section of our database -// var dbGreeting = dbRef.child("greeting"); var dbGreeting = dbRef.child("greeting"); // Get a reference to the "myname" section of our database var dbUsername = dbRef.child("myname"); -// Whenever our database reference is updated, show the data on our web page! -// Where is the event happening? On the dbRef object, which now points to the root of our Firebase database! -// Which event are we listening for? The "value" event, which is triggered any time a value changes inside this database location. -// What should happen when the event occurs? Run an anonymous function that will display the value of the new data inside the messageBox element on our web page. - -// textContent = text in the paragraph +// Whenever "greeting" value in our database is updated, show the data inside messageBox! dbGreeting.on("value", function(dataSnapshot) { - messageBox.textContent = dataSnapshot.val(); + messageBox.textContent = dataSnapshot.val(); console.log( dataSnapshot.val() ); }); +// Whenever "myname" value in our database is updated, show the data inside usernameBox! dbUsername.on("value", function(dataSnapshot) { usernameBox.textContent = dataSnapshot.val(); console.log( dataSnapshot.val() ); }); + + +// challenge 5 +//When user clicks login button: +loginButton.addEventListener("click", function(){ + console.log("User clicked LOGIN"); +}); + +// Use Firebase with GitHub Auth to log in the user +firebase.auth().signInWithPopup(provider).catch(function(error) { + // Log any errors to the console + console.log(error); +}); + +// When user clicks logout button: +logoutButton.addEventListener("click", function(){ + console.log("User clicked LOGOUT"); +}); + +// Use Firebase with GitHub Auth to log in the user +firebase.auth().signOut().catch(function(error) { + // Log any errors to the console + console.log(error); +}); +// challenge 5 + + + +// When user logs in or logs out: +firebase.auth().onAuthStateChanged(function(user){ + // If user is now logged in: + if (user) { + + console.log('User successfully logged in to Firebase!'); + + // HERE: Update the paragraph with ID of "userinfo" to display user's GitHub username and GitHub profile photo! + + // Otherwise, if no user currently logged in: + } else { + + console.log('User successfully logged OUT from Firebase!'); + + // HERE: Update the paragraph with ID of "userinfo" to display the message "Not currently logged in." + + } +}); + +//displayName +//Inherited from firebase.UserInfo#displayName + +//photoURL +// Inherited from firebase.UserInfo#photoURL From 2d31249bfe420b04951bea19084d054d7a403526 Mon Sep 17 00:00:00 2001 From: naoever Date: Fri, 16 Jun 2017 17:18:12 -0700 Subject: [PATCH 11/13] Update index.html --- firebase-test/index.html | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/firebase-test/index.html b/firebase-test/index.html index 7550dac..320d897 100644 --- a/firebase-test/index.html +++ b/firebase-test/index.html @@ -1,19 +1,21 @@ - - + - - - Testing Firebase! + Firebase Test - + -

Testing Firebase!

+

Testing Firebase!

- - + +

Not currently logged in.

+ + + + + + - From 649f069b907800a13357e9187f3fda22981ce59e Mon Sep 17 00:00:00 2001 From: naoever Date: Sat, 24 Jun 2017 15:19:14 -0700 Subject: [PATCH 12/13] Update firebasetest.js --- firebase-test/firebasetest.js | 57 ++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/firebase-test/firebasetest.js b/firebase-test/firebasetest.js index e95b4e6..5651960 100644 --- a/firebase-test/firebasetest.js +++ b/firebase-test/firebasetest.js @@ -1,14 +1,13 @@ // Initialize Firebase var config = { - apiKey: "AIzaSyCdoBkKYmhVlgvy46sBKLLknJUszf-TYAc", - authDomain: "test-web-app-4fde9.firebaseapp.com", - databaseURL: "https://test-web-app-4fde9.firebaseio.com", - projectId: "test-web-app-4fde9", - storageBucket: "test-web-app-4fde9.appspot.com", - messagingSenderId: "406177608219" -}; - -firebase.initializeApp(config); + apiKey: "AIzaSyAAKWAWX9IYQjC1q7hjZL5nsTqWfEulU9I", + authDomain: "fir-test-5f0d3.firebaseapp.com", + databaseURL: "https://fir-test-5f0d3.firebaseio.com", + projectId: "fir-test-5f0d3", + storageBucket: "fir-test-5f0d3.appspot.com", + messagingSenderId: "852596610591" + }; + firebase.initializeApp(config); var provider = new firebase.auth.GithubAuthProvider(); @@ -45,49 +44,53 @@ dbUsername.on("value", function(dataSnapshot) { //When user clicks login button: loginButton.addEventListener("click", function(){ console.log("User clicked LOGIN"); -}); -// Use Firebase with GitHub Auth to log in the user -firebase.auth().signInWithPopup(provider).catch(function(error) { - // Log any errors to the console - console.log(error); + // Use Firebase with GitHub Auth to log in the user + firebase.auth().signInWithPopup(provider).catch(function(error) { + // Log any errors to the console + console.log(error); + }); + }); + // When user clicks logout button: logoutButton.addEventListener("click", function(){ console.log("User clicked LOGOUT"); -}); + // Use Firebase with GitHub Auth to log in the user + firebase.auth().signOut().catch(function(error) { + // Log any errors to the console + console.log(error); -// Use Firebase with GitHub Auth to log in the user -firebase.auth().signOut().catch(function(error) { - // Log any errors to the console - console.log(error); + }); }); -// challenge 5 - // When user logs in or logs out: firebase.auth().onAuthStateChanged(function(user){ // If user is now logged in: - if (user) { + if (user) { console.log('User successfully logged in to Firebase!'); - // HERE: Update the paragraph with ID of "userinfo" to display user's GitHub username and GitHub profile photo! + console.log(user.email); + + document.getElementById("userinfo").innerHTML = 'The ' + user.email + ' will go here and the' + 'profile photo will go here: '; // Otherwise, if no user currently logged in: + } else { console.log('User successfully logged OUT from Firebase!'); + document.getElementById("userinfo").textContent = 'Not currently logged in.'; + + // HERE: Update the paragraph with ID of "userinfo" to display the message "Not currently logged in." } }); -//displayName -//Inherited from firebase.UserInfo#displayName -//photoURL -// Inherited from firebase.UserInfo#photoURL + + From f9417de664f969bd5aa3db1edc63a02454747308 Mon Sep 17 00:00:00 2001 From: naoever Date: Sat, 24 Jun 2017 15:30:21 -0700 Subject: [PATCH 13/13] Update firebasetest.js --- firebase-test/firebasetest.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/firebase-test/firebasetest.js b/firebase-test/firebasetest.js index 5651960..7e13e54 100644 --- a/firebase-test/firebasetest.js +++ b/firebase-test/firebasetest.js @@ -85,9 +85,6 @@ firebase.auth().onAuthStateChanged(function(user){ document.getElementById("userinfo").textContent = 'Not currently logged in.'; - - // HERE: Update the paragraph with ID of "userinfo" to display the message "Not currently logged in." - } });