X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=0e33c857bab064d11375fbc3579ee2d157de146a;hb=2d994a9a80337e9dcc0285e8887924bc74bc9f1f;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..0e33c85 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -299,7 +299,7 @@ function getPostId(element) { } function getPostTime(element) { - return getPostElement(element).find(".storage-time").text(); + return getPostElement(element).find(".post-time").text(); } function getReplyElement(element) { @@ -311,7 +311,7 @@ function getReplyId(element) { } function getReplyTime(element) { - return getReplyElement(element).find(".storage-time").text(); + return getReplyElement(element).find(".reply-time").text(); } function likePost(postId) { @@ -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,25 @@ function loadNewReply(replyId) { }); } +function markPostAsKnown(postElements) { + $(postElements).each(function() { + postElement = this; + $.getJSON("ajax/markPostAsKnown.ajax", {"formPassword": getFormPassword(), "post": getPostId(postElement)}, function() { + $(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"); + }); + }); +} + /** * Creates a new notification. *