Added ability to view event JSON.

This commit is contained in:
Thomas Mathews 2022-12-30 17:21:19 -08:00
parent a0e2b04501
commit 239c9bfb62
4 changed files with 38 additions and 2 deletions

View file

@ -507,6 +507,15 @@ label[role="profile-nip5"] {
margin: 15px 0;
}
/* Event Preview */
#event-details .modal-content > div {
overflow: scroll;
}
code {
tab-size: 4;
}
/* Settings */
#settings section {

View file

@ -253,6 +253,19 @@
</div>
</div>
</div>
<div id="event-details" class="modal closed">
<div class="modal-content">
<header>
<label>Event Details</label>
<button class="icon modal-floating-close-btn" onclick="close_modal(this)">
<img class="icon svg" src="icon/close-modal.svg"/>
</button>
</header>
<div>
<pre><code></code></pre>
</div>
</div>
</div>
<div id="faqs" class="modal scrollable closed">
<button class="icon modal-floating-close-btn" onclick="close_modal(this)">

View file

@ -183,13 +183,17 @@ function render_action_bar(model, ev, opts={}) {
</button>`;
}
str += `
<button class="icon" title="View Thread" role="view-event"
<button class="icon" title="View Thread" role="view-thread"
onclick="open_thread('${thread_root}')">
<img class="icon svg small" src="icon/open-thread.svg"/>
</button>
<button class="icon" title="View Replies" role="view-event"
<button class="icon" title="View Replies" role="view-replies"
onclick="open_thread('${ev.id}')">
<img class="icon svg small" src="icon/open-thread-here.svg"/>
</button>
<button class="icon" title="View Event JSON" role="view-event-json"
onclick="on_click_show_event_details('${ev.id}')">
<img class="icon svg small" src="icon/event-details.svg"/>
</button>`;
if (can_delete) {
const delete_id = shared ? shared.share_evid : ev.id;

View file

@ -353,3 +353,13 @@ function click_update_profile() {
close_modal(el);
// TODO show toast that say's "broadcasted!"
}
function on_click_show_event_details(evid) {
const model = DAMUS;
const ev = model.all_events[evid];
if (!ev)
return;
const el = find_node("#event-details");
el.classList.remove("closed");
find_node("code", el).innerText = JSON.stringify(ev, null, "\t");
}