summaryrefslogtreecommitdiff
path: root/public/js
diff options
context:
space:
mode:
Diffstat (limited to 'public/js')
-rw-r--r--public/js/home.js13
-rw-r--r--public/js/people.js2
-rw-r--r--public/js/profile.js13
3 files changed, 17 insertions, 11 deletions
diff --git a/public/js/home.js b/public/js/home.js
index ee3d6f0..cf56eca 100644
--- a/public/js/home.js
+++ b/public/js/home.js
@@ -33,17 +33,17 @@ function parsePost(post) {
<span class="gtext mtext">${parseDate(new Date(post.date))}</span>
</div>
</div>
- <p class="mtext">
+ <p class="mtext" style="color: var(--text);">
${post.content.replace(/\n/g,'<br>')}
</p>
- <span class="gtext mtext">
- ${Object.keys(post.likes).map(k => post.likes[k]).filter(v => v !== false).length} Likes
+ <span class="gtext mtext likes">
+ ${post.likes.length} Likes
</span>
<div class="fullline nb"></div>
<div class="postbuttons">
<span class="likeclicky" onclick="like(this)">
<i class="liketoggle icons like ${post.likes.includes(data.user.user_id) ? 'blue' : ''}"></i>
- <span class="liketoggle bold ${post.likes.includes(data.user.user_id) ? 'blue' : ''}">Like</span>
+ <span class="liketoggle bold ${post.likes.includes(data.user.user_id) ? 'bltext' : ''}">Like</span>
</span>
<span onclick="this.parentElement.parentElement.getElementsByClassName('newcomment')[0].focus()">
<i class="icons comm"></i>
@@ -95,11 +95,12 @@ async function like(span) {
.getElementsByClassName("liketoggle")
if (current) {
buttons[0].classList.remove("blue")
- buttons[1].classList.remove("blue")
+ buttons[1].classList.remove("bltext")
} else {
buttons[0].classList.add("blue")
- buttons[1].classList.add("blue")
+ buttons[1].classList.add("bltext")
}
+ container.getElementsByClassName("likes")[0].innerHTML = post.likes.length + " Likes"
}
async function comment(event) {
diff --git a/public/js/people.js b/public/js/people.js
index 5c1026b..15fde59 100644
--- a/public/js/people.js
+++ b/public/js/people.js
@@ -1,6 +1,6 @@
function parseUser(user) {
const html = `
- <a class="person" href="/profile?id=${user.id}">
+ <a class="person" href="/profile?id=${user.user_id}">
<div class="profile">
</div>
diff --git a/public/js/profile.js b/public/js/profile.js
index 787e2b2..1e14c21 100644
--- a/public/js/profile.js
+++ b/public/js/profile.js
@@ -90,22 +90,26 @@ async function load() {
params[key] = value
}
- data.user = (await loadself()).json;
- data.users[data.user.user_id] = data.user
+ data.self = (await loadself()).json;
+ data.users[data.self.user_id] = data.self
let id;
if (params.id !== undefined && !isNaN(params.id)) {
id = parseInt(params.id);
} else {
- id = data.user.user_id
+ id = data.self.user_id
}
- isself = id === data.user.user_id
+ isself = id === data.self.user_id
const posts = (await loadusersposts(id)).json
data.posts.push(... posts)
const batch = []
+
+ if (!isself) {
+ batch.push(id)
+ }
for (const post of posts) {
for(const comment of post.comments) {
if (data.users[comment[0]] !== undefined) continue
@@ -120,6 +124,7 @@ async function load() {
for (const user of users) {
data.users[user.user_id] = user
}
+ data.user = data.users[id]
render()
}