main
jerl 2023-05-12 17:50:00 -07:00
parent 1c408aa1ba
commit ce03802950
2 changed files with 13 additions and 9 deletions

View File

@ -51,11 +51,6 @@ async function message(e) {
document.getElementById("messages").appendChild(el);
}
function swap() {
document.getElementById("register").classList.add("hidden");
document.getElementById("chat").classList.remove("hidden");
}
function startThreadPicker() {
document.getElementById("chat").classList.add("hidden");
document.getElementById("threads").classList.remove("hidden");
@ -103,7 +98,9 @@ window.onload = () => {
if (msg.thread !== window.currentThreadId) return;
const el = document.createElement("div");
el.classList.add("message");
el.innerHTML = `<strong>${msg.name}: </strong>${msg.message}`;
const strong = document.createElement('strong');
strong.textContent = message.name + ': ';
el.append(strong, message.message);
document.getElementById("messages").appendChild(el);
if (!window.earliestMessage) window.earliestMessage = msg.id;
});
@ -116,14 +113,19 @@ window.onload = () => {
for (let message of msg.messages) {
const el = document.createElement("div");
el.classList.add("message");
el.innerHTML = `<strong>${message.name}: </strong>${message.message}`;
const strong = document.createElement('strong');
strong.textContent = message.name + ': ';
el.append(strong, message.message);
document.getElementById("messages").prepend(el);
}
}
if (!msg.more) document.getElementById("loadmore").classList.add("hidden");
});
window.socket.on("authenticate", (msg) => {
if (msg.success) swap();
if (msg.success) {
document.getElementById("register").classList.add("hidden");
document.getElementById("chat").classList.remove("hidden");
}
let emitter = window.socket.emit;
window.socket.emit = (type, data) => {
if (data)
@ -159,6 +161,8 @@ window.onload = () => {
window.name = localStorage.getItem("name");
loadKeys(JSON.parse(keys)).then(() => {});
}
else
document.getElementById("register").classList.remove("hidden");
document.getElementById("registerform").onsubmit = register;
document.getElementById("msginput").onsubmit = message;
document.getElementById("loadmore").onclick = loadMessages;

View File

@ -33,7 +33,7 @@
</style>
</head>
<body>
<div id="register">
<div id="register" class="hidden">
<h1>welcome to vybe</h1>
<h3>this site is in beta</h3>
<p>