Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Jan 5, 2024
1 parent dd137fc commit dc4707a
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pages/Login.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<input type="submit" value="Sumbit" />
</div>
<div class="text sign-up-text">
Don't have an account? <label for="flip">Sigup now</label>
Don't have an account? <label for="flip">Sigup now</label> <br><label id="loginwithfb">Login with Facebook</label> <br><label id="googleLoginBtn">Login with Google</label>
</div>
</div>
</form>
Expand Down
57 changes: 57 additions & 0 deletions pages/js/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import {
getAuth,
createUserWithEmailAndPassword,
signInWithEmailAndPassword,
OAuthProvider, // Add OAuthProvider import
signInWithPopup,
FacebookAuthProvider,
GoogleAuthProvider,
} from "https://www.gstatic.com/firebasejs/10.7.1/firebase-auth.js";
import {
getFirestore,
Expand All @@ -24,6 +28,7 @@ const firebaseConfig = {
storageBucket: "studygalaxy-8aa56.appspot.com",
messagingSenderId: "657368593724",
appId: "1:657368593724:web:ee0b1facca005fe9689a39",
authDomain: "127.0.0.1",
};

// Initialize Firebase
Expand All @@ -38,6 +43,8 @@ let passwordreg = document.getElementById("passwordreg");
let loginForm = document.getElementById("login");
let signupForm = document.getElementById("signup");
let username = document.getElementById("username");
const discordClientId = "1189554323026362468";
const discordRedirectUri = "http://localhost:5500/discord-callback"; // Update with your callback URI

let registerUser = async (evt) => {
evt.preventDefault();
Expand Down Expand Up @@ -86,6 +93,17 @@ let registerUser = async (evt) => {
console.error(error.message);
}
};
async function loginWithFacebook() {
const auth = getAuth();
const provider = new FacebookAuthProvider();

try {
const result = await signInWithPopup(auth, provider);
saveUserInfo(result);
} catch (error) {
console.error("Error signing in with Facebook:", error.message);
}
}

// Send verification email function
async function sendVerificationEmail(user) {
Expand Down Expand Up @@ -154,3 +172,42 @@ let signInUser = async (evt) => {

loginForm.addEventListener("submit", signInUser);
signupForm.addEventListener("submit", registerUser);


// Function to login with Google
let signInUserWithGoogle = async () => {
const googleProvider = new GoogleAuthProvider();
try {
const credentials = await signInWithPopup(auth, googleProvider);

// Save user information to Firebase
await saveUserInfo(credentials);

} catch (error) {
console.error("Google Authentication Error:", error.message);
}
};

async function saveUserInfo(credentials) {
try {
const ref = doc(db, "UserAuthList", credentials.user.uid);
const docSnap = await getDoc(ref);

if (docSnap.exists()) {
localStorage.setItem(
"user-info",
JSON.stringify({
Name: docSnap.data().Name,
})
);
localStorage.setItem("user-creds", JSON.stringify(credentials.user));
window.location.href = "studygalaxy.html";
}
} catch (error) {
console.error("Error saving user information:", error.message);
}
}

// Event listeners for Google and Discord login buttons
document.getElementById("googleLoginBtn").addEventListener("click", signInUserWithGoogle);
document.getElementById("loginwithfb").addEventListener("click", loginWithFacebook);
23 changes: 14 additions & 9 deletions pages/solo/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,19 @@ const firebaseConfig = {
document.querySelector(".btn1").style.display = "block";
});

//randon quote genetator

async function randomQuote() {
const response = await fetch("https://api.quotable.io/random");
const response = await fetch("https://api.quotable.io/quotes?tags=Education|famous-quotes|inspirational|knowledge");
const quote = await response.json();
// Output the quote and author name
document.getElementById("quote").innerHTML = quote.content;
document.getElementById("quote-author").innerHTML = "-" + quote.author;
if (response.ok) {
// Update DOM elements
console.log(quote);
document.getElementById("quote").innerHTML = `“ ${quote.results[0].content}”`;
document.getElementById("quote-author").innerHTML = "-" + quote.results[0].author;
}
}


randomQuote();
// timer function
const pomodoro = document.querySelector(".timer");
Expand Down Expand Up @@ -108,6 +113,8 @@ const firebaseConfig = {
});
time = clock;
a++;
randomQuote();

const swalWithBootstrapButtons = Swal.mixin({
customClass: {
confirmButton: "btn btn-success",
Expand Down Expand Up @@ -339,7 +346,7 @@ function pomodoroStart( studyTime, breakTime){


let sourcesLofiRecords = [ 'n61ULEU7CO0' ,'TURbeWK2wwg'];
let sourcesLofiEveryday= ['ezdP1lzsNUg','dzUHadgLiIY' , 'yKH7g4oupDE' ,'MZhivjxcF-M','Zbd1PKd-J_o','1bPb0egItVI', 'lzqHzF1S1F4','taNGanhQ8zo','n4P3CLAxJiw', 'Wqm-qADZP3U', 'BMCHy-AyhkY', 'UbLSGl-W46E']
let sourcesLofiEveryday= ['ezdP1lzsNUg','dzUHadgLiIY' , 'ZVEGvdh4-bM' , 'yKH7g4oupDE' ,'MZhivjxcF-M','Zbd1PKd-J_o','1bPb0egItVI', 'lzqHzF1S1F4','taNGanhQ8zo','n4P3CLAxJiw', 'Wqm-qADZP3U', 'BMCHy-AyhkY', 'UbLSGl-W46E']
// firstInstance.setSource(`https://www.youtube.com/watch?v=${sourcesLofiEveryday[0]}`)


Expand Down Expand Up @@ -417,6 +424,4 @@ document.querySelector('.lofiever').addEventListener('click', () => {
});
}
}
});

//
});
2 changes: 1 addition & 1 deletion pages/solo/solo.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h4 class="h5">Session - <span class="sessionNo"></span></h4>
</div>
</section>
<div class="quote">
<span class="h2"></span><span class="h4" id="quote"></span><span class="h2"></span>
<span class="h2"></span><span class="h4" id="quote"></span><span class="h2"></span>
<span class="h5" id="quote-author"></span>
</div>
<div class="pomodoroSettings sidepannel">
Expand Down
5 changes: 3 additions & 2 deletions pages/solo/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
user-select: none;
overflow: hidden !important;
z-index: 1;
text-shadow: #212529 1px 1px;

}
html{
position: fixed;
Expand All @@ -17,8 +19,7 @@ body{
}
.quote .h4 {
font-family: "Quando";
color: rgba(215, 213, 213, 0.71);
text-shadow: #212529 1px 1px;
color: rgb(255, 255, 255);
font-weight: 400;
}
.quote span{
Expand Down

0 comments on commit dc4707a

Please sign in to comment.