comparison src/thread.html.luan @ 32:72a1b77b4548

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 29 Jul 2022 13:57:20 -0600
parents 0837820b97fb
children 4fdc4ec0050b
comparison
equal deleted inserted replaced
31:6d265f5e18e2 32:72a1b77b4548
69 if( node.getAttribute('post') ) 69 if( node.getAttribute('post') )
70 return node; 70 return node;
71 } while( node = node.parentNode ); 71 } while( node = node.parentNode );
72 } 72 }
73 73
74 function cancelEdit(a) { 74 function cancelEdit(src) {
75 let postDiv = getPostDiv(a); 75 let postDiv = getPostDiv(src);
76 postDiv.querySelector('[output]').style.display = 'block'; 76 postDiv.querySelector('[output]').style.display = 'block';
77 postDiv.querySelector('[edit]').innerHTML = ''; 77 postDiv.querySelector('[edit]').innerHTML = '';
78 } 78 }
79 function saveEdit(a) { 79 function saveEdit(src) {
80 let postDiv = getPostDiv(a); 80 let postDiv = getPostDiv(src);
81 let post = postDiv.getAttribute('post'); 81 let post = postDiv.getAttribute('post');
82 let text = postDiv.querySelector('textarea').value; 82 let text = postDiv.querySelector('textarea').value;
83 let postData = 'post=' + post + '&text=' + encodeURIComponent(text); 83 let postData = 'post=' + post + '&text=' + encodeURIComponent(text);
84 ajax("save_edit.js",postData); 84 ajax("save_edit.js",postData);
85 }
86
87 function upload(src) {
88 let postDiv = getPostDiv(src);
89 let textarea = postDiv.querySelector('textarea');
90 textarea.focus();
91 textarea.setRangeText('xyz',textarea.selectionStart,textarea.selectionEnd,'select');
85 } 92 }
86 93
87 function deletePost(span) { 94 function deletePost(span) {
88 span.innerHTML = document.querySelector('[hidden][delete]').innerHTML; 95 span.innerHTML = document.querySelector('[hidden][delete]').innerHTML;
89 } 96 }
140 <span hidden delete>Delete? <a href="javascript:" onclick="deleteYes(parentNode)">yes</a> / <a href="javascript:" onclick="deleteNo(parentNode)">no</a></span> 147 <span hidden delete>Delete? <a href="javascript:" onclick="deleteYes(parentNode)">yes</a> / <a href="javascript:" onclick="deleteNo(parentNode)">no</a></span>
141 <span hidden undelete><%deletePost()%></span> 148 <span hidden undelete><%deletePost()%></span>
142 <div hidden edit> 149 <div hidden edit>
143 <textarea></textarea> 150 <textarea></textarea>
144 <p> 151 <p>
152 <button onclick="upload(this)">upload</button>
145 <button onclick="saveEdit(this)">save</button> 153 <button onclick="saveEdit(this)">save</button>
146 <button onclick="cancelEdit(this)">cancel</button> 154 <button onclick="cancelEdit(this)">cancel</button>
147 </p> 155 </p>
148 </div> 156 </div>
149 </body> 157 </body>