Add methods to extract the time of posts and replies.
[Sone.git] / src / main / resources / static / javascript / sone.js
index b8be6b3..a039211 100644 (file)
@@ -282,7 +282,7 @@ function generateSoneList(sones) {
        var soneList = "";
        $.each(sones, function() {
                if (soneList != "") {
-                       soneList += "\n";
+                       soneList += "";
                }
                soneList += this.name;
        });
@@ -301,13 +301,17 @@ function getSoneId(element) {
 }
 
 function getPostElement(element) {
-       return $(element).parents(".post");
+       return $(element).hasClass("post") ? $(element) : $(element).parents(".post");
 }
 
 function getPostId(element) {
        return getPostElement(element).attr("id");
 }
 
+function getPostTime(element) {
+       return getPostElement(element).find(".storage-time").text();
+}
+
 function getReplyElement(element) {
        return $(element).parents(".reply");
 }
@@ -316,6 +320,10 @@ function getReplyId(element) {
        return getReplyElement(element).attr("id");
 }
 
+function getReplyTime(element) {
+       return getReplyElement(element).find(".storage-time").text();
+}
+
 function likePost(postId) {
        $.getJSON("ajax/like.ajax", { "type": "post", "post" : postId, "formPassword": getFormPassword() }, function(data, textStatus) {
                if ((data == null) || !data.success) {