From 6b129595c94a1d65cd7949066963289badfd71c1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 20 Oct 2010 07:58:10 +0200 Subject: [PATCH] Try to fix comment posting. --- .../pterodactylus/sone/web/CreateReplyPage.java | 5 +++- src/main/resources/static/javascript/sone.js | 33 +++++++++++++--------- src/main/resources/templates/createReply.html | 3 +- 3 files changed, 25 insertions(+), 16 deletions(-) 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 @@
- + +
-- 2.7.4