Try to fix comment posting.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 20 Oct 2010 05:58:10 +0000 (07:58 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 20 Oct 2010 05:58:10 +0000 (07:58 +0200)
src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java
src/main/resources/static/javascript/sone.js
src/main/resources/templates/createReply.html

index 8fb4480..420fb86 100644 (file)
@@ -53,17 +53,20 @@ public class CreateReplyPage extends SoneTemplatePage {
                super.processTemplate(request, template);
                String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
                String text = request.getHttpRequest().getPartAsStringFailsafe("text", 65536).trim();
+               String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64);
+               System.out.println("postId: " + postId + ", text: " + text + ", returnPage: " + returnPage);
                if (request.getMethod() == Method.POST) {
                        Post post = webInterface.core().getPost(postId);
                        if (text.length() > 0) {
                                Sone currentSone = getCurrentSone(request.getToadletContext());
                                webInterface.core().createReply(currentSone, post, text);
-                               throw new RedirectException("viewPost.html?post=" + post.getId());
+                               throw new RedirectException(returnPage);
                        }
                        template.set("errorTextEmpty", true);
                }
                template.set("postId", postId);
                template.set("text", text);
+               template.set("returnPage", returnPage);
        }
 
        //
index 97c3da5..7fbdab9 100644 (file)
@@ -1,20 +1,25 @@
 /* Sone JavaScript functions. */
 
 function registerInputTextareaSwap(inputSelector, defaultText) {
-       $(inputSelector).focus(function() {
-               if ($(this).val() == defaultText) {
-                       $(this).val("").removeClass("default");
-               }
-       }).blur(function() {
-               if ($(this).val() == "") {
-                       $(this).val(defaultText).addClass("default");
-               }
-       }).addClass("default").val(defaultText);
-       $($(inputSelector).get(0).form).submit(function() {
-               if ($(inputSelector).hasClass("default")) {
-                       $(inputSelector).val("");
-               }
-       });
+       (function(inputSelector, defaultText) {
+               $(inputSelector).focus(function() {
+                       if ($(this).hasClass("default")) {
+                               $(this).removeClass("default").val("");
+                       }
+               }).blur(function() {
+                       alert($(this).val());
+                       if ($(this).val() == "") {
+                               alert("setting default");
+                               $(this).val(defaultText).addClass("default");
+                       }
+               }).addClass("default").val(defaultText);
+               $($(inputSelector).get(0).form).submit(function() {
+                       if ($(inputSelector).hasClass("default")) {
+                               $(inputSelector).val("");
+                       }
+                       alert(($(inputSelector).hasClass("default") ? "def: ": "ok: ") + $(inputSelector).val());
+               });
+       })(inputSelector, defaultText);
 }
 
 /* hide all the “create reply” forms until a link is clicked. */
index b24a588..642fdc0 100644 (file)
@@ -8,7 +8,8 @@
 
        <form method="post">
                <input type="hidden" name="formPassword" value="<% formPassword|html>" />
-               <input type="hidden" name="postId" value="<% postId>" />
+               <input type="hidden" name="returnPage" value="<% returnPage|html>" />
+               <input type="hidden" name="post" value="<% postId>" />
 
                <div>
                        <label for="text"><%= Page.CreateReply.Label.Text|l10n|html></label>