if (($(element).find(".show-reply-form").length > 0) || (getPostElement(element).find(".create-reply").length == 0)) {
return;
}
- commentElement = (function(postId, author) {
+ (function(postId, author, insertAfterThisElement) {
separator = $("<span> · </span>").addClass("separator");
- var commentElement = $("<div><span>Comment</span></div>").addClass("show-reply-form").click(function() {
- replyElement = $("#sone .post#" + postId + " .create-reply");
- replyElement.removeClass("hidden");
- replyElement.removeClass("light");
- (function(replyElement) {
- replyElement.find("input.reply-input").blur(function() {
- if ($(this).hasClass("default")) {
- replyElement.addClass("light");
- }
- }).focus(function() {
- replyElement.removeClass("light");
- });
- })(replyElement);
- textArea = replyElement.find("input.reply-input").focus().data("textarea");
- if (author != getCurrentSoneId()) {
- textArea.val(textArea.val() + "@sone://" + author + " ");
- }
+ getTranslation("WebInterface.Button.Comment", function(text) {
+ commentElement = $("<div><span>" + text + "</span></div>").addClass("show-reply-form").click(function() {
+ replyElement = $("#sone .post#post-" + postId + " .create-reply");
+ replyElement.removeClass("hidden");
+ replyElement.removeClass("light");
+ (function(replyElement) {
+ replyElement.find("input.reply-input").blur(function() {
+ if ($(this).hasClass("default")) {
+ replyElement.addClass("light");
+ }
+ }).focus(function() {
+ replyElement.removeClass("light");
+ });
+ })(replyElement);
+ textArea = replyElement.find("input.reply-input").focus().data("textarea");
+ if (author != getCurrentSoneId()) {
+ textArea.val(textArea.val() + "@sone://" + author + " ");
+ }
+ });
+ $(insertAfterThisElement).after(commentElement.clone(true));
+ $(insertAfterThisElement).after(separator);
});
- return commentElement;
- })(postId, author);
- $(insertAfterThisElement).after(commentElement.clone(true));
- $(insertAfterThisElement).after(separator);
+ })(postId, author, insertAfterThisElement);
}
var translations = {};
return;
}
if (data.success) {
- $("#sone .post#" + postId).slideUp();
+ $("#sone .post#post-" + postId).slideUp();
} else if (data.error == "invalid-post-id") {
/* pretend the post is already gone. */
getPost(postId).slideUp();
return;
}
if (data.success) {
- $("#sone .reply#" + replyId).slideUp();
+ $("#sone .reply#reply-" + replyId).slideUp();
} else if (data.error == "invalid-reply-id") {
/* pretend the reply is already gone. */
getReply(replyId).slideUp();
}
/**
+ * Returns the ID of the sone of the context menu that contains the given
+ * element.
+ *
+ * @param element
+ * The element within a context menu to get the Sone ID for
+ * @return The Sone ID
+ */
+function getMenuSone(element) {
+ return $(element).closest(".sone-menu").find(".sone-menu-id").text();
+}
+
+/**
* Generates a list of Sones by concatening the names of the given sones with a
* new line character (“\n”).
*
* @returns The element of the post
*/
function getPost(postId) {
- return $("#sone .post#" + postId);
+ return $("#sone .post#post-" + postId);
}
function getPostElement(element) {
}
function getPostId(element) {
- return getPostElement(element).attr("id");
+ return getPostElement(element).attr("id").substr(5);
}
function getPostTime(element) {
* @returns The element of the reply
*/
function getReply(replyId) {
- return $("#sone .reply#" + replyId);
+ return $("#sone .reply#reply-" + replyId);
}
function getReplyElement(element) {
}
function getReplyId(element) {
- return getReplyElement(element).attr("id");
+ return getReplyElement(element).attr("id").substr(6);
}
function getReplyTime(element) {
if ((data == null) || !data.success) {
return;
}
- $("#sone .post#" + postId + " > .inner-part > .status-line .like").addClass("hidden");
- $("#sone .post#" + postId + " > .inner-part > .status-line .unlike").removeClass("hidden");
+ $("#sone .post#post-" + postId + " > .inner-part > .status-line .like").addClass("hidden");
+ $("#sone .post#post-" + postId + " > .inner-part > .status-line .unlike").removeClass("hidden");
updatePostLikes(postId);
}, function(xmlHttpRequest, textStatus, error) {
/* ignore error. */
if ((data == null) || !data.success) {
return;
}
- $("#sone .post#" + postId + " > .inner-part > .status-line .unlike").addClass("hidden");
- $("#sone .post#" + postId + " > .inner-part > .status-line .like").removeClass("hidden");
+ $("#sone .post#post-" + postId + " > .inner-part > .status-line .unlike").addClass("hidden");
+ $("#sone .post#post-" + postId + " > .inner-part > .status-line .like").removeClass("hidden");
updatePostLikes(postId);
}, function(xmlHttpRequest, textStatus, error) {
/* ignore error. */
function updatePostLikes(postId) {
ajaxGet("getLikes.ajax", { "type": "post", "post": postId }, function(data, textStatus) {
if ((data != null) && data.success) {
- $("#sone .post#" + postId + " > .inner-part > .status-line .likes").toggleClass("hidden", data.likes == 0);
- $("#sone .post#" + postId + " > .inner-part > .status-line .likes span.like-count").text(data.likes);
- $("#sone .post#" + postId + " > .inner-part > .status-line .likes > span").attr("title", generateSoneList(data.sones));
+ $("#sone .post#post-" + postId + " > .inner-part > .status-line .likes").toggleClass("hidden", data.likes == 0);
+ $("#sone .post#post-" + postId + " > .inner-part > .status-line .likes span.like-count").text(data.likes);
+ $("#sone .post#post-" + postId + " > .inner-part > .status-line .likes > span").attr("title", generateSoneList(data.sones));
}
}, function(xmlHttpRequest, textStatus, error) {
/* ignore error. */
if ((data == null) || !data.success) {
return;
}
- $("#sone .reply#" + replyId + " .status-line .like").addClass("hidden");
- $("#sone .reply#" + replyId + " .status-line .unlike").removeClass("hidden");
+ $("#sone .reply#reply-" + replyId + " .status-line .like").addClass("hidden");
+ $("#sone .reply#reply-" + replyId + " .status-line .unlike").removeClass("hidden");
updateReplyLikes(replyId);
}, function(xmlHttpRequest, textStatus, error) {
/* ignore error. */
if ((data == null) || !data.success) {
return;
}
- $("#sone .reply#" + replyId + " .status-line .unlike").addClass("hidden");
- $("#sone .reply#" + replyId + " .status-line .like").removeClass("hidden");
+ $("#sone .reply#reply-" + replyId + " .status-line .unlike").addClass("hidden");
+ $("#sone .reply#reply-" + replyId + " .status-line .like").removeClass("hidden");
updateReplyLikes(replyId);
}, function(xmlHttpRequest, textStatus, error) {
/* ignore error. */
function updateReplyLikes(replyId) {
ajaxGet("getLikes.ajax", { "type": "reply", "reply": replyId }, function(data, textStatus) {
if ((data != null) && data.success) {
- $("#sone .reply#" + replyId + " .status-line .likes").toggleClass("hidden", data.likes == 0);
- $("#sone .reply#" + replyId + " .status-line .likes span.like-count").text(data.likes);
- $("#sone .reply#" + replyId + " .status-line .likes > span").attr("title", generateSoneList(data.sones));
+ $("#sone .reply#reply-" + replyId + " .status-line .likes").toggleClass("hidden", data.likes == 0);
+ $("#sone .reply#reply-" + replyId + " .status-line .likes span.like-count").text(data.likes);
+ $("#sone .reply#reply-" + replyId + " .status-line .likes > span").attr("title", generateSoneList(data.sones));
}
}, function(xmlHttpRequest, textStatus, error) {
/* ignore error. */
if (success) {
$(inputField).val("");
loadNewReply(replyId, soneId, postId);
- $("#sone .post#" + postId + " .create-reply").addClass("hidden");
- $("#sone .post#" + postId + " .create-reply .sender").hide();
- $("#sone .post#" + postId + " .create-reply .select-sender").show();
- $("#sone .post#" + postId + " .create-reply :input[name=sender]").val(getCurrentSoneId());
+ $("#sone .post#post-" + postId + " .create-reply").addClass("hidden");
+ $("#sone .post#post-" + postId + " .create-reply .sender").hide();
+ $("#sone .post#post-" + postId + " .create-reply .select-sender").show();
+ $("#sone .post#post-" + postId + " .create-reply :input[name=sender]").val(getCurrentSoneId());
} else {
alert(error);
}
/* convert “show source” link into javascript function. */
$(postElement).find(".show-source").each(function() {
$("a", this).click(function() {
+ post = getPostElement(this);
+ rawPostText = $(".post-text.raw-text", post);
+ rawPostText.toggleClass("hidden");
+ if (rawPostText.hasClass("hidden")) {
+ $(".post-text.short-text", post).removeClass("hidden");
+ $(".post-text.text", post).addClass("hidden");
+ $(".expand-post-text", post).removeClass("hidden");
+ $(".shrink-post-text", post).addClass("hidden");
+ } else {
+ $(".post-text.short-text", post).addClass("hidden");
+ $(".post-text.text", post).addClass("hidden");
+ $(".expand-post-text", post).addClass("hidden");
+ $(".shrink-post-text", post).addClass("hidden");
+ }
+ return false;
+ });
+ });
+
+ /* convert “show more” link into javascript function. */
+ $(postElement).find(".expand-post-text").each(function() {
+ $(this).click(function() {
+ $(".post-text.text", getPostElement(this)).toggleClass("hidden");
+ $(".post-text.short-text", getPostElement(this)).toggleClass("hidden");
+ $(".expand-post-text", getPostElement(this)).toggleClass("hidden");
+ $(".shrink-post-text", getPostElement(this)).toggleClass("hidden");
+ return false;
+ });
+ });
+ $(postElement).find(".shrink-post-text").each(function() {
+ $(this).click(function() {
$(".post-text.text", getPostElement(this)).toggleClass("hidden");
- $(".post-text.raw-text", getPostElement(this)).toggleClass("hidden");
+ $(".post-text.short-text", getPostElement(this)).toggleClass("hidden");
+ $(".expand-post-text", getPostElement(this)).toggleClass("hidden");
+ $(".shrink-post-text", getPostElement(this)).toggleClass("hidden");
return false;
});
});
+ /* ajaxify author/post links */
+ $(".post-status-line .permalink a", postElement).click(function() {
+ if (!$(".create-reply", postElement).hasClass("hidden")) {
+ textArea = $("input.reply-input", postElement).focus().data("textarea");
+ $(textArea).replaceSelection($(this).attr("href"));
+ }
+ return false;
+ });
+
/* add “comment” link. */
addCommentLink(getPostId(postElement), getPostAuthor(postElement), postElement, $(postElement).find(".post-status-line .permalink-author"));
});
/* mark everything as known on click. */
- $(postElement).click(function(event) {
- if ($(event.target).hasClass("click-to-show")) {
- return false;
- }
- markPostAsKnown(this);
- });
+ (function(postElement) {
+ $(postElement).click(function(event) {
+ if ($(event.target).hasClass("click-to-show")) {
+ return false;
+ }
+ markPostAsKnown(postElement, false);
+ });
+ })(postElement);
/* hide reply input field. */
$(postElement).find(".create-reply").addClass("hidden");
+
+ /* show Sone menu when hovering over the avatar. */
+ $(postElement).find(".post-avatar").mouseover(function() {
+ if (typeof currentSoneMenuTimeoutHandler != undefined) {
+ clearTimeout(currentSoneMenuTimeoutHandler);
+ }
+ currentSoneMenuId = getPostId(this);
+ currentSoneMenuTimeoutHandler = setTimeout(function() {
+ $(".sone-menu:visible").fadeOut();
+ $(".sone-post-menu", postElement).mouseleave(function() {
+ $(this).fadeOut();
+ }).fadeIn();
+ }, 1000);
+ }).mouseleave(function() {
+ if (currentSoneMenuId = getPostId(this)) {
+ clearTimeout(currentSoneMenuTimeoutHandler);
+ }
+ });
+ (function(postElement) {
+ var soneId = $(".sone-menu-id:first", postElement).text();
+ $(".sone-post-menu .follow", postElement).click(function() {
+ var followElement = this;
+ ajaxGet("followSone.ajax", { "sone": soneId, "formPassword": getFormPassword() }, function() {
+ $(followElement).addClass("hidden");
+ $(followElement).parent().find(".unfollow").removeClass("hidden");
+ $("#sone .sone-menu").each(function() {
+ if (getMenuSone(this) == soneId) {
+ $(".follow", this).toggleClass("hidden", true);
+ $(".unfollow", this).toggleClass("hidden", false);
+ }
+ });
+ });
+ return false;
+ });
+ $(".sone-post-menu .unfollow", postElement).click(function() {
+ var unfollowElement = this;
+ ajaxGet("unfollowSone.ajax", { "sone": soneId, "formPassword": getFormPassword() }, function() {
+ $(unfollowElement).addClass("hidden");
+ $(unfollowElement).parent().find(".follow").removeClass("hidden");
+ $("#sone .sone-menu").each(function() {
+ if (getMenuSone(this) == soneId) {
+ $(".follow", this).toggleClass("hidden", false);
+ $(".unfollow", this).toggleClass("hidden", true);
+ }
+ });
+ });
+ return false;
+ });
+ })(postElement);
}
/**
});
});
})(replyElement);
+
+ /* ajaxify author links */
+ $(".reply-status-line .permalink a", replyElement).click(function() {
+ if (!$(".create-reply", getPostElement(replyElement)).hasClass("hidden")) {
+ textArea = $("input.reply-input", getPostElement(replyElement)).focus().data("textarea");
+ $(textArea).replaceSelection($(this).attr("href"));
+ }
+ return false;
+ });
+
addCommentLink(getPostId(replyElement), getReplyAuthor(replyElement), replyElement, $(replyElement).find(".reply-status-line .permalink-author"));
/* convert “show source” link into javascript function. */
$(replyElement).find(".show-reply-source").each(function() {
$("a", this).click(function() {
+ reply = getReplyElement(this);
+ rawReplyText = $(".reply-text.raw-text", reply);
+ rawReplyText.toggleClass("hidden");
+ if (rawReplyText.hasClass("hidden")) {
+ $(".reply-text.short-text", reply).removeClass("hidden");
+ $(".reply-text.text", reply).addClass("hidden");
+ $(".expand-reply-text", reply).removeClass("hidden");
+ $(".shrink-reply-text", reply).addClass("hidden");
+ } else {
+ $(".reply-text.short-text", reply).addClass("hidden");
+ $(".reply-text.text", reply).addClass("hidden");
+ $(".expand-reply-text", reply).addClass("hidden");
+ $(".shrink-reply-text", reply).addClass("hidden");
+ }
+ return false;
+ });
+ });
+
+ /* convert “show more” link into javascript function. */
+ $(replyElement).find(".expand-reply-text").each(function() {
+ $(this).click(function() {
$(".reply-text.text", getReplyElement(this)).toggleClass("hidden");
- $(".reply-text.raw-text", getReplyElement(this)).toggleClass("hidden");
+ $(".reply-text.short-text", getReplyElement(this)).toggleClass("hidden");
+ $(".expand-reply-text", getReplyElement(this)).toggleClass("hidden");
+ $(".shrink-reply-text", getReplyElement(this)).toggleClass("hidden");
+ return false;
+ });
+ });
+ $(replyElement).find(".shrink-reply-text").each(function() {
+ $(this).click(function() {
+ $(".reply-text.text", getReplyElement(this)).toggleClass("hidden");
+ $(".reply-text.short-text", getReplyElement(this)).toggleClass("hidden");
+ $(".expand-reply-text", getReplyElement(this)).toggleClass("hidden");
+ $(".shrink-reply-text", getReplyElement(this)).toggleClass("hidden");
return false;
});
});
untrustSone(getReplyAuthor(this));
return false;
});
+
+ /* show Sone menu when hovering over the avatar. */
+ $(replyElement).find(".reply-avatar").mouseover(function() {
+ if (typeof currentSoneMenuTimeoutHandler != undefined) {
+ clearTimeout(currentSoneMenuTimeoutHandler);
+ }
+ currentSoneMenuId = getPostId(this) + "-" + getReplyId(this);
+ currentSoneMenuTimeoutHandler = setTimeout(function() {
+ $(".sone-menu:visible").fadeOut();
+ $(".sone-reply-menu", replyElement).mouseleave(function() {
+ $(this).fadeOut();
+ }).fadeIn();
+ }, 1000);
+ }).mouseleave(function() {
+ if (currentSoneMenuId = getPostId(this) + "-" + getReplyId(this)) {
+ clearTimeout(currentSoneMenuTimeoutHandler);
+ }
+ });
+ (function(replyElement) {
+ var soneId = $(".sone-menu-id", replyElement).text();
+ $(".sone-menu .follow", replyElement).click(function() {
+ var followElement = this;
+ ajaxGet("followSone.ajax", { "sone": soneId, "formPassword": getFormPassword() }, function() {
+ $(followElement).addClass("hidden");
+ $(followElement).parent().find(".unfollow").removeClass("hidden");
+ $("#sone .sone-menu").each(function() {
+ if (getMenuSone(this) == soneId) {
+ $(".follow", this).toggleClass("hidden", true);
+ $(".unfollow", this).toggleClass("hidden", false);
+ }
+ });
+ });
+ return false;
+ });
+ $(".sone-menu .unfollow", replyElement).click(function() {
+ var unfollowElement = this;
+ ajaxGet("unfollowSone.ajax", { "sone": soneId, "formPassword": getFormPassword() }, function() {
+ $(unfollowElement).addClass("hidden");
+ $(unfollowElement).parent().find(".follow").removeClass("hidden");
+ $("#sone .sone-menu").each(function() {
+ if (getMenuSone(this) == soneId) {
+ $(".follow", this).toggleClass("hidden", false);
+ $(".unfollow", this).toggleClass("hidden", true);
+ }
+ });
+ });
+ return false;
+ });
+ })(replyElement);
}
/**
notification.find(".text").addClass("hidden");
}
notification.find("form.mark-as-read button").click(function() {
- ajaxGet("markAsKnown.ajax", {"formPassword": getFormPassword(), "type": $(":input[name=type]", this.form).val(), "id": $(":input[name=id]", this.form).val()});
+ allIds = $(":input[name=id]", this.form).val().split(" ");
+ for (var index = 0; index < allIds.length; index += 16) {
+ ids = allIds.slice(index, index + 16).join(" ");
+ ajaxGet("markAsKnown.ajax", {"formPassword": getFormPassword(), "type": $(":input[name=type]", this.form).val(), "id": ids});
+ }
});
notification.find("a[class^='link-']").each(function() {
linkElement = $(this);
}
/**
+ * Returns the notification hash. This hash is used in {@link #getStatus()} to
+ * determine whether the notifications changed and need to be reloaded.
+ */
+function getNotificationHash() {
+ return $("#sone #notification-area #notification-hash").text();
+}
+
+/**
+ * Sets the notification hash.
+ *
+ * @param notificationHash
+ * The new notification hash
+ */
+function setNotificationHash(notificationHash) {
+ $("#sone #notification-area #notification-hash").text(notificationHash);
+}
+
+/**
* Retrieves element IDs from notification elements.
*
* @param notification
* The new notification element
*/
function checkForRemovedReplies(oldNotification, newNotification) {
- if (getNotificationId(oldNotification) != "new-replies-notification") {
+ if (getNotificationId(oldNotification) != "new-reply-notification") {
return;
}
oldIds = getElementIds(oldNotification, ".reply-id");
if (!notLoggedIn) {
showOfflineMarker(!online);
}
+ if (data.notificationHash != getNotificationHash()) {
+ console.log("Old hash: ", getNotificationHash(), ", new hash: ", data.notificationHash);
+ requestNotifications();
+ }
+ /* process new posts. */
+ $.each(data.newPosts, function(index, value) {
+ loadNewPost(value.id, value.sone, value.recipient, value.time);
+ });
+ /* process new replies. */
+ $.each(data.newReplies, function(index, value) {
+ loadNewReply(value.id, value.sone, value.post, value.postSone);
+ });
+ /* do it again in 5 seconds. */
+ setTimeout(getStatus, 5000);
+ } else {
+ /* data.success was false, wait 30 seconds. */
+ setTimeout(getStatus, 30000);
+ }
+ }, function() {
+ statusRequestQueued = false;
+ ajaxError();
+ });
+}
+
+function requestNotifications() {
+ ajaxGet("getNotifications.ajax", {}, function(data, textStatus) {
+ if (data && data.success) {
/* search for removed notifications. */
$("#sone #notification-area .notification").each(function() {
notificationId = $(this).attr("id");
}
});
if (!foundNotification) {
- if (notificationId == "new-sone-notification") {
+ if (notificationId == "new-sone-notification" && (data.options["ShowNotification/NewSones"] == true)) {
$(".new-sone-id", this).each(function(index, element) {
soneId = $(this).text();
markSoneAsKnown(getSone(soneId), true);
});
- } else if (notificationId == "new-post-notification") {
+ } else if (notificationId == "new-post-notification" && (data.options["ShowNotification/NewPosts"] == true)) {
$(".post-id", this).each(function(index, element) {
postId = $(this).text();
markPostAsKnown(getPost(postId), true);
});
- } else if (notificationId == "new-replies-notification") {
+ } else if (notificationId == "new-reply-notification" && (data.options["ShowNotification/NewReplies"] == true)) {
$(".reply-id", this).each(function(index, element) {
replyId = $(this).text();
markReplyAsKnown(getReply(replyId), true);
}
});
/* process notifications. */
- notificationIds = [];
$.each(data.notifications, function(index, value) {
oldNotification = getNotification(value.id);
- if ((oldNotification.length == 0) || (value.lastUpdatedTime > getNotificationLastUpdatedTime(oldNotification))) {
- notificationIds.push(value.id);
+ notification = ajaxifyNotification(createNotification(value.id, value.lastUpdatedTime, value.text, value.dismissable)).hide();
+ if (oldNotification.length != 0) {
+ if ((oldNotification.find(".short-text").length > 0) && (notification.find(".short-text").length > 0)) {
+ opened = oldNotification.is(":visible") && oldNotification.find(".short-text").hasClass("hidden");
+ notification.find(".short-text").toggleClass("hidden", opened);
+ notification.find(".text").toggleClass("hidden", !opened);
+ }
+ checkForRemovedSones(oldNotification, notification);
+ checkForRemovedPosts(oldNotification, notification);
+ checkForRemovedReplies(oldNotification, notification);
+ oldNotification.replaceWith(notification.show());
+ } else {
+ $("#sone #notification-area").append(notification);
+ if (value.id.substring(0, 5) != "local") {
+ notification.slideDown();
+ setActivity();
+ }
}
});
- if (notificationIds.length > 0) {
- loadNotifications(notificationIds);
- }
- /* process new posts. */
- $.each(data.newPosts, function(index, value) {
- loadNewPost(value.id, value.sone, value.recipient, value.time);
- });
- /* process new replies. */
- $.each(data.newReplies, function(index, value) {
- loadNewReply(value.id, value.sone, value.post, value.postSone);
- });
- /* do it again in 5 seconds. */
- setTimeout(getStatus, 5000);
- } else {
- /* data.success was false, wait 30 seconds. */
- setTimeout(getStatus, 30000);
- }
- }, function() {
- statusRequestQueued = false;
- ajaxError();
- });
-}
-
-/**
- * Requests multiple notifications from Sone and displays them.
- *
- * @param notificationIds
- * Array of IDs of the notifications to load
- */
-function loadNotifications(notificationIds) {
- ajaxGet("getNotification.ajax", {"notifications": notificationIds.join(",")}, function(data, textStatus) {
- if (!data || !data.success) {
- // TODO - show error
- return;
+ setNotificationHash(data.notificationHash);
}
- $.each(data.notifications, function(index, value) {
- oldNotification = getNotification(value.id);
- notification = ajaxifyNotification(createNotification(value.id, value.lastUpdatedTime, value.text, value.dismissable)).hide();
- if (oldNotification.length != 0) {
- if ((oldNotification.find(".short-text").length > 0) && (notification.find(".short-text").length > 0)) {
- opened = oldNotification.is(":visible") && oldNotification.find(".short-text").hasClass("hidden");
- notification.find(".short-text").toggleClass("hidden", opened);
- notification.find(".text").toggleClass("hidden", !opened);
- }
- checkForRemovedSones(oldNotification, notification);
- checkForRemovedPosts(oldNotification, notification);
- checkForRemovedReplies(oldNotification, notification);
- oldNotification.replaceWith(notification.show());
- } else {
- $("#sone #notification-area").append(notification);
- notification.slideDown();
- setActivity();
- }
- });
});
}
* @returns The ID of the currently shown Sone
*/
function getShownSoneId() {
- return $("#sone .sone-id").text();
+ return $("#sone .sone-id").first().text();
}
/**
* exists on the page, <code>false</code> otherwise
*/
function hasPost(postId) {
- return $(".post#" + postId).length > 0;
+ return $(".post#post-" + postId).length > 0;
}
/**
* exists on the page, <code>false</code> otherwise
*/
function hasReply(replyId) {
- return $("#sone .reply#" + replyId).length > 0;
+ return $("#sone .reply#reply-" + replyId).length > 0;
}
function loadNewPost(postId, soneId, recipientId, time) {
newPost = $(data.post.html).addClass("hidden");
if ($(".post-author-local", newPost).text() == "true") {
newPost.removeClass("new");
- (function(newPost) {
- setTimeout(function() {
- markPostAsKnown(newPost, false);
- }, 5000);
- })(newPost);
}
if (firstOlderPost != null) {
newPost.insertBefore(firstOlderPost);
if (hasReply(data.reply.id)) {
return;
}
- $("#sone .post#" + data.reply.postId).each(function() {
+ $("#sone .post#post-" + data.reply.postId).each(function() {
var firstNewerReply = null;
$(this).find(".replies .reply").each(function() {
if (getReplyTime(this) > data.reply.time) {
}
});
newReply = $(data.reply.html).addClass("hidden");
- if ($(".reply-author-local", newPost).text() == "true") {
- newPost.removeClass("new");
+ if ($(".reply-author-local", newReply).text() == "true") {
+ newReply.removeClass("new");
(function(newReply) {
setTimeout(function() {
markReplyAsKnown(newReply, false);
$(soneElement).removeClass("new");
if ((typeof skipRequest == "undefined") || !skipRequest) {
ajaxGet("markAsKnown.ajax", {"formPassword": getFormPassword(), "type": "sone", "id": getSoneId(soneElement)});
+ requestNotifications();
}
}
}
function markPostAsKnown(postElements, skipRequest) {
$(postElements).each(function() {
postElement = this;
- if ($(postElement).hasClass("new") || ((typeof skipRequest != "undefined") && !skipRequest)) {
+ if ($(postElement).hasClass("new") || ((typeof skipRequest != "undefined"))) {
(function(postElement) {
$(postElement).removeClass("new");
if ((typeof skipRequest == "undefined") || !skipRequest) {
ajaxGet("markAsKnown.ajax", {"formPassword": getFormPassword(), "type": "post", "id": getPostId(postElement)});
+ requestNotifications();
}
})(postElement);
}
$(".click-to-show", postElement).removeClass("new");
});
- markReplyAsKnown($(postElements).find(".reply"));
+ markReplyAsKnown($(postElements).find(".reply"), true);
}
function markReplyAsKnown(replyElements, skipRequest) {
$(replyElements).each(function() {
replyElement = this;
- if ($(replyElement).hasClass("new") || ((typeof skipRequest != "undefined") && !skipRequest)) {
+ if ($(replyElement).hasClass("new") || ((typeof skipRequest != "undefined"))) {
(function(replyElement) {
$(replyElement).removeClass("new");
if ((typeof skipRequest == "undefined") || !skipRequest) {
ajaxGet("markAsKnown.ajax", {"formPassword": getFormPassword(), "type": "reply", "id": getReplyId(replyElement)});
+ requestNotifications();
}
})(replyElement);
}
var initiallyLoggedIn = $("#sone #loggedIn").text() == "true";
var notLoggedIn = !initiallyLoggedIn;
+/** ID of the next-to-show Sone context menu. */
+var currentSoneMenuId;
+
+/** Timeout handler for the next-to-show Sone context menu. */
+var currentSoneMenuTimeoutHandler;
+
$(document).ready(function() {
/* this initializes the status update input field. */
getTranslation("WebInterface.Confirmation.DeletePostButton", function(text) {
getTranslation("WebInterface.Confirmation.DeleteReplyButton", function(text) {
getTranslation("WebInterface.DefaultText.Reply", function(text) {
- $("#sone .post").each(function() {
- ajaxifyPost(this);
+ getTranslation("WebInterface.Button.Comment", function(text) {
+ $("#sone .post").each(function() {
+ ajaxifyPost(this);
+ });
});
});
});
ajaxifyNotification($(this));
});
- /* disable all permalinks. */
- $(".permalink").click(function() {
- return false;
- });
-
/* activate status polling. */
setTimeout(getStatus, 5000);