// Initialize Firebase
var config = {
apiKey: "AIzaSyBMkJxiw00Mf4IW54d7SiHQym3DO6fCM1U",
authDomain: "thewalkingdead-9fc71.firebaseapp.com",
databaseURL: "https://thewalkingdead-9fc71.firebaseio.com",
projectId: "thewalkingdead-9fc71",
storageBucket: "thewalkingdead-9fc71.appspot.com",
messagingSenderId: "224388998916"
};
firebase.initializeApp(config);
console.log(firebase);
let database = firebase.database();
var ref = database.ref('characters');
function addNewName() {
let nameValue = document.getElementById("submittedValue").value;
let newName = {
name: nameValue
}
ref.push(newName);
}
ref.on('value', gotData, errData);
function gotData(data) {
let names = data.val();
let keys = Object.keys(names);
for (let i = 0; i < keys.length; i = i + 1) {
let name = names[keys[i]].name;
let li = document.createElement('li', name);
document.getElementById('list').appendChild(li);
li.innerHTML = name;
}
}
function errData(err) {
console.log(err.val());
console.log('Error !');
}