Created
February 12, 2018 20:59
-
-
Save indie-rok/3db68dabbfebcf8ea45a7c318951af32 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang='en'> | |
<head> | |
<meta charset='UTF-8'/> | |
<meta name='viewport' content='width=device-width, initial-scale=1.0'/> | |
<meta http-equiv='X-UA-Compatible' content='ie=edge'/> | |
<title>Document</title> | |
</head> | |
<body> | |
<h1>aqui va la logica de fb</h1> | |
<button id="crear_usuarios">Crear usuarios</button> | |
<section id='user_container'></section> | |
<script src="https://www.gstatic.com/firebasejs/4.9.1/firebase.js"></script> | |
<script> | |
// Initialize Firebase | |
var config = { | |
apiKey: "AIzaSyCacpJQqaB8omqwgZYzsKmSVZRGDagpOyQ", | |
authDomain: "chilaquil-1495833008539.firebaseapp.com", | |
databaseURL: "https://chilaquil-1495833008539.firebaseio.com", | |
projectId: "chilaquil-1495833008539", | |
storageBucket: "", | |
messagingSenderId: "242606230167" | |
}; | |
firebase.initializeApp(config); | |
// Get a reference to the database service | |
var database = firebase.database(); | |
function writeUserData(userId, name, email, imageUrl, variableDelResultado) { | |
firebase | |
.database() | |
.ref("users/" + userId) | |
.set({ | |
username: name, | |
email: email, | |
profile_picture: imageUrl, | |
frances_perfecto: variableDelResultado | |
}); | |
} | |
var crearUsuarios = document.getElementById("crear_usuarios"); | |
crearUsuarios.addEventListener("click", crearUsuariosFuncion); | |
function crearUsuariosFuncion() { | |
writeUserData("1", "Manu", "manu@laboratoria.la", "http://imagen.com", false); | |
writeUserData( | |
"99", | |
"Lucile", | |
"lucile@laboratoria.la", | |
"http://imagen.com", | |
true | |
); | |
} | |
firebase | |
.database() | |
.ref("users/") | |
.once("value") | |
.then(function(results) { | |
var users = results.val(); | |
var userContainer = document.getElementById("user_container"); | |
userContainer.innerHTML = users[1]["email"]; | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment