diff --git a/js/posts.js b/js/posts.js index f3a757d..541f580 100644 --- a/js/posts.js +++ b/js/posts.js @@ -149,8 +149,10 @@ async function createPost(username,text,time,specialtext,postid,isbot,reply_id,a avatar.width=25; avatar.height=25; avatar.classList.add("avatar") - - avatar.src = avatar_src + if(avatar_src)avatar.src = "/avatars/"+avatar_src + else { + avatar.src = "/images/default_avatar.png" + } newA.appendChild(avatar) newA.appendChild(newUsername) @@ -183,7 +185,11 @@ async function createPost(username,text,time,specialtext,postid,isbot,reply_id,a replyAvatar.width=10; replyAvatar.height=10; replyAvatar.classList.add("avatar") - replyAvatar.src = "/avatars/"+reply_obj.User_Avatar + + if(reply_obj.User_Avatar)replyAvatar.src = "/avatars/"+reply_obj.User_Avatar + else { + replyAvatar.src = "/images/default_avatar.png" + } replyA.appendChild(replyAvatar) replyA.appendChild(reply_username_text) @@ -242,7 +248,7 @@ async function main(){ highest_id = all_posts[0].post_id for(i in all_posts) { let item = all_posts[i] - await createPost(decURIComp(item.post_user_name),decURIComp(item.post_text),item.post_time,item.post_special_text,item.post_id,item.post_from_bot,item.post_reply_id,false,"/avatars/"+item.User_Avatar) + await createPost(decURIComp(item.post_user_name),decURIComp(item.post_text),item.post_time,item.post_special_text,item.post_id,item.post_from_bot,item.post_reply_id,false,item.User_Avatar) } let links = document.getElementsByClassName("insertedlink")