Initiate guestbook functions
This commit is contained in:
parent
7a9d062e60
commit
89b08094f8
|
@ -16,7 +16,6 @@ const nameInputEl = document.querySelector('#name-input');
|
||||||
const emailInputEl = document.querySelector('#email-input');
|
const emailInputEl = document.querySelector('#email-input');
|
||||||
const websiteInputEl = document.querySelector('#website-input');
|
const websiteInputEl = document.querySelector('#website-input');
|
||||||
const msgInputEl = document.querySelector('#message-input');
|
const msgInputEl = document.querySelector('#message-input');
|
||||||
const publishBtn = document.querySelector('.gb__form--submit');
|
|
||||||
const messageListEl = document.querySelector('.gb__message--list');
|
const messageListEl = document.querySelector('.gb__message--list');
|
||||||
|
|
||||||
// Initiate guestbook message object
|
// Initiate guestbook message object
|
||||||
|
@ -29,15 +28,31 @@ let messageObj = {
|
||||||
replies: [],
|
replies: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Form submission event
|
||||||
formEl.addEventListener('submit', (e) => {
|
formEl.addEventListener('submit', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
clearInputEl();
|
clearInputEl();
|
||||||
console.log('Form submitted');
|
console.log('Form submitted');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Clear input fields
|
||||||
const clearInputEl = () => {
|
const clearInputEl = () => {
|
||||||
nameInputEl.value = '';
|
nameInputEl.value = '';
|
||||||
emailInputEl.value = '';
|
emailInputEl.value = '';
|
||||||
websiteInputEl.value = '';
|
websiteInputEl.value = '';
|
||||||
msgInputEl.value = '';
|
msgInputEl.value = '';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Load data from the Firebase database
|
||||||
|
onValue(endorsementsInDB, (snapshot) => {});
|
||||||
|
|
||||||
|
// Prevent rendering any message more than once
|
||||||
|
const clearMessageListEl = () => {
|
||||||
|
messageListEl.innerHTML = '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Render each message
|
||||||
|
const renderMessage = (item) => {
|
||||||
|
const itemID = item[0];
|
||||||
|
const itemValue = item[1];
|
||||||
|
};
|
Loading…
Reference in New Issue