From e3669e8d4281afd8f12a88b8cc1c63a5196b7ab1 Mon Sep 17 00:00:00 2001 From: biglyderv Date: Sat, 12 Apr 2025 23:59:47 -0400 Subject: [PATCH] fix malformed input issue when there is nothing malformed --- index.js | 10 ++++++---- static/index.css | 12 +++++++----- static/index.js | 4 +--- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/index.js b/index.js index 69fb5d1..24cb45b 100644 --- a/index.js +++ b/index.js @@ -45,17 +45,18 @@ app.post('/', async function (req, res) { }) } + channels[id] = res; + let fsession = channels[id]; + setTimeout(async function () { - if (!sessions[id]) return; + if (fsession != channels[id]) return; if (channels[id].headersSent) return; try { channels[id].send('Input is possibly malformed.').header('access-allow-control-origin', '*') } catch (err) { } - }, 1000); - - channels[id] = res; + }, 600); let msgs = req.body.data.split('\n'); @@ -66,6 +67,7 @@ app.post('/', async function (req, res) { } setTimeout(async function () { + sessions[id].lastBusy = new Date(); sessions[id].stdin.write(msg + '\n'); }, 100); }); diff --git a/static/index.css b/static/index.css index f3dbe18..ff7e240 100644 --- a/static/index.css +++ b/static/index.css @@ -6,18 +6,20 @@ button { body { margin: 0; - padding-bottom: 3rem; + display: flex; + flex-direction: column; + justify-content: space-between; + height: 100vh; + } #form { background: rgba(0, 0, 0, 0.15); padding: 0.25rem; - position: fixed; - bottom: 0; - left: 0; - right: 0; box-sizing: border-box; backdrop-filter: blur(10px); + position: sticky; + bottom: 0; } .inner-form { diff --git a/static/index.js b/static/index.js index e6900da..d9b96e0 100644 --- a/static/index.js +++ b/static/index.js @@ -33,6 +33,4 @@ async function main(e) { form.addEventListener('submit', main); -document.querySelector('.send').addEventListener('click',function() { - main({preventDefault: () => {}}) -}) \ No newline at end of file +document.querySelector('.send').addEventListener('click',main); \ No newline at end of file