diff options
author | pdp8 <pdp8@pdp8.info> | 2023-06-26 11:20:38 +0200 |
---|---|---|
committer | pdp8 <pdp8@pdp8.info> | 2023-06-26 11:20:38 +0200 |
commit | 8453f524515941f3c0a65b5ca3b9354be76b4c33 (patch) | |
tree | c33131d99193f5a5875ae1869e8cafa11e2a803e /views | |
parent | cec92f7d472c53bdd5d2aa480179ee30c27e8b38 (diff) |
hidden reply form
Diffstat (limited to 'views')
-rw-r--r-- | views/index.erb | 18 | ||||
-rw-r--r-- | views/item.erb | 10 |
2 files changed, 25 insertions, 3 deletions
diff --git a/views/index.erb b/views/index.erb index 269c495..0021ec9 100644 --- a/views/index.erb +++ b/views/index.erb @@ -18,4 +18,22 @@ </form> <% end %> </body> + <script> + const reply_buttons = document.querySelectorAll(".reply"); + for (const button of reply_buttons) { + button.addEventListener('click', function() { + const form = document.getElementById('form' + button.getAttribute('data-index')); + button.style.display = 'none'; + form.style.display = 'block'; + }); + }; + const cancel_buttons = document.querySelectorAll(".cancel"); + for (const button of cancel_buttons) { + button.addEventListener('click', function() { + const form = document.getElementById('form' + button.getAttribute('data-index')); + button.style.display = 'block'; + form.style.display = 'none'; + }); + }; + </script> </html> diff --git a/views/item.erb b/views/item.erb index 287054e..ebc632e 100644 --- a/views/item.erb +++ b/views/item.erb @@ -35,12 +35,16 @@ <% end %> <% end %> <% end %> - <form action='/outbox' method='post'> + <p> + <button class="reply" data-index='<%= @item[:nr] %>'>Reply</button> + <form action='/outbox' method='post' id='form<%= @item[:nr] %>' style='display:none;' > <input type='hidden' name='to' value='<%= @item[:actor_url] %>' /> <input type='hidden' name='inReplyTo' value='<%= @item[:id] %>' /> <input type='hidden' name='redirect' value='/<%= @dir.sub('inbox','') %>#<%= @item[:nr] %>' /> - <textarea name="content"></textarea> - <input type="submit" value="Reply"> + <textarea name='content'></textarea> + <br> + <button class="cancel" data-index='<%= @item[:nr] %>'>Cancel</button> + <input type='submit' value='Send'> </form> </div> <% @item[:replies].each do |reply| %> |