ui changes

This commit is contained in:
biglyderv 2025-04-02 22:55:51 -04:00
parent 747389c697
commit 16290ebdb7
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5
5 changed files with 34 additions and 19 deletions

0
README.md Normal file
View file

View file

@ -13,8 +13,9 @@ app.set('trust proxy', true)
app.use(express.static('static')); app.use(express.static('static'));
app.post('/', async function (req, res) { app.post('/', async function (req, res) {
let id = 'web:' + createHash('sha256').update(req.ip).digest('hex'); let id = 'web:' + createHash('sha256').update(req.ip).digest('hex');
id = id.slice(0,24); console.log(req.ip)
id = id.slice(0, 24);
if (!sessions[id]) { if (!sessions[id]) {
try { try {
@ -34,7 +35,7 @@ app.post('/', async function (req, res) {
if (channels[id].headersSent) return; if (channels[id].headersSent) return;
try { try {
channels[id].send(str).header('access-allow-control-origin','*') channels[id].send(str).header('access-allow-control-origin', '*')
} catch (err) { } } catch (err) { }
} }
}); });
@ -43,15 +44,15 @@ app.post('/', async function (req, res) {
}) })
} }
setTimeout(async function() { setTimeout(async function () {
if (!sessions[id]) return; if (!sessions[id]) return;
if (channels[id].headersSent) return; if (channels[id].headersSent) return;
try { 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) { } catch (err) {
} }
},1000); }, 1000);
channels[id] = res; channels[id] = res;

View file

@ -1,7 +1,12 @@
:root,
input,
button {
font-family: monospace;
}
body { body {
margin: 0; margin: 0;
padding-bottom: 3rem; padding-bottom: 3rem;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
} }
#form { #form {
@ -12,7 +17,8 @@ body {
left: 0; left: 0;
right: 0; right: 0;
display: flex; display: flex;
height: 3rem; flex-wrap: wrap;
min-height: 3rem;
box-sizing: border-box; box-sizing: border-box;
backdrop-filter: blur(10px); backdrop-filter: blur(10px);
} }
@ -36,7 +42,11 @@ body {
margin: 0.25rem; margin: 0.25rem;
border-radius: 3px; border-radius: 3px;
outline: none; outline: none;
}
button, button a {
color: #fff; color: #fff;
text-decoration: none;
} }
#messages { #messages {

View file

@ -11,7 +11,9 @@
<body> <body>
<ul id="messages"></ul> <ul id="messages"></ul>
<form id="form" action=""> <form id="form" action="">
<input id="input" autocomplete="off" /><button>Send</button> <input id="input" autocomplete="off" />
<button><a href='#'>Send</a></button>
<button><a href='https://discord.com/invite/Wkr7PVk3cF'>Discord</a></button>
</form> </form>
<script src='/index.js'></script> <script src='/index.js'></script>
</body> </body>

View file

@ -3,8 +3,16 @@ var messages = document.getElementById('messages');
var form = document.getElementById('form'); var form = document.getElementById('form');
var input = document.getElementById('input'); 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) { async function main(e) {
e.preventDefault(); e.preventDefault();
if (!input.value) return; if (!input.value) return;
let msg = await fetch("/", { let msg = await fetch("/", {
@ -18,15 +26,9 @@ async function main(e) {
msg = await msg.text(); msg = await msg.text();
msg = msg.trim(); msg = msg.trim();
addMsg(input.value)
input.value = ''; input.value = '';
addMsg(msg)
var item = document.createElement('li');
item.textContent = msg;
messages.appendChild(item);
window.scrollTo(0, document.body.scrollHeight);
} }
form.addEventListener('submit', main); form.addEventListener('submit', main);
input.value = 'test';
main({ preventDefault: () => { }})