diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/index.js b/index.js index 2383095..6075b93 100644 --- a/index.js +++ b/index.js @@ -13,8 +13,9 @@ app.set('trust proxy', true) app.use(express.static('static')); app.post('/', async function (req, res) { - let id = 'web:' + createHash('sha256').update(req.ip).digest('hex'); - id = id.slice(0,24); + let id = 'web:' + createHash('sha256').update(req.ip).digest('hex'); + console.log(req.ip) + id = id.slice(0, 24); if (!sessions[id]) { try { @@ -34,7 +35,7 @@ app.post('/', async function (req, res) { if (channels[id].headersSent) return; try { - channels[id].send(str).header('access-allow-control-origin','*') + channels[id].send(str).header('access-allow-control-origin', '*') } catch (err) { } } }); @@ -43,15 +44,15 @@ app.post('/', async function (req, res) { }) } - setTimeout(async function() { + setTimeout(async function () { if (!sessions[id]) return; if (channels[id].headersSent) return; try { - channels[id].send('Input is possibly malformed.').header('access-allow-control-origin','*') + channels[id].send('Input is possibly malformed.').header('access-allow-control-origin', '*') } catch (err) { - + } - },1000); + }, 1000); channels[id] = res; diff --git a/static/index.css b/static/index.css index 9fc8584..c7e41f7 100644 --- a/static/index.css +++ b/static/index.css @@ -1,7 +1,12 @@ +:root, +input, +button { + font-family: monospace; +} + body { margin: 0; padding-bottom: 3rem; - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; } #form { @@ -12,7 +17,8 @@ body { left: 0; right: 0; display: flex; - height: 3rem; + flex-wrap: wrap; + min-height: 3rem; box-sizing: border-box; backdrop-filter: blur(10px); } @@ -36,7 +42,11 @@ body { margin: 0.25rem; border-radius: 3px; outline: none; +} + +button, button a { color: #fff; + text-decoration: none; } #messages { diff --git a/static/index.html b/static/index.html index 2491bba..0fe8b2b 100644 --- a/static/index.html +++ b/static/index.html @@ -11,7 +11,9 @@
- + + +
diff --git a/static/index.js b/static/index.js index 6266caf..86149ae 100644 --- a/static/index.js +++ b/static/index.js @@ -3,8 +3,16 @@ var messages = document.getElementById('messages'); var form = document.getElementById('form'); var input = document.getElementById('input'); +async function addMsg(msg) { + var item = document.createElement('li'); + item.textContent = msg; + messages.appendChild(item); + window.scrollTo(0, document.body.scrollHeight); +} + async function main(e) { e.preventDefault(); + if (!input.value) return; let msg = await fetch("/", { @@ -18,15 +26,9 @@ async function main(e) { msg = await msg.text(); msg = msg.trim(); + addMsg(input.value) input.value = ''; - - var item = document.createElement('li'); - item.textContent = msg; - messages.appendChild(item); - window.scrollTo(0, document.body.scrollHeight); + addMsg(msg) } -form.addEventListener('submit', main); - -input.value = 'test'; -main({ preventDefault: () => { }}) \ No newline at end of file +form.addEventListener('submit', main); \ No newline at end of file