meows
parent
63252a0a86
commit
85d5297c94
12
README.md
12
README.md
|
@ -2,12 +2,8 @@
|
|||
|
||||
very very unfinished !! right now it can do a chatroom
|
||||
|
||||
## setup
|
||||
## usage
|
||||
|
||||
currently uses sqlite! install sqlite for your machine then do the following
|
||||
|
||||
```bash
|
||||
sqlite3 vybe.db < db/1-init.sql
|
||||
```
|
||||
|
||||
then you can `yarn install` and `node index.js`
|
||||
`npm install`
|
||||
then
|
||||
`node index.js`
|
||||
|
|
|
@ -29,7 +29,6 @@ async function loadKeys(keys) {
|
|||
function chooseThread(thread) {
|
||||
window.currentThreadId = thread.id;
|
||||
window.earliestMessage = null;
|
||||
document.getElementById("loadmore").classList.remove("hidden");
|
||||
document.getElementById("messages").innerHTML = "";
|
||||
document.getElementById("threadname").innerHTML = thread.name;
|
||||
}
|
||||
|
@ -50,6 +49,7 @@ function addThread(thread) {
|
|||
btn.onclick = () => {
|
||||
chooseThread(thread);
|
||||
loadMessages();
|
||||
document.getElementById("loadmore").classList.remove("hidden");
|
||||
};
|
||||
el.appendChild(btn);
|
||||
document.getElementById("threadlist").appendChild(el);
|
||||
|
@ -67,10 +67,8 @@ window.onload = () => {
|
|||
strong.textContent = msg.name + ': ';
|
||||
el.append(strong, msg.message);
|
||||
document.getElementById("messages").appendChild(el);
|
||||
if (!window.earliestMessage) window.earliestMessage = msg.id;
|
||||
});
|
||||
window.socket.on("send_message", (msg) => {
|
||||
if (!window.earliestMessage) window.earliestMessage = msg.id;
|
||||
if (!window.earliestMessage)
|
||||
window.earliestMessage = msg.id;
|
||||
});
|
||||
window.socket.on("get_history", (msg) => {
|
||||
if (msg.messages.length > 0) {
|
||||
|
@ -84,7 +82,8 @@ window.onload = () => {
|
|||
document.getElementById("messages").prepend(el);
|
||||
}
|
||||
}
|
||||
if (!msg.more) document.getElementById("loadmore").classList.add("hidden");
|
||||
if (!msg.more)
|
||||
document.getElementById("loadmore").classList.add("hidden");
|
||||
});
|
||||
window.socket.on("authenticate", (msg) => {
|
||||
if (msg.success) {
|
||||
|
@ -141,10 +140,6 @@ window.onload = () => {
|
|||
thread: window.currentThreadId,
|
||||
});
|
||||
document.getElementById("msg").value = "";
|
||||
const el = document.createElement("div");
|
||||
el.classList.add("message");
|
||||
el.innerHTML = `<strong>${window.name}: </strong>${msg}`;
|
||||
document.getElementById("messages").appendChild(el);
|
||||
};
|
||||
document.getElementById("loadmore").onclick = e => {
|
||||
loadMessages();
|
||||
|
|
|
@ -6,7 +6,13 @@ const create_thread = async (msg, respond, socket, io) => {
|
|||
if (!msg.name) {
|
||||
return respond({
|
||||
success: false,
|
||||
message: "Thread name required",
|
||||
message: "thread name required",
|
||||
});
|
||||
}
|
||||
if (msg.name.length > 200) {
|
||||
return respond({
|
||||
success: false,
|
||||
message: "thread name 200 chars max",
|
||||
});
|
||||
}
|
||||
// add to db
|
||||
|
|
Loading…
Reference in New Issue