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);
}
//
/* 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. */
<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>