Mercurial Hosting > freedit
view src/edit.js.luan @ 32:72a1b77b4548
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 29 Jul 2022 13:57:20 -0600 |
parents | 66fd3784e60e |
children | 4fdc4ec0050b |
line wrap: on
line source
local Luan = require "luan:Luan.luan" local error = Luan.error local Html = require "luan:Html.luan" local html_encode = Html.encode or error() local Parsers = require "luan:Parsers.luan" local json_string = Parsers.json_string or error() local Io = require "luan:Io.luan" local Http = require "luan:http/Http.luan" local Post = require "site:/lib/Post.luan" return function() local post = Http.request.parameters.post or error() post = Post.get_by_id(post) or error() Io.stdout = Http.response.text_writer() %> let postDiv = document.querySelector('[post="<%=post.id%>"]'); postDiv.querySelector('[output]').style.display = 'none'; postDiv.querySelector('[edit]').innerHTML = document.querySelector('[hidden][edit]').innerHTML; let textarea = postDiv.querySelector('textarea'); textarea.innerHTML = <%= json_string(html_encode(post.content)) %>; textarea.focus(); <% end