-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtimeline.html
More file actions
52 lines (43 loc) · 1.23 KB
/
timeline.html
File metadata and controls
52 lines (43 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Timeline</title>
</head>
<body>
<h1>Timeline de <span id="mastodonUrl"></span></h1>
<ul id="timeline">
</ul>
<script>
var mastodonUrl = "https://hispagatos.space/api/v1/timelines/public";
async function getMastodonTimeline() {
const response = await fetch(mastodonUrl, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
},
});
return response.json();
}
function getMastodonInstanceNameByUrl(url)
{
var instanceName = url.substring("https://".length);
instanceName = instanceName.substring(0, instanceName.indexOf("/"));
return instanceName;
}
var urlElement = document.getElementById("mastodonUrl");
urlElement.innerHTML = getMastodonInstanceNameByUrl(mastodonUrl);
getMastodonTimeline()
.then((data) => {
var timelineElement = document.getElementById("timeline");
for (const toot of data) {
var liElement = document.createElement("li");
liElement.innerHTML = toot["content"];
timelineElement.appendChild(liElement);
}
});
</script>
</body>
</html>