rc3-html-infobeamer/index.html

78 lines
2.5 KiB
HTML
Raw Normal View History

2020-12-22 18:54:35 +01:00
<!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 class="item">Helo 1 sadfsa df sa df as df as dfas d f as df as df sa df a sdf asdf as fd sad f sa df sa fd sa fd sa fd sa df sa df asdf sa df sa df s af</div>
<div class="item">Helo 2 s adf safd sad fs df sa f sa f sa df sa df sa df a sd f asd f safd sad f safd asfd sadf a sfd sadf asdf a sdf a sdf sa fd</div>
</div>
</div>
</div>
</main>
<script>
var tweets = {};
function update_tweets() {
var request = new XMLHttpRequest();
request.open('GET', 'https://api.octycs.eu/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>