X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=75facb347af12712e821948e024dc9c5010d8a93;hb=a57e3b33c5837a40aa08c11fb92f600d928be1ab;hp=7d7bcb557b0c07dd49a965a59f17f5933ea851fa;hpb=2dab45dd964a48144d8c919b491f792b53f5a2ea;p=Sone.git diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 7d7bcb5..75facb3 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -611,10 +611,6 @@ function loadNewPost(postId) { loadedPosts[postId] = true; $.getJSON("ajax/getPost.ajax", { "post" : postId }, function(data, textStatus) { if ((data != null) && data.success) { - /* maybe weird timing stuff ensues. */ - if (data.post.id in loadedPosts) { - return; - } var firstOlderPost = null; $("#sone .post").each(function() { if (getPostTime(this) < data.post.time) { @@ -622,6 +618,7 @@ function loadNewPost(postId) { return false; } }); + newPost = $(data.post.html).addClass("hidden"); if (firstOlderPost != null) { newPost.insertBefore(firstOlderPost); } else { @@ -642,10 +639,6 @@ function loadNewReply(replyId) { $.getJSON("ajax/getReply.ajax", { "reply": replyId }, function(data, textStatus) { /* find post. */ if ((data != null) && data.success) { - /* maybe weird timing stuff ensues. */ - if (data.reply.id in loadedReplies) { - return; - } $("#sone .post#" + data.reply.postId).each(function() { var firstNewerReply = null; $(this).find(".replies .reply").each(function() { @@ -654,6 +647,7 @@ function loadNewReply(replyId) { return false; } }); + newReply = $(data.reply.html).addClass("hidden"); if (firstNewerReply != null) { newReply.insertBefore(firstNewerReply); } else { @@ -759,6 +753,21 @@ $(document).ready(function() { }); }); + /* ajaxify input field on “view Sone” page. */ + getTranslation("WebInterface.DefaultText.Message", function(defaultText) { + registerInputTextareaSwap("#sone #post-message input[name=text]", defaultText, "text", false, false); + $("#sone #post-message").submit(function() { + text = $(this).find(":input:enabled").val(); + $.getJSON("ajax/createPost.ajax", { "formPassword": getFormPassword(), "recipient": $("#sone #sone-id").text(), "text": text }, function(data, textStatus) { + if ((data != null) && data.success) { + loadNewPost(data.postId); + } + }); + $(this).find(":input:enabled").val("").blur(); + return false; + }); + }); + /* Ajaxifies all posts. */ /* calling getTranslation here will cache the necessary values. */ getTranslation("WebInterface.Confirmation.DeletePostButton", function(text) {