Fix comparisons that were assignments.
[Sone.git] / src / main / resources / static / javascript / sone.js
index 6077049..accfabc 100644 (file)
@@ -872,7 +872,7 @@ function ajaxifyPost(postElement) {
                        }).fadeIn();
                }, 1000);
        }).mouseleave(function() {
-               if (currentSoneMenuId = getPostId(this)) {
+               if (currentSoneMenuId == getPostId(this)) {
                        clearTimeout(currentSoneMenuTimeoutHandler);
                }
        });
@@ -1011,7 +1011,7 @@ function ajaxifyReply(replyElement) {
                        }).fadeIn();
                }, 1000);
        }).mouseleave(function() {
-               if (currentSoneMenuId = getPostId(this) + "-" + getReplyId(this)) {
+               if (currentSoneMenuId == getPostId(this) + "-" + getReplyId(this)) {
                        clearTimeout(currentSoneMenuTimeoutHandler);
                }
        });
@@ -1193,7 +1193,7 @@ function checkForRemovedReplies(oldNotification, newNotification) {
 }
 
 function getStatus() {
-       ajaxGet("getStatus.ajax", isViewSonePage() ? {"soneIds": getShownSoneId() } : {"loadAllSones": isKnownSonesPage()}, function(data, textStatus) {
+       ajaxGet("getStatus.ajax", isViewSonePage() ? {"soneIds": getShownSoneId() } : isKnownSonesPage() ? {"soneIds": getShownSoneIds() } : {}, function(data, textStatus) {
                if ((data != null) && data.success) {
                        /* process Sone information. */
                        $.each(data.sones, function(index, value) {
@@ -1359,6 +1359,20 @@ function getShownSoneId() {
 }
 
 /**
+ * Returns the ID of all currently visible Sones. This is mainly used on the
+ * “Known Sones” page.
+ *
+ * @returns The ID of the currently shown Sones
+ */
+function getShownSoneIds() {
+       var soneIds = new Array();
+       $("#sone #known-sones .sone .id").each(function() {
+               soneIds.push($(this).text());
+       });
+       return soneIds.join(",");
+}
+
+/**
  * Returns whether the current page is a “view post” page.
  *
  * @returns {Boolean} <code>true</code> if the current page is a “view post”
@@ -1515,7 +1529,7 @@ function loadNewReply(replyId, soneId, postId, postSoneId) {
  *            request
  */
 function markSoneAsKnown(soneElement, skipRequest) {
-       if ($(soneElement).is(".new")) {
+       if ($(soneElement).hasClass("new")) {
                $(soneElement).removeClass("new");
                if ((typeof skipRequest == "undefined") || !skipRequest) {
                        ajaxGet("markAsKnown.ajax", {"formPassword": getFormPassword(), "type": "sone", "id": getSoneId(soneElement)});
@@ -1865,6 +1879,14 @@ var currentSoneMenuTimeoutHandler;
 
 $(document).ready(function() {
 
+       /* rip out the status update textarea. */
+       $("#sone .rip-out").each(function() {
+               var oldElement = $(this);
+               newElement = $("<input type='text'/>");
+               newElement.attr("class", oldElement.attr("class")).attr("name", oldElement.attr("name"));
+               oldElement.before(newElement).remove();
+       });
+
        /* this initializes the status update input field. */
        getTranslation("WebInterface.DefaultText.StatusUpdate", function(defaultText) {
                registerInputTextareaSwap("#sone #update-status .status-input", defaultText, "text", false, false);