Created
November 24, 2018 12:31
-
-
Save mihailsitnic/cfe4d435fe288bc508b66428a24877e7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* Initialize Firebase | |
/* ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## */ | |
const config = { | |
apiKey: "AIzaSyBM3775D6P6G97DJ19M3MxD9uCfvFf_AVs", | |
authDomain: "web-dev-45423.firebaseapp.com", | |
databaseURL: "https://web-dev-45423.firebaseio.com", | |
projectId: "web-dev-45423", | |
storageBucket: "", | |
messagingSenderId: "981641631998" | |
}; | |
firebase.initializeApp(config); | |
const formFutureBtn = document.getElementById('form__btn'); | |
const studentMail = document.getElementById('student-mail').value; | |
const spinner = document.getElementById('donut'); | |
const resText = document.getElementById('form__res'); | |
const errText = document.getElementById('form__err'); | |
const checkbox1 = document.getElementById('answer-1').checked; | |
const checkbox2 = document.getElementById('answer-2').checked; | |
const checkbox3 = document.getElementById('answer-3').checked; | |
const checkbox4 = document.getElementById('answer-4').checked; | |
const checkbox5 = document.getElementById('answer-5').checked; | |
const postRef = firebase.database().ref('/future'); | |
/* Post Data Future | |
/* ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## */ | |
formFutureBtn.addEventListener( | |
'click', (e) => { | |
e.preventDefault(); | |
spinner.classList.add('donut--active'); | |
postRef.push({ | |
'date': new Date().toLocaleString(), | |
'studentMail': studentMail, | |
'checkbox1': checkbox1, | |
'checkbox2': checkbox2, | |
'checkbox3': checkbox3, | |
'checkbox4': checkbox4, | |
'checkbox5': checkbox5, | |
}).then(res => { | |
console.log(res); | |
spinner.classList.remove('donut--active'); | |
setTimeout(resText.classList.add('form__res--active'), 2000); | |
}).catch(err => { | |
console.log(err); | |
spinner.classList.remove('donut--active'); | |
setTimeout(errText.classList.add('form__err--active'), 2000); | |
}); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment