Cor de fundo:
Nome do painel:
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js')
.then(() => console.log('Service Worker registrado!'))
.catch(err => console.error('Erro ao registrar o Service Worker', err));
}
const firebaseConfig = {
apiKey: "SUA_API_KEY",
authDomain: "SEU_DOMINIO.firebaseapp.com",
databaseURL: "https://SEU_DATABASE.firebaseio.com",
projectId: "SEU_PROJECT_ID",
storageBucket: "SEU_BUCKET.appspot.com",
messagingSenderId: "SEU_SENDER_ID",
appId: "SEU_APP_ID"
};
firebase.initializeApp(firebaseConfig);
const db = firebase.database();
const auth = firebase.auth();
function login() {
const email = document.getElementById("email").value;
const senha = document.getElementById("senha").value;
auth.signInWithEmailAndPassword(email, senha)
.then(() => {
document.getElementById("login").style.display = "none";
document.getElementById("painel").style.display = "block";
})
.catch(error => alert("Erro ao fazer login: " + error.message));
}
function gerarSenha() {
const novaSenha = "S" + Math.floor(Math.random() * 1000);
db.ref("senhas").push(novaSenha);
}
function chamarSenha() {
db.ref("senhas").once("value", snapshot => {
const senhas = snapshot.val();
if (senhas) {
const primeiraChave = Object.keys(senhas)[0];
const senhaAtual = senhas[primeiraChave];
document.getElementById("senha-atual").innerText = senhaAtual;
db.ref("senhas/" + primeiraChave).remove();
}
});
}
function customizar() {
document.body.style.backgroundColor = document.getElementById("corFundo").value;
document.getElementById("titulo").innerText = document.getElementById("nomePainel").value;
}
</script>