X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=7d7bcb557b0c07dd49a965a59f17f5933ea851fa;hb=e8411efc4eaff6418cad496eb34fd7bc260eb9cd;hp=f195d5943a43b466d171baa97ed55bea236a45a1;hpb=46ad26b66e978c531f563a51a4ff6a2908816947;p=Sone.git diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index f195d59..7d7bcb5 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -497,6 +497,11 @@ function ajaxifyPost(postElement) { }); }); + /* mark everything as known on click. */ + $(postElement).click(function() { + markPostAsKnown(this); + }); + /* hide reply input field. */ $(postElement).find(".create-reply").addClass("hidden"); } @@ -526,6 +531,11 @@ function ajaxifyReply(replyElement) { }); })(replyElement); addCommentLink(getPostId(replyElement), replyElement, $(replyElement).find(".reply-status-line .time")); + + /* mark post and all replies as known on click. */ + $(replyElement).click(function() { + markPostAsKnown(getPostElement(replyElement)); + }); } /** @@ -601,6 +611,10 @@ function loadNewPost(postId) { loadedPosts[postId] = true; $.getJSON("ajax/getPost.ajax", { "post" : postId }, function(data, textStatus) { if ((data != null) && data.success) { + /* maybe weird timing stuff ensues. */ + if (data.post.id in loadedPosts) { + return; + } var firstOlderPost = null; $("#sone .post").each(function() { if (getPostTime(this) < data.post.time) { @@ -608,7 +622,6 @@ function loadNewPost(postId) { return false; } }); - newPost = $(data.post.html).addClass("hidden"); if (firstOlderPost != null) { newPost.insertBefore(firstOlderPost); } else { @@ -629,6 +642,10 @@ function loadNewReply(replyId) { $.getJSON("ajax/getReply.ajax", { "reply": replyId }, function(data, textStatus) { /* find post. */ if ((data != null) && data.success) { + /* maybe weird timing stuff ensues. */ + if (data.reply.id in loadedReplies) { + return; + } $("#sone .post#" + data.reply.postId).each(function() { var firstNewerReply = null; $(this).find(".replies .reply").each(function() { @@ -637,7 +654,6 @@ function loadNewReply(replyId) { return false; } }); - newReply = $(data.reply.html).addClass("hidden"); if (firstNewerReply != null) { newReply.insertBefore(firstNewerReply); } else { @@ -690,9 +706,11 @@ function resetActivity() { } function setActivity() { - title = document.title; - if (title.indexOf('(') != 0) { - document.title = "(!) " + title; + if (!focus) { + title = document.title; + if (title.indexOf('(') != 0) { + document.title = "(!) " + title; + } } } @@ -722,6 +740,8 @@ function createNotification(id, text, dismissable) { // EVERYTHING BELOW HERE IS EXECUTED AFTER LOADING THE PAGE // +var focus = true; + $(document).ready(function() { /* this initializes the status update input field. */ @@ -824,7 +844,10 @@ $(document).ready(function() { /* reset activity counter when the page has focus. */ $(window).focus(function() { + focus = true; resetActivity(); - }); + }).blur(function() { + focus = false; + }) });