summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xserver.js8
-rw-r--r--static/index.js6
2 files changed, 8 insertions, 6 deletions
diff --git a/server.js b/server.js
index e9d0761..da29e0a 100755
--- a/server.js
+++ b/server.js
@@ -37,14 +37,14 @@ class Database {
this.#lastbackup = new Date();
}
- add_new(string) {
+ add_new(votes, string) {
for (let i = 0; i < this.#list.length; i++) {
if (this.#list[i][1] == string) {
return "already existed";
}
}
- this.#list.push([0, string]);
+ this.#list.push([votes, string]);
this.#sort();
this.#persist();
@@ -162,9 +162,9 @@ io.on("connection", socket => {
}
});
- socket.on("new", string => {
+ socket.on("new", (votes, string) => {
if (!logged_in) { socket.emit("unauth"); return; }
- const res = database.add_new(string);
+ const res = database.add_new(votes, string);
if (res != null) socket.emit("error", res);
});
diff --git a/static/index.js b/static/index.js
index 31099d6..311afc7 100644
--- a/static/index.js
+++ b/static/index.js
@@ -141,9 +141,11 @@ function submitNewItem(string) {
}
}
- socket.emit("new", string);
+ const votes = 1;
- insertItem(0, string);
+ socket.emit("new", votes, string);
+
+ insertItem(votes, string);
}
function upvoteItem(string, incr) {