Merge branch 'mark-as-read' into next
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 19 Jan 2011 18:12:40 +0000 (19:12 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 19 Jan 2011 18:12:40 +0000 (19:12 +0100)
Conflicts:
src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java

1  2 
src/main/java/net/pterodactylus/sone/template/SoneAccessor.java
src/main/java/net/pterodactylus/sone/web/CreatePostPage.java
src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java
src/main/java/net/pterodactylus/sone/web/DeletePostPage.java
src/main/java/net/pterodactylus/sone/web/DeleteReplyPage.java
src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java
src/main/resources/i18n/sone.en.properties
src/main/resources/static/css/sone.css
src/main/resources/static/javascript/sone.js

@@@ -27,8 -27,8 +27,8 @@@ import net.pterodactylus.sone.data.Sone
  import net.pterodactylus.sone.freenet.wot.Trust;
  import net.pterodactylus.util.logging.Logging;
  import net.pterodactylus.util.template.Accessor;
- import net.pterodactylus.util.template.DataProvider;
  import net.pterodactylus.util.template.ReflectionAccessor;
+ import net.pterodactylus.util.template.TemplateContext;
  
  /**
   * {@link Accessor} for {@link Sone}s that adds a couple of properties to Sones.
@@@ -39,7 -39,7 +39,7 @@@
   * <dt>friend</dt>
   * <dd>Will return {@code true} if the sone in question is a friend of the
   * currently logged in Sone (as determined by accessing the “currentSone”
-  * variable of the given {@link DataProvider}).</dd>
+  * variable of the given {@link TemplateContext}).</dd>
   * <dt>current</dt>
   * <dd>Will return {@code true} if the sone in question is the currently logged
   * in Sone.</dd>
@@@ -69,17 -69,17 +69,17 @@@ public class SoneAccessor extends Refle
         * {@inheritDoc}
         */
        @Override
-       public Object get(DataProvider dataProvider, Object object, String member) {
+       public Object get(TemplateContext templateContext, Object object, String member) {
                Sone sone = (Sone) object;
                if (member.equals("niceName")) {
                        return getNiceName(sone);
                } else if (member.equals("local")) {
 -                      return sone.getInsertUri() != null;
 +                      return core.isLocalSone(sone);
                } else if (member.equals("friend")) {
-                       Sone currentSone = (Sone) dataProvider.get("currentSone");
+                       Sone currentSone = (Sone) templateContext.get("currentSone");
                        return (currentSone != null) && currentSone.hasFriend(sone.getId());
                } else if (member.equals("current")) {
-                       Sone currentSone = (Sone) dataProvider.get("currentSone");
+                       Sone currentSone = (Sone) templateContext.get("currentSone");
                        return (currentSone != null) && currentSone.equals(sone);
                } else if (member.equals("modified")) {
                        return core.isModifiedSone(sone);
                } else if (member.equals("downloading")) {
                        return core.getSoneStatus(sone) == SoneStatus.downloading;
                } else if (member.equals("new")) {
-                       return core.isNewSone(sone);
+                       return core.isNewSone(sone.getId(), false);
                } else if (member.equals("locked")) {
                        return core.isLocked(sone);
                } else if (member.equals("trust")) {
-                       Sone currentSone = (Sone) dataProvider.get("currentSone");
+                       Sone currentSone = (Sone) templateContext.get("currentSone");
                        if (currentSone == null) {
                                return null;
                        }
                        }
                        return trust;
                }
-               return super.get(dataProvider, object, member);
+               return super.get(templateContext, object, member);
        }
  
        //
@@@ -20,8 -20,8 +20,8 @@@ package net.pterodactylus.sone.web
  import net.pterodactylus.sone.data.Post;
  import net.pterodactylus.sone.data.Sone;
  import net.pterodactylus.sone.web.page.Page.Request.Method;
- import net.pterodactylus.util.template.DataProvider;
  import net.pterodactylus.util.template.Template;
+ import net.pterodactylus.util.template.TemplateContext;
  
  /**
   * This page lets the user create a new {@link Post}.
@@@ -50,26 -50,21 +50,26 @@@ public class CreatePostPage extends Son
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, DataProvider dataProvider) throws RedirectException {
-               super.processTemplate(request, dataProvider);
+       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+               super.processTemplate(request, templateContext);
                String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
                if (request.getMethod() == Method.POST) {
                        String text = request.getHttpRequest().getPartAsStringFailsafe("text", 65536).trim();
                        if (text.length() != 0) {
 +                              String senderId = request.getHttpRequest().getPartAsStringFailsafe("sender", 43);
                                String recipientId = request.getHttpRequest().getPartAsStringFailsafe("recipient", 43);
 -                              Sone recipient = webInterface.getCore().getSone(recipientId, false);
                                Sone currentSone = getCurrentSone(request.getToadletContext());
 -                              webInterface.getCore().createPost(currentSone, recipient, System.currentTimeMillis(), text);
 +                              Sone sender = webInterface.getCore().getLocalSone(senderId, false);
 +                              if (sender == null) {
 +                                      sender = currentSone;
 +                              }
 +                              Sone recipient = webInterface.getCore().getSone(recipientId, false);
 +                              webInterface.getCore().createPost(sender, recipient, System.currentTimeMillis(), text);
                                throw new RedirectException(returnPage);
                        }
-                       dataProvider.set("errorTextEmpty", true);
+                       templateContext.set("errorTextEmpty", true);
                }
-               dataProvider.set("returnPage", returnPage);
+               templateContext.set("returnPage", returnPage);
        }
  
  }
@@@ -20,8 -20,8 +20,8 @@@ package net.pterodactylus.sone.web
  import net.pterodactylus.sone.data.Post;
  import net.pterodactylus.sone.data.Sone;
  import net.pterodactylus.sone.web.page.Page.Request.Method;
- import net.pterodactylus.util.template.DataProvider;
  import net.pterodactylus.util.template.Template;
+ import net.pterodactylus.util.template.TemplateContext;
  
  /**
   * This page lets the user post a reply to a post.
@@@ -50,27 -50,23 +50,27 @@@ public class CreateReplyPage extends So
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, DataProvider dataProvider) throws RedirectException {
-               super.processTemplate(request, dataProvider);
+       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+               super.processTemplate(request, templateContext);
                String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
                String text = request.getHttpRequest().getPartAsStringFailsafe("text", 65536).trim();
                String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
                if (request.getMethod() == Method.POST) {
                        Post post = webInterface.getCore().getPost(postId);
                        if (text.length() > 0) {
 -                              Sone currentSone = getCurrentSone(request.getToadletContext());
 -                              webInterface.getCore().createReply(currentSone, post, text);
 +                              String senderId = request.getHttpRequest().getPartAsStringFailsafe("sender", 43);
 +                              Sone sender = webInterface.getCore().getLocalSone(senderId, false);
 +                              if (sender == null) {
 +                                      sender = getCurrentSone(request.getToadletContext());
 +                              }
 +                              webInterface.getCore().createReply(sender, post, text);
                                throw new RedirectException(returnPage);
                        }
-                       dataProvider.set("errorTextEmpty", true);
+                       templateContext.set("errorTextEmpty", true);
                }
-               dataProvider.set("postId", postId);
-               dataProvider.set("text", text);
-               dataProvider.set("returnPage", returnPage);
+               templateContext.set("postId", postId);
+               templateContext.set("text", text);
+               templateContext.set("returnPage", returnPage);
        }
  
  }
  package net.pterodactylus.sone.web;
  
  import net.pterodactylus.sone.data.Post;
 -import net.pterodactylus.sone.data.Sone;
  import net.pterodactylus.sone.web.page.Page.Request.Method;
- import net.pterodactylus.util.template.DataProvider;
  import net.pterodactylus.util.template.Template;
+ import net.pterodactylus.util.template.TemplateContext;
  
  /**
   * Lets the user delete a post they made.
@@@ -49,30 -50,31 +49,30 @@@ public class DeletePostPage extends Son
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, DataProvider dataProvider) throws RedirectException {
-               super.processTemplate(request, dataProvider);
+       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+               super.processTemplate(request, templateContext);
                if (request.getMethod() == Method.GET) {
                        String postId = request.getHttpRequest().getParam("post");
                        String returnPage = request.getHttpRequest().getParam("returnPage");
                        Post post = webInterface.getCore().getPost(postId);
-                       dataProvider.set("post", post);
-                       dataProvider.set("returnPage", returnPage);
+                       templateContext.set("post", post);
+                       templateContext.set("returnPage", returnPage);
                        return;
                } else if (request.getMethod() == Method.POST) {
                        String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
                        String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
                        Post post = webInterface.getCore().getPost(postId);
 -                      Sone currentSone = getCurrentSone(request.getToadletContext());
 -                      if (!post.getSone().equals(currentSone)) {
 +                      if (!webInterface.getCore().isLocalSone(post.getSone())) {
                                throw new RedirectException("noPermission.html");
                        }
                        if (request.getHttpRequest().isPartSet("confirmDelete")) {
 -                              currentSone.removePost(post);
 +                              webInterface.getCore().deletePost(post);
                                throw new RedirectException(returnPage);
                        } else if (request.getHttpRequest().isPartSet("abortDelete")) {
                                throw new RedirectException(returnPage);
                        }
-                       dataProvider.set("post", post);
-                       dataProvider.set("returnPage", returnPage);
+                       templateContext.set("post", post);
+                       templateContext.set("returnPage", returnPage);
                }
        }
  
  package net.pterodactylus.sone.web;
  
  import net.pterodactylus.sone.data.Reply;
 -import net.pterodactylus.sone.data.Sone;
  import net.pterodactylus.sone.web.page.Page.Request.Method;
- import net.pterodactylus.util.template.DataProvider;
  import net.pterodactylus.util.template.Template;
+ import net.pterodactylus.util.template.TemplateContext;
  
  /**
   * This page lets the user delete a reply.
@@@ -49,13 -50,14 +49,13 @@@ public class DeleteReplyPage extends So
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, DataProvider dataProvider) throws RedirectException {
-               super.processTemplate(request, dataProvider);
+       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+               super.processTemplate(request, templateContext);
                String replyId = request.getHttpRequest().getPartAsStringFailsafe("reply", 36);
                Reply reply = webInterface.getCore().getReply(replyId);
                String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
                if (request.getMethod() == Method.POST) {
 -                      Sone currentSone = getCurrentSone(request.getToadletContext());
 -                      if (!reply.getSone().equals(currentSone)) {
 +                      if (!webInterface.getCore().isLocalSone(reply.getSone())) {
                                throw new RedirectException("noPermission.html");
                        }
                        if (request.getHttpRequest().isPartSet("confirmDelete")) {
@@@ -65,8 -67,8 +65,8 @@@
                                throw new RedirectException(returnPage);
                        }
                }
-               dataProvider.set("reply", reply);
-               dataProvider.set("returnPage", returnPage);
+               templateContext.set("reply", reply);
+               templateContext.set("returnPage", returnPage);
        }
  
  }
@@@ -24,8 -24,8 +24,8 @@@ import net.pterodactylus.sone.data.Sone
  import net.pterodactylus.sone.main.SonePlugin;
  import net.pterodactylus.sone.web.page.Page;
  import net.pterodactylus.sone.web.page.TemplatePage;
- import net.pterodactylus.util.template.DataProvider;
  import net.pterodactylus.util.template.Template;
+ import net.pterodactylus.util.template.TemplateContext;
  import freenet.clients.http.SessionManager.Session;
  import freenet.clients.http.ToadletContext;
  
@@@ -74,10 -74,10 +74,10 @@@ public class SoneTemplatePage extends T
         *            Whether this page requires a login
         */
        public SoneTemplatePage(String path, Template template, String pageTitleKey, WebInterface webInterface, boolean requireLogin) {
-               super(path, template, webInterface.getL10n(), pageTitleKey, "noPermission.html");
+               super(path, webInterface.getTemplateContextFactory(), template, webInterface.getL10n(), pageTitleKey, "noPermission.html");
                this.webInterface = webInterface;
                this.requireLogin = requireLogin;
-               template.set("webInterface", webInterface);
+               template.getInitialContext().set("webInterface", webInterface);
        }
  
        //
         * {@inheritDoc}
         */
        @Override
-       protected void processTemplate(Request request, DataProvider dataProvider) throws RedirectException {
-               super.processTemplate(request, dataProvider);
-               dataProvider.set("currentSone", getCurrentSone(request.getToadletContext(), false));
-               dataProvider.set("localSones", webInterface.getCore().getLocalSones());
-               dataProvider.set("request", request);
-               dataProvider.set("currentVersion", SonePlugin.VERSION);
-               dataProvider.set("hasLatestVersion", webInterface.getCore().getUpdateChecker().hasLatestVersion());
-               dataProvider.set("latestVersion", webInterface.getCore().getUpdateChecker().getLatestVersion());
-               dataProvider.set("latestVersionTime", webInterface.getCore().getUpdateChecker().getLatestVersionDate());
+       protected void processTemplate(Request request, TemplateContext templateContext) throws RedirectException {
+               super.processTemplate(request, templateContext);
+               templateContext.set("currentSone", getCurrentSone(request.getToadletContext(), false));
++              templateContext.set("localSones", webInterface.getCore().getLocalSones());
+               templateContext.set("request", request);
+               templateContext.set("currentVersion", SonePlugin.VERSION);
+               templateContext.set("hasLatestVersion", webInterface.getCore().getUpdateChecker().hasLatestVersion());
+               templateContext.set("latestVersion", webInterface.getCore().getUpdateChecker().getLatestVersion());
+               templateContext.set("latestVersionTime", webInterface.getCore().getUpdateChecker().getLatestVersionDate());
        }
  
        /**
@@@ -55,7 -55,6 +55,7 @@@ Page.DeleteSone.Button.No=No, do not de
  
  Page.Index.Title=Your Sone - Sone
  Page.Index.Label.Text=Post text:
 +Page.Index.Label.Sender=Sender:
  Page.Index.Button.Post=Post!
  Page.Index.PostList.Title=Post Feed
  Page.Index.PostList.Text.NoPostYet=Nobody has written any posts yet. You should probably start it right now!
@@@ -158,6 -157,8 +158,8 @@@ Page.Distrust.Title=Distrust Sone - Son
  
  Page.Untrust.Title=Untrust Sone - Sone
  
+ Page.MarkAsKnown.Title=Mark as Known - Sone
  Page.NoPermission.Title=Unauthorized Access - Sone
  Page.NoPermission.Page.Title=Unauthorized Access
  Page.NoPermission.Text.NoPermission=You tried to do something that you do not have sufficient authorization for. Please refrain from such actions in the future or we will be forced to take counter-measures!
@@@ -201,8 -202,6 +203,8 @@@ View.Post.Reply.DeleteLink=Delet
  View.Post.LikeLink=Like
  View.Post.UnlikeLink=Unlike
  
 +View.UpdateStatus.Text.ChooseSenderIdentity=Choose the sender identity
 +
  View.Trust.Tooltip.Trust=Trust this person
  View.Trust.Tooltip.Distrust=Assign negative trust to this person
  View.Trust.Tooltip.Untrust=Remove your trust assignment for this person
@@@ -236,6 -235,7 +238,7 @@@ Notification.NewSone.ShortText=New Sone
  Notification.NewSone.Text=New Sones have been discovered:
  Notification.NewPost.ShortText=New posts have been discovered.
  Notification.NewPost.Text=New posts have been discovered by the following Sones:
+ Notification.NewPost.Button.MarkRead=Mark as read
  Notification.NewReply.ShortText=New replies have been discovered.
  Notification.NewReply.Text=New replies have been discovered by the following Sones:
  Notification.SoneIsBeingRescued.Text=The following Sones are currently being rescued:
@@@ -35,11 -35,6 +35,11 @@@ textarea 
        margin: 0px;
  }
  
 +#sone select {
 +      color: #444;
 +      padding: 0.5ex 1.5ex;
 +}
 +
  /* now for the real stuff. */
  
  #sone {
        margin-left: 1ex;
  }
  
+ #sone #notification-area .notification .mark-as-read {
+       float: right;
+ }
  #sone #plugin-warning {
        border: solid 0.5em red;
        padding: 0.5em;
        float: right;
  }
  
 +#sone #update-status .select-sender, #sone .create-reply .select-sender {
 +      display: none;
 +}
 +
 +#sone #update-status .select-sender button {
 +      display: inline;
 +      float: left;
 +}
 +
  #sone .nice-name {
        font-weight: bold;
  }
  
  #sone .post .create-reply input[type=text] {
        margin-left: 0.5ex;
 -      width: 44em;
 +      width: 42em;
  }
  
  #sone .post .create-reply textarea {
        margin-left: 0.5ex;
 -      width: 44em;
 +      width: 42em;
        height: 4em;
  }
  
        float: right;
  }
  
 +#sone .create-reply .select-sender button {
 +      display: inline;
 +      float: left;
 +}
 +
  #sone .sone {
        clear: both;
        background-color: #f0f0ff;
        display: none;
  }
  
 -#sone .profile-field button.confirm {
 +#sone .profile-field button.confirm.edit {
        font-weight: bold;
        color: #080;
  }
  #sone .profile-field .edit-field-name, #sone .profile-field .move-up-field, #sone .profile-field .move-down-field, #sone .profile-field .delete-field-name {
        float: right;
        margin-top: -1ex;
 +      position: relative;
  }
  
  #sone #tail {
@@@ -491,8 -491,6 +491,8 @@@ function updateReplyLikes(replyId) 
  /**
   * Posts a reply and calls the given callback when the request finishes.
   *
 + * @param sender
 + *            The ID of the sender
   * @param postId
   *            The ID of the post the reply refers to
   * @param text
   *            The callback function to call when the request finishes (takes 3
   *            parameters: success, error, replyId)
   */
 -function postReply(postId, text, callbackFunction) {
 -      $.getJSON("createReply.ajax", { "formPassword" : getFormPassword(), "post" : postId, "text": text }, function(data, textStatus) {
 +function postReply(sender, postId, text, callbackFunction) {
 +      $.getJSON("createReply.ajax", { "formPassword" : getFormPassword(), "sender": sender, "post" : postId, "text": text }, function(data, textStatus) {
                if (data == null) {
                        /* TODO - show error */
                        return;
                }
                if (data.success) {
 -                      callbackFunction(true, null, data.reply);
 +                      callbackFunction(true, null, data.reply, data.sone);
                } else {
                        callbackFunction(false, data.error);
                }
@@@ -547,25 -545,21 +547,25 @@@ function ajaxifyPost(postElement) 
                return false;
        });
        $(postElement).find(".create-reply button:submit").click(function() {
 -              inputField = $(this.form).find(":input:enabled").get(0);
 +              sender = $(this.form).find(":input[name=sender]").val();
 +              inputField = $(this.form).find(":input[name=text]:enabled").get(0);
                postId = getPostId(this);
                text = $(inputField).val();
 -              (function(postId, text, inputField) {
 -                      postReply(postId, text, function(success, error, replyId) {
 +              (function(sender, postId, text, inputField) {
 +                      postReply(sender, postId, text, function(success, error, replyId, soneId) {
                                if (success) {
                                        $(inputField).val("");
 -                                      loadNewReply(replyId, getCurrentSoneId(), postId);
 +                                      loadNewReply(replyId, soneId, postId);
                                        markPostAsKnown(getPostElement(inputField));
                                        $("#sone .post#" + postId + " .create-reply").addClass("hidden");
 +                                      $("#sone .post#" + postId + " .create-reply .sender").hide();
 +                                      $("#sone .post#" + postId + " .create-reply .select-sender").show();
 +                                      $("#sone .post#" + postId + " .create-reply :input[name=sender]").val(getCurrentSoneId());
                                } else {
                                        alert(error);
                                }
                        });
 -              })(postId, text, inputField);
 +              })(sender, postId, text, inputField);
                return false;
        });
  
                });
        });
  
 +      /* process sender selection. */
 +      $(".select-sender", postElement).css("display", "inline");
 +      $(".sender", postElement).hide();
 +      $(".select-sender button", postElement).click(function() {
 +              $(".sender", postElement).show();
 +              $(".select-sender", postElement).hide();
 +              return false;
 +      });
 +
        /* mark everything as known on click. */
        $(postElement).click(function(event) {
                if ($(event.target).hasClass("click-to-show")) {
@@@ -692,9 -677,17 +692,17 @@@ function ajaxifyReply(replyElement) 
   *            jQuery object representing the notification.
   */
  function ajaxifyNotification(notification) {
-       notification.find("form.dismiss").submit(function() {
+       notification.find("form").submit(function() {
                return false;
        });
+       notification.find("input[name=returnPage]").val($.url.attr("relative"));
+       if (notification.find(".short-text").length > 0) {
+               notification.find(".short-text").removeClass("hidden");
+               notification.find(".text").addClass("hidden");
+       }
+       notification.find("form.mark-as-read button").click(function() {
+               $.getJSON("markAsKnown.ajax", {"formPassword": getFormPassword(), "type": $(":input[name=type]", this.form).val(), "id": $(":input[name=id]", this.form).val()});
+       });
        notification.find("form.dismiss button").click(function() {
                $.getJSON("dismissNotification.ajax", { "formPassword" : getFormPassword(), "notification" : notification.attr("id") }, function(data, textStatus) {
                        /* dismiss in case of error, too. */
@@@ -936,7 -929,7 +944,7 @@@ function markPostAsKnown(postElements) 
                postElement = this;
                if ($(postElement).hasClass("new")) {
                        (function(postElement) {
-                               $.getJSON("markPostAsKnown.ajax", {"formPassword": getFormPassword(), "post": getPostId(postElement)}, function(data, textStatus) {
+                               $.getJSON("markAsKnown.ajax", {"formPassword": getFormPassword(), "type": "post", "id": getPostId(postElement)}, function(data, textStatus) {
                                        $(postElement).removeClass("new");
                                        $(".click-to-show", postElement).removeClass("new");
                                });
@@@ -951,7 -944,7 +959,7 @@@ function markReplyAsKnown(replyElements
                replyElement = this;
                if ($(replyElement).hasClass("new")) {
                        (function(replyElement) {
-                               $.getJSON("markReplyAsKnown.ajax", {"formPassword": getFormPassword(), "reply": getReplyId(replyElement)}, function(data, textStatus) {
+                               $.getJSON("markAsKnown.ajax", {"formPassword": getFormPassword(), "type": "reply", "id": getReplyId(replyElement)}, function(data, textStatus) {
                                        $(replyElement).removeClass("new");
                                });
                        })(replyElement);
@@@ -1093,28 -1086,17 +1101,28 @@@ $(document).ready(function() 
        /* this initializes the status update input field. */
        getTranslation("WebInterface.DefaultText.StatusUpdate", function(defaultText) {
                registerInputTextareaSwap("#sone #update-status .status-input", defaultText, "text", false, false);
 +              $("#sone #update-status .select-sender").css("display", "inline");
 +              $("#sone #update-status .sender").hide();
 +              $("#sone #update-status .select-sender button").click(function() {
 +                      $("#sone #update-status .sender").show();
 +                      $("#sone #update-status .select-sender").hide();
 +                      return false;
 +              });
                $("#sone #update-status").submit(function() {
                        if ($(this).find(":input.default:enabled").length > 0) {
                                return false;
                        }
 -                      text = $(this).find(":input:enabled").val();
 -                      $.getJSON("createPost.ajax", { "formPassword": getFormPassword(), "text": text }, function(data, textStatus) {
 +                      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, getCurrentSoneId());
 +                                      loadNewPost(data.postId, data.sone, data.recipient);
                                }
                        });
 -                      $(this).find(":input:enabled").val("").blur();
 +                      $(this).find(":input[name=sender]").val(getCurrentSoneId());
 +                      $(this).find(":input[name=text]:enabled").val("").blur();
 +                      $(this).find(".sender").hide();
 +                      $(this).find(".select-sender").show();
                        return false;
                });
        });