Merge branch 'next' into edit-wot-trust
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 31 Dec 2010 00:20:07 +0000 (01:20 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 31 Dec 2010 00:20:07 +0000 (01:20 +0100)
pom.xml
src/main/java/net/pterodactylus/sone/main/SonePlugin.java
src/main/resources/static/javascript/sone.js

diff --git a/pom.xml b/pom.xml
index 76f4718..780ea82 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -2,12 +2,12 @@
        <modelVersion>4.0.0</modelVersion>
        <groupId>net.pterodactylus</groupId>
        <artifactId>sone</artifactId>
-       <version>0.3.5-1</version>
+       <version>0.3.6-2</version>
        <dependencies>
                <dependency>
                        <groupId>net.pterodactylus</groupId>
                        <artifactId>utils</artifactId>
-                       <version>0.7.4</version>
+                       <version>0.7.5</version>
                </dependency>
                <dependency>
                        <groupId>junit</groupId>
index 83fc71e..8182fa2 100644 (file)
@@ -78,7 +78,7 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10
        }
 
        /** The version. */
-       public static final Version VERSION = new Version(0, 3, 5, 1);
+       public static final Version VERSION = new Version(0, 3, 6, 2);
 
        /** The logger. */
        private static final Logger logger = Logging.getLogger(SonePlugin.class);
index 898c3c0..8a3780f 100644 (file)
@@ -672,19 +672,39 @@ function isKnownSonesPage() {
        return getPageId() == "known-sones";
 }
 
-var loadedPosts = {};
-var loadedReplies = {};
+/**
+ * Returns whether a post with the given ID exists on the current page.
+ *
+ * @param postId
+ *            The post ID to check for
+ * @returns {Boolean} <code>true</code> if a post with the given ID already
+ *          exists on the page, <code>false</code> otherwise
+ */
+function hasPost(postId) {
+       return $(".post#" + postId).length > 0;
+}
+
+/**
+ * Returns whether a reply with the given ID exists on the current page.
+ *
+ * @param replyId
+ *            The reply ID to check for
+ * @returns {Boolean} <code>true</code> if a reply with the given ID already
+ *          exists on the page, <code>false</code> otherwise
+ */
+function hasReply(replyId) {
+       return $("#sone .reply#" + replyId).length > 0;
+}
 
 function loadNewPost(postId) {
-       if (postId in loadedPosts) {
+       if (hasPost(postId)) {
                return;
        }
        $.getJSON("getPost.ajax", { "post" : postId }, function(data, textStatus) {
                if ((data != null) && data.success) {
-                       if (data.post.id in loadedPosts) {
+                       if (hasPost(data.post.id)) {
                                return;
                        }
-                       loadedPosts[data.post.id] = true;
                        if (!isIndexPage() && !(isViewSonePage() && ((getShownSoneId() == data.post.sone) || (getShownSoneId() == data.post.recipient)))) {
                                return;
                        }
@@ -709,16 +729,15 @@ function loadNewPost(postId) {
 }
 
 function loadNewReply(replyId) {
-       if (replyId in loadedReplies) {
+       if (hasReply(replyId)) {
                return;
        }
        $.getJSON("getReply.ajax", { "reply": replyId }, function(data, textStatus) {
                /* find post. */
                if ((data != null) && data.success) {
-                       if (data.reply.id in loadedReplies) {
+                       if (hasReply(data.reply.id)) {
                                return;
                        }
-                       loadedReplies[data.reply.id] = true;
                        $("#sone .post#" + data.reply.postId).each(function() {
                                var firstNewerReply = null;
                                $(this).find(".replies .reply").each(function() {
@@ -823,7 +842,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").hasClass("default")) {
+                       if ($(this).find(":input.default:enabled").length > 0) {
                                return false;
                        }
                        text = $(this).find(":input:enabled").val();