Assign every comment section an ID.
This makes it possible to display several posts on one page.
This commit is contained in:
parent
8776d5cea2
commit
3868593605
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
<!-- Comments via Mastodon-API -->
|
<!-- Comments via Mastodon-API -->
|
||||||
{{ partial "mastodon-api-comments-scripts.html" . }}
|
{{ partial "mastodon-api-comments-scripts.html" . }}
|
||||||
<p class="mastodon-api-comments"></p>
|
<p id="mastodon-api-comments_{{ $status_id }}" class="mastodon-api-comments"></p>
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
fetch_mastodon_api_comments("{{ $instance }}", "{{ $status_id }}");
|
fetch_mastodon_api_comments("{{ $instance }}", "{{ $status_id }}");
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
function fetch_mastodon_api_comments(instance, status_id)
|
function fetch_mastodon_api_comments(instance, status_id)
|
||||||
{
|
{
|
||||||
const root = document.getElementById("mastodon-api-comments");
|
const root = document.getElementById("mastodon-api-comments_" + status_id);
|
||||||
|
|
||||||
let api = new MastodonAPI(
|
let api = new MastodonAPI(
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ function fetch_mastodon_api_comments(instance, status_id)
|
||||||
// Get all the replies to the status and write them to the page.
|
// Get all the replies to the status and write them to the page.
|
||||||
api.get("statuses/" + status_id + "/context", function(data)
|
api.get("statuses/" + status_id + "/context", function(data)
|
||||||
{
|
{
|
||||||
write_comments(data);
|
write_comments(root, data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,10 +39,8 @@ function comments_intro(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function write_comments(data)
|
function write_comments(root, data)
|
||||||
{
|
{
|
||||||
const root = document.getElementById("mastodon-api-comments");
|
|
||||||
|
|
||||||
for (const status of data.descendants)
|
for (const status of data.descendants)
|
||||||
{
|
{
|
||||||
let content = status.content;
|
let content = status.content;
|
||||||
|
|
Loading…
Reference in New Issue