X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=596c19ca15c3c500ce0eb8ae62d2dc924858cc85;hb=5777cb6291375cdd4cbc2c781d1fea807da566f8;hp=21f6803af437a2cf507579da37601326b4429ee1;hpb=9d341071d7fc10118038e238d29ce7bd38ff08c4;p=Sone.git diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 21f6803..596c19c 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -218,7 +218,8 @@ function enhanceDeletePostButton(button, postId, text) { if (data.success) { $("#sone .post#" + postId).slideUp(); } else if (data.error == "invalid-post-id") { - alert("Invalid post ID given!"); + /* pretend the post is already gone. */ + getPost(postId).slideUp(); } else if (data.error == "auth-required") { alert("You need to be logged in."); } else if (data.error == "not-authorized") { @@ -249,7 +250,8 @@ function enhanceDeleteReplyButton(button, replyId, text) { if (data.success) { $("#sone .reply#" + replyId).slideUp(); } else if (data.error == "invalid-reply-id") { - alert("Invalid reply ID given!"); + /* pretend the reply is already gone. */ + getReply(replyId).slideUp(); } else if (data.error == "auth-required") { alert("You need to be logged in."); } else if (data.error == "not-authorized") { @@ -1030,6 +1032,10 @@ function getStatus() { $.each(data.newReplies, function(index, value) { loadNewReply(value.id, value.sone, value.post, value.postSone); }); + /* remove activity when no notifications are visible. */ + if ($("#sone #notification-area .notification").length == 0) { + resetActivity(); + } /* do it again in 5 seconds. */ setTimeout(getStatus, 5000); } else { @@ -1558,9 +1564,6 @@ $(document).ready(function() { sender = $(this).find(":input[name=sender]").val(); text = $(this).find(":input[name=text]:enabled").val(); $.getJSON("createPost.ajax", { "formPassword": getFormPassword(), "sender": sender, "text": text }, function(data, textStatus) { - if ((data != null) && data.success) { - loadNewPost(data.postId, data.sone, data.recipient); - } button.removeAttr("disabled"); }); $(this).find(":input[name=sender]").val(getCurrentSoneId()); @@ -1589,11 +1592,7 @@ $(document).ready(function() { $("#sone #post-message").submit(function() { sender = $(this).find(":input[name=sender]").val(); text = $(this).find(":input[name=text]:enabled").val(); - $.getJSON("createPost.ajax", { "formPassword": getFormPassword(), "recipient": getShownSoneId(), "sender": sender, "text": text }, function(data, textStatus) { - if ((data != null) && data.success) { - loadNewPost(data.postId, getCurrentSoneId()); - } - }); + $.getJSON("createPost.ajax", { "formPassword": getFormPassword(), "recipient": getShownSoneId(), "sender": sender, "text": text }); $(this).find(":input[name=sender]").val(getCurrentSoneId()); $(this).find(":input[name=text]:enabled").val("").blur(); $(this).find(".sender").hide();