rc3-html-infobeamer/index.html

76 lines
2.1 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="favicon.ico">
<link rel="stylesheet" href="index.css">
<!--<script src="recent.js"></script>-->
<title>rC3 Stream Overlay</title>
</head>
<body style="background:#000">
<main>
<div id="bottom-bar" class="visible">
<div id="ticker-wrap">
<div id="ticker">
</div>
</div>
</div>
</main>
<script>
var tweets = {};
function update_tweets() {
var request = new XMLHttpRequest();
request.open('GET', 'https://api.oct.re/tweets-rc3.json', true);
request.onload = function() {
if (this.status >= 200 && this.status < 400) {
tweets = JSON.parse(this.response);
update_tweet_ticker();
} else {
// We reached our target server, but it returned an error
console.log(this);
}
};
request.onerror = function(e) {
console.log(e);
};
request.send();
}
function update_tweet_ticker() {
var ticker = document.getElementById("ticker");
ticker.innerHTML = "";
for (var i in tweets.data) {
//console.log(tweets.data[i].text);
var item = document.createElement("div");
item.className = "item";
var img = document.createElement("img");
img.src = tweets.includes.users[i].profile_image_url;
item.appendChild(img);
var user = document.createElement("span");
user.className = "user";
var uname = tweets.includes.users[i].username;
user.innerText = "@" + uname;
item.appendChild(user);
var content = document.createElement("span");
content.className = "content";
var text = tweets.data[i].text;
text = text.replace(/\n/g, "↲");
content.innerText = text;
item.appendChild(content);
ticker.appendChild(item);
}
}
update_tweets();
</script>
</body>
</html>