Mercurial Hosting > freedit
diff src/thread.html.luan @ 46:289718f121e4
use bbcode editor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 14 Nov 2022 18:43:38 -0700 |
parents | 96f0c3d65698 |
children | f225e82b2bf8 |
line wrap: on
line diff
--- a/src/thread.html.luan Sun Nov 13 22:07:18 2022 -0700 +++ b/src/thread.html.luan Mon Nov 14 18:43:38 2022 -0700 @@ -36,6 +36,8 @@ <% head() %> <title><%=forum_title%>: <%=subject_html%></title> <style> + @import "/bbcode/bbcode.css"; + div[author] { margin-bottom: 6px; font-size: 10px; @@ -55,11 +57,6 @@ white-space: pre-wrap; line-height: 1.4; } - textarea { - width: 100%; - xmax-width: 450px; - xheight: 100px; - } <% if user_name == nil then %> [logged_in] { display: none; @@ -80,6 +77,7 @@ display: initial; } </style> + <script src="/bbcode/bbcode.js"></script> <script> function getPostDiv(node) { do { @@ -88,16 +86,16 @@ } while( node = node.parentNode ); } - function cancelEdit(src) { - let postDiv = getPostDiv(src); + function cancelEdit(event) { + let postDiv = getPostDiv(event.target); postDiv.querySelector('[output]').style.display = 'block'; postDiv.querySelector('[edit]').innerHTML = ''; } - function saveEdit(src) { - let postDiv = getPostDiv(src); + function saveEdit(event) { + let postDiv = getPostDiv(event.target); let post = postDiv.getAttribute('post'); let text = postDiv.querySelector('textarea').value; - cancelEdit(src); + cancelEdit(event); let postData = 'post=' + post + '&text=' + encodeURIComponent(text); ajax('save_edit.js',postData); } @@ -141,6 +139,10 @@ ajax( '/delete.js?post=' + post ); } function deleted(postId,thread_size) { + if( thread_size === 0 ) { + location = '/'; + return; + } let postDiv = document.querySelector('[post="'+postId+'"]'); if(!postDiv) return @@ -173,28 +175,19 @@ end %> <div post=new logged_in> <hr> - <textarea oninput="fixTextarea(this)"></textarea> - <p> - <input type=file onchange="upload(this,uploaded)"> - <button onclick="fileButtonClick(this)">Upload File</button> - <button onclick="newPost()">save</button> - </p> + <div editor></div> </div> </div> <% footer() %> <span hidden delete>Delete? <a href="javascript:" onclick="deleteYes(parentNode)">yes</a> / <a href="javascript:" onclick="deleteNo(parentNode)">no</a></span> <span hidden undelete><%delete_post()%></span> - <div hidden edit> - <textarea oninput="fixTextarea(this)"></textarea> - <p> - <input type=file onchange="upload(this,uploaded)"> - <button onclick="fileButtonClick(this)">Upload File</button> - <button onclick="saveEdit(this)">save</button> - <button onclick="cancelEdit(this)">cancel</button> - </p> - </div> </body> + <script> + bbcodeCreate('div[post="new"] div[editor]',{ + save: newPost + }); + </script> </html> <% end