X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=c9521b7b0e281c85dc3017ebb6a38d3a8e8251fa;hb=2288fe8a74e888e9d6a8b13ccbd322ca006c1cec;hp=ad23acdb08223e4dd6d8828771e5e0a77d201c72;hpb=35d7f770242ec62fb246d914c892a9ffec2def60;p=Sone.git diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index ad23acd..c9521b7 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -585,7 +585,7 @@ function getStatus() { }); /* process new posts. */ $.each(data.newPosts, function(index, value) { - loadNewPost(value); + loadNewPost(value.id, value.sone, value.recipient); }); /* process new replies. */ $.each(data.newReplies, function(index, value) { @@ -604,6 +604,16 @@ function getStatus() { } /** + * Returns the ID of the currently logged in Sone. + * + * @return The ID of the current Sone, or an empty string if no Sone is logged + * in + */ +function getCurrentSoneId() { + return $("#currentSoneId").text(); +} + +/** * Returns the content of the page-id attribute. * * @returns The page ID @@ -696,10 +706,13 @@ function hasReply(replyId) { return $("#sone .reply#" + replyId).length > 0; } -function loadNewPost(postId) { +function loadNewPost(postId, soneId, recipientId) { if (hasPost(postId)) { return; } + if (!isIndexPage() && (!isViewPostPage() || (getShownPostId() != postId))) { + return; + } $.getJSON("getPost.ajax", { "post" : postId }, function(data, textStatus) { if ((data != null) && data.success) { if (hasPost(data.post.id)) { @@ -830,6 +843,17 @@ function createNotification(id, text, dismissable) { return notification; } +/** + * Shows the details of the notification with the given ID. + * + * @param notificationId + * The ID of the notification + */ +function showNotificationDetails(notificationId) { + $("#sone .notification#" + notificationId + " .text").show(); + $("#sone .notification#" + notificationId + " .short-text").hide(); +} + // // EVERYTHING BELOW HERE IS EXECUTED AFTER LOADING THE PAGE // @@ -842,7 +866,7 @@ $(document).ready(function() { getTranslation("WebInterface.DefaultText.StatusUpdate", function(defaultText) { registerInputTextareaSwap("#sone #update-status .status-input", defaultText, "text", false, false); $("#sone #update-status").submit(function() { - if (!$(this).find(":input.default").hasAttr("disabled")) { + if ($(this).find(":input.default:enabled").length > 0) { return false; } text = $(this).find(":input:enabled").val();