diff --git a/boards/static/js/thread_update.js b/boards/static/js/thread_update.js --- a/boards/static/js/thread_update.js +++ b/boards/static/js/thread_update.js @@ -55,11 +55,18 @@ function updateThread() { .success(function(data) { var bottom = isPageBottom(); + var lastUpdate = ''; + var addedPosts = data.added; for (var i = 0; i < addedPosts.length; i++) { var postText = addedPosts[i]; var post = $(postText); + + if (lastUpdate === '') { + lastUpdate = post.find('.pub_time').text(); + } + post.appendTo(lastPost.parent()); addRefLinkPreview(post[0]); @@ -72,6 +79,11 @@ function updateThread() { var postText = updatedPosts[i]; var post = $(postText); + + if (lastUpdate === '') { + lastUpdate = post.find('.pub_time').text(); + } + var postId = post.attr('id'); var oldPost = $('div.thread').children('.post[id=' + postId + ']'); @@ -81,7 +93,7 @@ function updateThread() { blink(post); } - + // TODO Process deleted posts lastUpdateTime = data.last_update; @@ -92,8 +104,11 @@ function updateThread() { $target.animate({scrollTop: $target.height()}, 1000); } - $('#reply-count').text(getReplyCount()); - $('#image-count').text(getImageCount()); + var hasPostChanges = (updatedPosts.length > 0) + || (addedPosts.length > 0); + if (hasPostChanges) { + updateMetadataPanel(lastUpdate); + } updateBumplimitProgress(data.added.length); updatePostBumpableStatus(); @@ -132,6 +147,23 @@ function getImageCount() { return $('.thread').find('img').length } +function updateMetadataPanel(lastUpdate) { + var replyCountField = $('#reply-count'); + var imageCountField = $('#image-count'); + + replyCountField.text(getReplyCount()); + imageCountField.text(getImageCount()); + + if (lastUpdate !== '') { + var lastUpdateField = $('#last-update'); + lastUpdateField.text(lastUpdate); + blink(lastUpdateField); + } + + blink(replyCountField); + blink(imageCountField); +} + /** * Update bumplimit progress bar */ @@ -158,12 +190,10 @@ function updateBumplimitProgress(postDel * If the bumplimit is reached, add dead_post class to all posts */ function updatePostBumpableStatus() { - var postCount = getReplyCount(); var postsToLimitElement = $('#left_to_limit'); - var postsToLimit = parseInt(postsToLimitElement.text()); - if (postsToLimit <= 0) { - $('.thread').find('.post').addClass('dead_post'); + if (postsToLimitElement === null) { + $('.thread').children('.post').addClass('dead_post'); } } @@ -227,10 +257,9 @@ function resetForm(form) { } else { var errors = json.errors; for (var i = 0; i < errors.length; i++) { - var error = errors[i]; + var fieldErrors = errors[i]; - var fieldName = error.field; - var error = error.errors; + var error = fieldErrors.errors; var errorList = $('
' + error + '
'); diff --git a/boards/templates/boards/post.html b/boards/templates/boards/post.html --- a/boards/templates/boards/post.html +++ b/boards/templates/boards/post.html @@ -28,8 +28,8 @@