Created
August 18, 2017 07:07
-
-
Save Zatnosk/8f93d6ae45ac117d72d071b715e77aa9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Public Timeline</title> | |
<script> | |
function show_timeline(instance, parent){ | |
var request = new XMLHttpRequest(); | |
request.open('GET',instance+'/api/v1/timelines/public'); | |
request.addEventListener('load',function(){ | |
if(this.status == 200){ | |
display(JSON.parse(this.responseText)); | |
} | |
}) | |
request.send(); | |
function display(timeline){ | |
for(var i=0; i < timeline.length; i++){ | |
var div = document.createElement('div'); | |
// Build the markup of a toot here | |
div.innerHTML = timeline[i].content; | |
parent.appendChild(div); | |
} | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<script> | |
// set instance to the URI of the server | |
// set parent to the DOM element that should contain all the toots | |
var instance = "https://mastodon.social"; | |
var parent = document.body; | |
show_timeline(instance, parent); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment