comparison 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
comparison
equal deleted inserted replaced
14:7d0c96408abf 15:0edde02b908c
26 <html> 26 <html>
27 <head> 27 <head>
28 <% head() %> 28 <% head() %>
29 <title><%=forum_title%>: <%=subject_html%></title> 29 <title><%=forum_title%>: <%=subject_html%></title>
30 <style> 30 <style>
31 [post] { 31 [message] {
32 white-space: pre-wrap; 32 white-space: pre-wrap;
33 } 33 }
34 </style> 34 </style>
35 <script>
36 function cancelEdit(post) {
37 let postDiv = document.querySelector('[post="'+post+'"]');
38 postDiv.querySelector('[output]').style.display = 'block';
39 postDiv.querySelector('[edit]').innerHTML = '';
40 }
41
42 function saveEdit(post) {
43 let postDiv = document.querySelector('[post="'+post+'"]');
44 let text = postDiv.querySelector('textarea').value;
45 let postData = 'post=' + post + '&text=' + encodeURIComponent(text);
46 ajax("save_edit.js",postData);
47 }
48 </script>
35 </head> 49 </head>
36 <body> 50 <body>
37 <% header() %> 51 <% header() %>
38 <div content> 52 <div content>
39 <h1><%=subject_html%></h1> 53 <h1><%=subject_html%></h1>
40 <% for _, post in ipairs(posts) do %> 54 <% for _, post in ipairs(posts) do %>
41 <hr> 55 <hr>
42 <% bbcode_to_html(post.content) %> 56 <div post="<%=post.id%>">
43 <p> 57 <div output>
44 <a href="/reply.html?parent=<%=post.id%>">reply</a> 58 <% bbcode_to_html(post.content) %>
45 - <a href="/edit.html?post=<%=post.id%>">edit</a> 59 <p>
46 </p> 60 <a href="/reply.html?parent=<%=post.id%>">reply</a>
61 - <a href="javascript:ajax('/edit.js?post=<%=post.id%>')">edit</a>
62 </p>
63 </div>
64 <div edit></div>
65 </div>
47 <% end %> 66 <% end %>
48 </div> 67 </div>
49 <% footer() %> 68 <% footer() %>
50 </body> 69 </body>
51 </html> 70 </html>