X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=956b3dfd9ce30b8057ab72eb724620653dbf007b;hb=3785277a0b89b63a40b7423d80ba779c84ac630e;hp=936ca57cdddc1fe8e73c73fa995c7dc8af705bce;hpb=954541600c80c270f43bf63f476b41ee499cfed3;p=Sone.git diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 936ca57..956b3df 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -454,6 +454,8 @@ function ajaxifyPost(postElement) { postReply(postId, text, function(success, error, replyId) { if (success) { loadNewReply(replyId); + markPostAsKnown(postElement); + markReplyAsKnown($(postElement).find(".reply")); $("#sone .post#" + postId + " .create-reply").addClass("hidden"); } else { alert(error); @@ -649,6 +651,24 @@ function loadNewReply(replyId) { }); } +function markPostAsKnown(postElements) { + $(postElements).each(function() { + postElement = this; + $.getJSON("ajax/markPostAsKnown.ajax", {"formPassword": getFormPassword(), "post": getPostId(postElement)}, function() { + $(postElement).removeClass("new"); + }); + }); +} + +function markReplyAsKnown(replyElements) { + $(replyElements).each(function() { + replyElement = this; + $.getJSON("ajax/markReplyAsKnown.ajax", {"formPassword": getFormPassword(), "reply": getReplyId(replyElement)}, function() { + $(replyElement).removeClass("new"); + }); + }); +} + /** * Creates a new notification. *