From: David ‘Bombe’ Roden Date: Wed, 20 Oct 2010 05:58:10 +0000 (+0200) Subject: Try to fix comment posting. X-Git-Tag: 0.1-RC1~166 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=6b129595c94a1d65cd7949066963289badfd71c1;p=Sone.git Try to fix comment posting. --- diff --git a/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java b/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java index 8fb4480..420fb86 100644 --- a/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java +++ b/src/main/java/net/pterodactylus/sone/web/CreateReplyPage.java @@ -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); } // diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 97c3da5..7fbdab9 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -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. */ diff --git a/src/main/resources/templates/createReply.html b/src/main/resources/templates/createReply.html index b24a588..642fdc0 100644 --- a/src/main/resources/templates/createReply.html +++ b/src/main/resources/templates/createReply.html @@ -8,7 +8,8 @@
- + +