Mercurial Hosting > freedit
diff src/thread.html.luan @ 15:0edde02b908c
edit in place
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 05 Jul 2022 23:27:54 -0600 |
parents | ad1604c72156 |
children | bff178656073 |
line wrap: on
line diff
--- a/src/thread.html.luan Mon Jul 04 17:04:14 2022 -0600 +++ b/src/thread.html.luan Tue Jul 05 23:27:54 2022 -0600 @@ -28,10 +28,24 @@ <% head() %> <title><%=forum_title%>: <%=subject_html%></title> <style> - [post] { + [message] { white-space: pre-wrap; } </style> + <script> + function cancelEdit(post) { + let postDiv = document.querySelector('[post="'+post+'"]'); + postDiv.querySelector('[output]').style.display = 'block'; + postDiv.querySelector('[edit]').innerHTML = ''; + } + + function saveEdit(post) { + let postDiv = document.querySelector('[post="'+post+'"]'); + let text = postDiv.querySelector('textarea').value; + let postData = 'post=' + post + '&text=' + encodeURIComponent(text); + ajax("save_edit.js",postData); + } + </script> </head> <body> <% header() %> @@ -39,11 +53,16 @@ <h1><%=subject_html%></h1> <% for _, post in ipairs(posts) do %> <hr> - <% bbcode_to_html(post.content) %> - <p> - <a href="/reply.html?parent=<%=post.id%>">reply</a> - - <a href="/edit.html?post=<%=post.id%>">edit</a> - </p> + <div post="<%=post.id%>"> + <div output> + <% bbcode_to_html(post.content) %> + <p> + <a href="/reply.html?parent=<%=post.id%>">reply</a> + - <a href="javascript:ajax('/edit.js?post=<%=post.id%>')">edit</a> + </p> + </div> + <div edit></div> + </div> <% end %> </div> <% footer() %>