* @param element
* The element to add a “comment” link to
*/
-function addCommentLink(postId, element) {
+function addCommentLink(postId, element, insertAfterThisElement) {
if ($(element).find(".show-reply-form").length > 0) {
return;
}
});
return commentElement;
})(postId);
- $(element).find(".status-line .time").each(function() {
- $(this).after(commentElement.clone(true));
- });
+ $(insertAfterThisElement).after(commentElement.clone(true));
}
var translations = {};
});
});
+ /* mark everything as known on click. */
+ $(postElement).click(function() {
+ markPostAsKnown(this);
+ });
+
/* hide reply input field. */
$(postElement).find(".create-reply").addClass("hidden");
}
});
});
})(replyElement);
- addCommentLink(getPostId(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));
+ });
}
/**
return false;
}
});
- newPost = $(data.post.html).addClass("hidden");
+ newPost = $(data.post.html).addClass("hidden").click(function() {
+ markPostAsKnown(this);
+ });
if (firstOlderPost != null) {
newPost.insertBefore(firstOlderPost);
} else {
return false;
}
});
- newReply = $(data.reply.html).addClass("hidden");
+ newReply = $(data.reply.html).addClass("hidden").click(function() {
+ markPostAsKnown(getPostElement(this));
+ });
if (firstNewerReply != null) {
newReply.insertBefore(firstNewerReply);
} else {
}
function setActivity() {
- title = document.title;
- if (title.indexOf('(') != 0) {
- document.title = "(!) " + title;
+ if (!focus) {
+ title = document.title;
+ if (title.indexOf('(') != 0) {
+ document.title = "(!) " + title;
+ }
}
}
// EVERYTHING BELOW HERE IS EXECUTED AFTER LOADING THE PAGE
//
+var focus = true;
+
$(document).ready(function() {
/* this initializes the status update input field. */
/* reset activity counter when the page has focus. */
$(window).focus(function() {
+ focus = true;
resetActivity();
- });
+ }).blur(function() {
+ focus = false;
+ })
});