X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=748213866eaf9498797b03aae9a5621f93cab5f4;hb=566268d3acfdf9e012fb966eee0e0ddc11953c3f;hp=59135afdbecdf109b4f7f879e95b059d8d197e69;hpb=56d8cf539156f5949ce33aebf784438c737f84b3;p=Sone.git diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 59135af..7482138 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -620,6 +620,26 @@ function isIndexPage() { return getPageId() == "index"; } +/** + * Returns whether the current page is a “view Sone” page. + * + * @returns {Boolean} true if the current page is a “view Sone” + * page, false otherwise + */ +function isViewSonePage() { + return getPageId() == "view-sone"; +} + +/** + * Returns the ID of the currently shown Sone. This will only return a sensible + * value if isViewSonePage() returns true. + * + * @returns The ID of the currently shown Sone + */ +function getSoneId() { + return $("#sone .sone-id").text(); +} + var loadedPosts = {}; var loadedReplies = {}; @@ -630,6 +650,9 @@ function loadNewPost(postId) { loadedPosts[postId] = true; $.getJSON("ajax/getPost.ajax", { "post" : postId }, function(data, textStatus) { if ((data != null) && data.success) { + if (!isIndexPage() && !(isViewSonePage() && (getSoneId() == data.post.sone))) { + return; + } var firstOlderPost = null; $("#sone .post").each(function() { if (getPostTime(this) < data.post.time) { @@ -641,7 +664,7 @@ function loadNewPost(postId) { if (firstOlderPost != null) { newPost.insertBefore(firstOlderPost); } else { - $("#sone #posts").append(newPost); + $("#sone .post:last").append(newPost); } ajaxifyPost(newPost); newPost.slideDown();