Created
July 22, 2019 08:40
-
-
Save anthonybaldwin/767cab3977ff4d5f1c204d777f2b35e0 to your computer and use it in GitHub Desktop.
WIP: Follower animations using animate.css and Streamlabs Labels
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> | |
<meta http-equiv="Content-type" content="text/html;charset=UTF-8"> | |
<script type="text/javascript" src="http://localhost:8888/ticker.js"></script> | |
<link rel="stylesheet" type="text/css" href="http://localhost:8888/animate.css"> | |
<style type='text/css'> | |
body { | |
font-family: 'Open Sans', Arial, sans-serif; | |
font-weight: bold; | |
color: #000000; | |
text-transform: uppercase; | |
font-size: 14px; | |
padding-left: 5px; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="follower" class="animated bounce fast"></div> | |
<div id="followerCheck" style="visibility:hidden;"></div> | |
<script> | |
window.onload = function () { | |
text = loadFile("follower", "most_recent_follower.txt", false); | |
textCheck = loadFile("follower", "most_recent_follower.txt", true); | |
function ticker() | |
{ | |
let mainText = document.getElementById("follower"); | |
let hiddenText = document.getElementById("followerCheck"); | |
mainText.classList.remove('animated','bounce','fast'); | |
textCheck = loadFile("follower", "most_recent_follower.txt", true); | |
let pageText = document.getElementById("follower").innerHTML; | |
let newPageText = document.getElementById("followerCheck").innerHTML; | |
if (pageText != newPageText) | |
{ | |
mainText.classList.add('animated', 'hinge', 'faster'); | |
mainText.addEventListener('animationend', function() { | |
mainText.classList.remove('animated', 'hinge', 'faster'); | |
mainText.innerHTML = newPageText; | |
mainText.classList.add('animated','bounceInRight', 'faster'); | |
}) | |
} | |
} | |
setInterval(ticker, 5000); | |
} | |
</script> | |
</body> | |
</html> |
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
#!/usr/bin/env python3 | |
from http.server import HTTPServer, SimpleHTTPRequestHandler, test | |
import sys | |
class CORSRequestHandler (SimpleHTTPRequestHandler): | |
def end_headers (self): | |
self.send_header('Access-Control-Allow-Origin', '*') | |
SimpleHTTPRequestHandler.end_headers(self) | |
if __name__ == '__main__': | |
test(CORSRequestHandler, HTTPServer, port=int(sys.argv[1]) if len(sys.argv) > 1 else 8888) |
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
function loadFile(id, file, isCheck) { | |
var xhttp = new XMLHttpRequest(); | |
xhttp.onreadystatechange = function() { | |
if (this.readyState == 4 && this.status == 200) { | |
if (isCheck) { | |
document.getElementById(id+"Check").innerHTML = this.responseText; | |
} | |
else { | |
document.getElementById(id).innerHTML = this.responseText; | |
} | |
} | |
}; | |
xhttp.open("GET", "http://localhost:8888/"+file, true); | |
xhttp.send(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment