X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=32ad68320bdbded8a597147233f2bedd886d7a4b;hb=2beccb575d2baf1d0e9e41acc77fe742b8517ecd;hp=619b62e7ee7254fbb37f852126db1912b20ccfb1;hpb=08e3bf47ecb5699c13307dece92fc0bc36947b55;p=Sone.git diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 619b62e..32ad683 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -69,6 +69,7 @@ function addCommentLink(postId, element) { } commentElement = (function(postId) { var commentElement = $("
Comment
").addClass("show-reply-form").click(function() { + markPostAsKnown(getPostElement(this)); replyElement = $("#sone .post#" + postId + " .create-reply"); replyElement.removeClass("hidden"); replyElement.removeClass("light"); @@ -454,8 +455,7 @@ function ajaxifyPost(postElement) { postReply(postId, text, function(success, error, replyId) { if (success) { loadNewReply(replyId); - markPostAsKnown(postElement); - markReplyAsKnown($(postElement).find(".reply")); + markPostAsKnown(getPostElement(inputField)); $("#sone .post#" + postId + " .create-reply").addClass("hidden"); } else { alert(error); @@ -475,10 +475,12 @@ function ajaxifyPost(postElement) { /* convert all “like” buttons to javascript functions. */ $(postElement).find(".like-post").submit(function() { likePost(getPostId(this)); + markPostAsKnown(getPostElement(this)); return false; }); $(postElement).find(".unlike-post").submit(function() { unlikePost(getPostId(this)); + markPostAsKnown(getPostElement(this)); return false; }); @@ -511,10 +513,12 @@ function ajaxifyPost(postElement) { function ajaxifyReply(replyElement) { $(replyElement).find(".like-reply").submit(function() { likeReply(getReplyId(this)); + markPostAsKnown(getPostElement(this)); return false; }); $(replyElement).find(".unlike-reply").submit(function() { unlikeReply(getReplyId(this)); + markPostAsKnown(getPostElement(this)); return false; }); (function(replyElement) { @@ -654,18 +658,23 @@ function loadNewReply(replyId) { function markPostAsKnown(postElements) { $(postElements).each(function() { postElement = this; - $.getJSON("ajax/markPostAsKnown.ajax", {"formPassword": getFormPassword(), "post": getPostId(postElement)}, function() { - $(postElement).removeClass("new"); - }); + if ($(postElement).hasClass("new")) { + $.getJSON("ajax/markPostAsKnown.ajax", {"formPassword": getFormPassword(), "post": getPostId(postElement)}, function(data, textStatus) { + $(postElement).removeClass("new"); + }); + } }); + markReplyAsKnown($(postElements).find(".reply")); } function markReplyAsKnown(replyElements) { $(replyElements).each(function() { replyElement = this; - $.getJSON("ajax/markReplyAsKnown.ajax", {"formPassword": getFormPassword(), "reply": getReplyId(replyElement)}, function() { - $(replyElement).removeClass("new"); - }); + if ($(replyElement).hasClass("new")) { + $.getJSON("ajax/markReplyAsKnown.ajax", {"formPassword": getFormPassword(), "reply": getReplyId(replyElement)}, function(data, textStatus) { + $(replyElement).removeClass("new"); + }); + } }); }