* @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 = {};
return false;
});
+ /* add “comment” link. */
+ addCommentLink(getPostId(postElement), postElement, $(postElement).find(".post-status-line .time"));
+
/* process all replies. */
$(postElement).find(".reply").each(function() {
ajaxifyReply(this);
});
});
- /* add “comment” link. */
- addCommentLink(getPostId(postElement), postElement);
+ /* 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));
+ });
}
/**
}
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;
+ })
});