This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
bdfr-browser/priv/templates/http/chat.eex

47 lines
1.5 KiB
Elixir
Raw Normal View History

<h2>Chats</h2>
<%= for message <- messages do %>
2023-08-21 11:40:48 +00:00
<div class="row" style="margin-bottom: 2px;"
id="msg-<%= message.id %>"
<%= unless is_nil(message.bookmark) do %>
data-bookmark="<%= message.bookmark %>"
<% end %>
>
<div class="card">
<div class="card-body" style="padding: 8px;">
<blockquote class="blockquote mb-0" style="font-size: 1rem;">
<%= BdfrBrowser.RenderUtils.message(message.message) %>
<footer class="blockquote-footer">
<a href="/user/<%= message.author %>"><%= message.author %></a>,
<small><%= DateTime.to_iso8601(message.posted_at) %></small>
2023-08-21 11:40:48 +00:00
<%= unless is_nil(message.bookmark) do %>
<span class="badge text-bg-secondary"><%= message.bookmark %></span>
<% end %>
</footer>
</blockquote>
</div>
</div>
</div>
<% end %>
2023-08-21 11:40:48 +00:00
<script>
const bookmarks = document.querySelectorAll('[data-bookmark]');
const header = document.getElementsByTagName('h2')[0];
let container = document.createElement('p');
for (var i = 0; i < bookmarks.length; i++) {
let bookmarkElement = document.createElement('a');
bookmarkElement.href = `#${bookmarks[i].id}`;
bookmarkElement.innerText = bookmarks[i].dataset.bookmark;
bookmarkElement.className = "btn btn-secondary btn-sm";
bookmarkElement.setAttribute('role', 'button');
container.appendChild(bookmarkElement);
2023-08-21 15:29:46 +00:00
container.appendChild(document.createTextNode(' '));
2023-08-21 11:40:48 +00:00
}
header.after(container);
</script>