summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-07-27 16:05:11 -0400
committerJakob Kaivo <jkk@ung.org>2019-07-27 16:05:11 -0400
commit4887e2d8b718c239d8c5cf79513e261a40a103f3 (patch)
treec9e97348a13beac8e91d7608daffadba73a92118
parentb7346d1dd32608d4e48244fc28bbdba93e495da3 (diff)
add live preview
-rw-r--r--blog.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/blog.c b/blog.c
index 3c69802..8174a10 100644
--- a/blog.c
+++ b/blog.c
@@ -148,11 +148,18 @@ int main(void)
printf("<p>Posting as %s</p>\n", user);
}
+ puts("<script type=\"text/javascript\">");
+ puts("function update() {");
+ puts("\tdocument.getElementById(\"output\").innerHTML = document.getElementById(\"body\").value;");
+ puts("}");
+ puts("</script>");
+
printf("<form method=\"POST\" action=\"%s\">\n", getenv("DOCUMENT_URI"));
puts("<input type=\"text\" name=\"title\" placeholder=\"title\" size=\"80\"><br>");
- puts("<textarea name=\"body\" cols=\"80\" rows=\"24\"><p></p></textarea><br>");
- puts("<input type=\"submit\">");
+ puts("<textarea id=\"body\" name=\"body\" cols=\"80\" rows=\"24\" oninput=\"update();\"><p></p></textarea><br>");
+ puts("<input type=\"submit\" value=\"Post\">");
puts("</form>");
+ puts("<div id=\"output\"></div>");
printf(HTML_TAIL, current_year(), "Jakob Kaivo", "jakob@kaivo.net");