1 comment

[ 3.6 ms ] story [ 11.1 ms ] thread
<!DOCTYPE html> <ul id='list'></ul> <form id='form'> <input id='who' placeholder='name'> <input id='what' placeholder='say'> <input type='submit' value='send'> </form> <script type="module"> import { GDB } from "../dist/index.js"; let db = new GDB('chat9linescode'), chat = db.get("note" + location.hash.replace('#', '/')), view = document; db.map(({ id, value }) => { (view.line = view.getElementById(id) || view.createElement("li")).id = id; list.appendChild(view.line).innerText = value.msg window.scroll(0, list.offsetHeight); }); form.onsubmit = (eve) => { db.put({ msg: who.value + ': ' + what.value }), eve.preventDefault(what.value = "") } </script>