commentElement = (function(postId, author) {
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 = $("#sone .post#post-" + postId + " .create-reply");
replyElement.removeClass("hidden");
replyElement.removeClass("light");
(function(replyElement) {
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 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);
}
* 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) {
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) {