My Photo World
html>
const firebaseConfig = {
apiKey: "YOUR-API-KEY",
authDomain: "YOUR-PROJECT.firebaseapp.com",
projectId: "YOUR-PROJECT-ID",
storageBucket: "YOUR-PROJECT.appspot.com",
messagingSenderId: "xxxx",
appId: "xxx"
};
firebase.initializeApp(firebaseConfig);
const auth = firebase.auth();
const storage = firebase.storage();
const db = firebase.firestore();
function signInWithGoogle() {
const provider = new firebase.auth.GoogleAuthProvider();
auth.signInWithPopup(provider).then(user => {
alert("Login Successful");
}).catch(console.error);
}
function logout() {
auth.signOut().then(() => alert("Logged out"));
}
function deleteAccount() {
auth.currentUser.delete().then(() => {
alert("Account deleted");
}).catch(error => {
alert("Re-login to delete account");
});
}
function uploadMedia(event) {
const file = event.target.files[0];
const ref = storage.ref().child("uploads/" + file.name);
ref.put(file).then(snapshot => {
ref.getDownloadURL().then(url => {
const mediaElement = file.type.startsWith("video") ? document.createElement("video") : document.createElement("img");
mediaElement.src = url;
if (file.type.startsWith("video")) mediaElement.controls = true;
document.getElementById("gallery").appendChild(mediaElement);
});
});
}
function toggleTheme() {
document.body.classList.toggle("dark-theme");
}
body {
background: white;
color: black;
font-family: sans-serif;
transition: all 0.3s;
}
body.dark-theme {
background: #121212;
color: white;
}
button {
margin: 10px;
padding: 10px;
cursor: pointer;
}
img, video {
width: 300px;
margin: 10px;
border-radius: 10px;
}