Mercurial Hosting > freedit
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/upload_bbcode.js.luan Mon Aug 01 22:50:16 2022 -0600 @@ -0,0 +1,25 @@ +local Luan = require "luan:Luan.luan" +local error = Luan.error +local stringify = Luan.stringify or error() +local Io = require "luan:Io.luan" +local Http = require "luan:http/Http.luan" +local Shared = require "site:/lib/Shared.luan" +local get_url_from_file = Shared.get_url_from_file or error() +local Logging = require "luan:logging/Logging.luan" +local logger = Logging.logger "test/upload.js" + + +return function() + local post = Http.request.parameters.post or error() + local file = Http.request.parameters.file or error() + --logger.info(stringify(file)); + local url = get_url_from_file(file) + --logger.info("url = "..url) + Io.stdout = Http.response.text_writer() +%> + let postDiv = document.querySelector('[post="<%=post%>"]'); + let textarea = postDiv.querySelector('textarea'); + textarea.focus(); + textarea.setRangeText('<%=url%>',textarea.selectionStart,textarea.selectionEnd,'select'); +<% +end