Simple Firebase Comments
How do I make an simple firebase comments?
Credit to http://codepen.io/mstone6769/pen/zvObRY.November 20th: Added time-stamp feature.. What is a simple firebase comments? How do you make a simple firebase comments? This script and codes were developed by Josh Bivens on 01 October 2022, Saturday.
Simple Firebase Comments - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Simple Firebase Comments</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <body> <div class="container"> <div class="comment-box"> <div class="comment-form"> <div class="header">Add Your Comment</div> <form> <div> <input type="text" id="name" placeholder="Name"/> </div> <div> <textarea id="comment" rows="3" cols="30" placeholder="Comment"></textarea> </div> <button type="submit">COMMENT</button> </form> </div> <div> <h4 class="header">Comments</h4> <div id="comments"></div> </div> <div class="footer"><hr><p>© 2016 by Josh Bivens</p></div> </div> </div>
</body> <script src='https://cdn.firebase.com/js/client/2.2.1/firebase.js'></script> <script src="js/index.js"></script>
</body>
</html>
Simple Firebase Comments - Script Codes CSS Codes
@import url(https://fonts.googleapis.com/css?family=Roboto:400,600);
body { font-family: "Roboto", sans-serif; height: 100%; margin-bottom: 50px; background: cadetblue;
}
h4 { margin: 5px 20px;
}
span { float: right; margin-right: 10px; font-size: 12px; font-weight: 300;
}
hr { border: 0; height: 0; border-top: 1px solid rgba(0, 0, 0, 0.1); border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}
.container { display: flex; justify-content: center;
}
.comment-box { width: 85%; margin-top: 50px; background: #fff; padding: 5px; display: flex; justify-content: center; flex-direction: column;
}
.comment-box p { margin: 0 30px 15px; font-weight: 300; color: #333; word-wrap: break-word; background: #EEE; padding: 5px 10px;
}
.header { margin: 15px 20px; font-size: 27px; font-weight: 600;
}
form { margin: 10px 10px 30px 10px;
}
form ::-webkit-input-placeholder { color: #CCC; font-weight: 300;
}
input[type="text"], textarea { margin: 5px 10px; outline: none; background: #efefef; border: 0; padding: 10px;
}
textarea { resize: none; width: 85%;
}
input[type="text"] { width: 50%; margin-bottom: 15px;
}
button { font-weight: 400; margin: 12px 0 0 10px; border: 0; color: #fff; font-size: 15px; background: #D3775D; padding: 12px 20px 12px 20px; text-decoration: none; transition: all 0.2s ease;
}
button:hover { background: #C15322;
}
.footer p { float: right; font-size: 13px; margin-bottom: 10px; background: #FFF;
}
Simple Firebase Comments - Script Codes JS Codes
const ref = new Firebase("https://radiant-torch-3037.firebaseio.com/");
const form = document.querySelector("form");
form.addEventListener("submit", postComment);
const timeStamp = () => { let options = { month: '2-digit', day: '2-digit', year: '2-digit', hour: '2-digit', minute:'2-digit' }; let now = new Date().toLocaleString('en-US', options); return now;
};
function postComment(e) { e.preventDefault(); let name = document.getElementById("name").value; let comment = document.getElementById("comment").value; if (name && comment) { ref.push({ name: name, comment: comment, time: timeStamp() }); } document.getElementById("name").value = ''; document.getElementById("comment").value = '';
};
ref.on("child_added", function(snapshot) { let comment = snapshot.val(); addComment(comment.name, comment.comment, comment.time);
});
const addComment = (name, comment, timeStamp) => { let comments = document.getElementById("comments"); comments.innerHTML = `<hr><h4>${name} says<span>${timeStamp}</span></h4><p>${comment}</p>${comments.innerHTML}`;
}
Developer | Josh Bivens |
Username | joshbivens |
Uploaded | October 01, 2022 |
Rating | 3.5 |
Size | 3,695 Kb |
Views | 26,312 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
React Palette Picker | 4,004 Kb |
Vue Habit Tracker | 4,239 Kb |
Vue Progress Bar | 2,408 Kb |
Hours | 2,703 Kb |
Currency Conversion Cards | 2,576 Kb |
Fun Facts | 3,023 Kb |
Alarm Clock UI | 4,491 Kb |
Vue Shopping Cart | 4,157 Kb |
Material Form | 4,012 Kb |
Todos in Vue.js | 3,766 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Out of the blue | Giaco | 2,537 Kb |
Social.svg.min | Larsenwork | 13,849 Kb |
CSS3 iPad | Vikvarg | 1,766 Kb |
Firefox Breakout Guide | Quincysoeliman | 2,576 Kb |
Myprofile | SoufianeAbid | 2,451 Kb |
Another brick in the wall | Fivera | 1,955 Kb |
Portfolio Landing Page | FDfranklin | 3,585 Kb |
CardMove | Thompsonemerson | 3,699 Kb |
Button Option Group | Honchoman | 1,859 Kb |
A simple log in form made with css | Mayurelbhar | 2,160 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!