From d7a444d9ab597bf93f00183b28b4e8ca488dabc4 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Tue, 17 Dec 2013 16:10:32 -0500 Subject: [PATCH] dynamically update post count in post footer on new post --- public/src/forum/topic.js | 16 +++++++++++++++- public/templates/topic.tpl | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index 824ef1cfb8..424d12db2c 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -482,7 +482,21 @@ define(function() { adjust_rep(-1, data.pid, data.uid); }); - socket.on('event:new_post', createNewPosts); + socket.on('event:new_post', function(data) { + var posts = data.posts; + for (var p in posts) { + if (posts.hasOwnProperty(p)) { + var post = posts[p], + postcount = jQuery('.user_postcount_' + post.uid), + ptotal = parseInt(postcount.html(), 10); + + ptotal += 1; + postcount.html(ptotal); + } + } + + createNewPosts(data); + }); socket.on('event:topic_deleted', function(data) { if (data.tid === tid && data.status === 'ok') { diff --git a/public/templates/topic.tpl b/public/templates/topic.tpl index 7c21d1a849..a09ee029e5 100644 --- a/public/templates/topic.tpl +++ b/public/templates/topic.tpl @@ -109,7 +109,7 @@
- [[topic:reputation]]: {posts.user_rep} | [[topic:posts]]: {posts.user_postcount} + [[topic:reputation]]: {posts.user_rep} | [[topic:posts]]: {posts.user_postcount} {posts.additional_profile_info}