diff options
author | Jakob Kaivo <jkk@ung.org> | 2019-07-27 16:05:11 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2019-07-27 16:05:11 -0400 |
commit | 4887e2d8b718c239d8c5cf79513e261a40a103f3 (patch) | |
tree | c9e97348a13beac8e91d7608daffadba73a92118 /blog.c | |
parent | b7346d1dd32608d4e48244fc28bbdba93e495da3 (diff) |
add live preview
Diffstat (limited to 'blog.c')
-rw-r--r-- | blog.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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"); |