Mercurial Hosting > freedit
comparison src/upload_bbcode.js.luan @ 33:4fdc4ec0050b
upload with uploadcare
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 01 Aug 2022 22:50:16 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
32:72a1b77b4548 | 33:4fdc4ec0050b |
---|---|
1 local Luan = require "luan:Luan.luan" | |
2 local error = Luan.error | |
3 local stringify = Luan.stringify or error() | |
4 local Io = require "luan:Io.luan" | |
5 local Http = require "luan:http/Http.luan" | |
6 local Shared = require "site:/lib/Shared.luan" | |
7 local get_url_from_file = Shared.get_url_from_file or error() | |
8 local Logging = require "luan:logging/Logging.luan" | |
9 local logger = Logging.logger "test/upload.js" | |
10 | |
11 | |
12 return function() | |
13 local post = Http.request.parameters.post or error() | |
14 local file = Http.request.parameters.file or error() | |
15 --logger.info(stringify(file)); | |
16 local url = get_url_from_file(file) | |
17 --logger.info("url = "..url) | |
18 Io.stdout = Http.response.text_writer() | |
19 %> | |
20 let postDiv = document.querySelector('[post="<%=post%>"]'); | |
21 let textarea = postDiv.querySelector('textarea'); | |
22 textarea.focus(); | |
23 textarea.setRangeText('<%=url%>',textarea.selectionStart,textarea.selectionEnd,'select'); | |
24 <% | |
25 end |