comparison src/thread.html.luan @ 33:4fdc4ec0050b

upload with uploadcare
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 01 Aug 2022 22:50:16 -0600
parents 72a1b77b4548
children c8d47981c74f
comparison
equal deleted inserted replaced
32:72a1b77b4548 33:4fdc4ec0050b
7 local Http = require "luan:http/Http.luan" 7 local Http = require "luan:http/Http.luan"
8 local Shared = require "site:/lib/Shared.luan" 8 local Shared = require "site:/lib/Shared.luan"
9 local head = Shared.head or error() 9 local head = Shared.head or error()
10 local header = Shared.header or error() 10 local header = Shared.header or error()
11 local footer = Shared.footer or error() 11 local footer = Shared.footer or error()
12 local get_url_from_file = Shared.get_url_from_file or error()
12 local Forum = require "site:/lib/Forum.luan" 13 local Forum = require "site:/lib/Forum.luan"
13 local forum_title = Forum.title or error() 14 local forum_title = Forum.title or error()
14 local Db = require "site:/lib/Db.luan" 15 local Db = require "site:/lib/Db.luan"
15 local Post = require "site:/lib/Post.luan" 16 local Post = require "site:/lib/Post.luan"
16 local Bbcode = require "site:/lib/Bbcode.luan" 17 local Bbcode = require "site:/lib/Bbcode.luan"
82 let text = postDiv.querySelector('textarea').value; 83 let text = postDiv.querySelector('textarea').value;
83 let postData = 'post=' + post + '&text=' + encodeURIComponent(text); 84 let postData = 'post=' + post + '&text=' + encodeURIComponent(text);
84 ajax("save_edit.js",postData); 85 ajax("save_edit.js",postData);
85 } 86 }
86 87
87 function upload(src) { 88 function upload(input) {
88 let postDiv = getPostDiv(src); 89 let postDiv = getPostDiv(input);
89 let textarea = postDiv.querySelector('textarea'); 90 let post = postDiv.getAttribute('post');
90 textarea.focus(); 91 let file = input.files[0];
91 textarea.setRangeText('xyz',textarea.selectionStart,textarea.selectionEnd,'select'); 92 ajax("/upload_bbcode.js?post="+post,file);
92 } 93 }
93 94
94 function deletePost(span) { 95 function deletePost(span) {
95 span.innerHTML = document.querySelector('[hidden][delete]').innerHTML; 96 span.innerHTML = document.querySelector('[hidden][delete]').innerHTML;
96 } 97 }
147 <span hidden delete>Delete? <a href="javascript:" onclick="deleteYes(parentNode)">yes</a> / <a href="javascript:" onclick="deleteNo(parentNode)">no</a></span> 148 <span hidden delete>Delete? <a href="javascript:" onclick="deleteYes(parentNode)">yes</a> / <a href="javascript:" onclick="deleteNo(parentNode)">no</a></span>
148 <span hidden undelete><%deletePost()%></span> 149 <span hidden undelete><%deletePost()%></span>
149 <div hidden edit> 150 <div hidden edit>
150 <textarea></textarea> 151 <textarea></textarea>
151 <p> 152 <p>
152 <button onclick="upload(this)">upload</button> 153 <label clickable
154 ><input type=file onchange="upload(this)"
155 ><span inline_button>upload</span>
156 </label>
153 <button onclick="saveEdit(this)">save</button> 157 <button onclick="saveEdit(this)">save</button>
154 <button onclick="cancelEdit(this)">cancel</button> 158 <button onclick="cancelEdit(this)">cancel</button>
155 </p> 159 </p>
156 </div> 160 </div>
157 </body> 161 </body>