Small optimization to prevent loading of a post if it’s obviously not necessary.
[Sone.git] / src / main / resources / static / javascript / sone.js
index fe2e12d..ccf7149 100644 (file)
@@ -700,6 +700,9 @@ function loadNewPost(postId) {
        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 +833,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
 //
@@ -954,9 +968,7 @@ $(document).ready(function() {
        });
 
        /* activate status polling. */
-       if (getPageId() != "login") {
-               setTimeout(getStatus, 5000);
-       }
+       setTimeout(getStatus, 5000);
 
        /* reset activity counter when the page has focus. */
        $(window).focus(function() {