function getComments(statusId) { $.ajax({ url: "https://tech.lgbt/api/v1/statuses/" + statusId + "/context", type: "get", success: function(replies) { console.log(replies); replies.descendants.forEach(reply => { var timestamp = Date.parse(reply.created_at); var date = new Date(timestamp); var comment = "
"; comment += ""; comment += "
" + reply.account.display_name + " wrote at "; comment += "" + date.toDateString() + ', ' + date.toLocaleTimeString() + "
"; comment += "
" + reply.content + "
"; comment += "
"; if (reply.in_reply_to_id == statusId) { document.getElementById("comments").innerHTML = document.getElementById("comments").innerHTML + comment; } else { var selector = reply.in_reply_to_id; document.getElementById(selector).innerHTML = document.getElementById(selector).innerHTML + comment; } }); var join = "
Join the discussion on Mastodon.
" document.getElementById("comments").innerHTML = document.getElementById("comments").innerHTML + join; } }); };