-
-
Save JimTim/1c4edac29e2a85b4238b to your computer and use it in GitHub Desktop.
OBS new betterplace.org donations
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
var donations = 0, | |
lastCheck = 0, | |
lastFollower = "", | |
project_id = 24307; | |
function checkForNew(){ | |
$.getJSON("https://api.betterplace.org/de/api_v4/fundraising_events/"+project_id+"/opinions.json?order=created_at:DESC&facets=has_donation:true&per_page=1", function(data){ | |
donations = data.total_entries; | |
if(donations > lastCheck && lastCheck!=0){ | |
var d = data.data[0]; | |
if (d.author === null || typeof d.author =="undefined"){ | |
donator = "Anonymer Spender"; | |
} | |
else { | |
donator = d.author.name; | |
} | |
$("#new-follower").html(donator + " (" + d.donated_amount_in_cents/100.0 + "€)"); | |
$("#new-follower").fadeIn("slow"); | |
setTimeout(function(){ | |
$("#new-follower").fadeOut("slow"); | |
}, 10000); | |
} | |
if(donations > lastCheck){ | |
$.getJSON("https://api.betterplace.org/de/api_v4/fundraising_events/"+project_id+".json", function(data){ | |
$("#donation-sum").html(data.donated_amount_in_cents/100.0 + "€<br />Ziel: "+data.requested_amount_in_cents/100.0+"€"); | |
}); | |
} | |
lastCheck = donations; | |
}).fail(function(){ | |
console.log('An error occurred!'); | |
}); | |
} | |
setInterval(checkForNew, 5000); |
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
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Follower Alert</title> | |
<style> | |
body { | |
background-color: transparent; | |
color: white; | |
} | |
#follower-alert { | |
position: absolute; | |
top: 0px; | |
left: 0px; | |
width: 580px; | |
height: 110px; | |
background-repeat: no-repeat; | |
} | |
#follower-alert .text { | |
display: none; | |
margin-left: 140px; | |
padding-top: 45px; | |
text-align: left; | |
width: 385px; | |
line-height: 45px; | |
vertical-align: middle; | |
font-size: 45px; | |
font-family: Impact; | |
text-shadow: 2px 2px 1px #000; | |
white-space: nowrap; | |
color: #ffffff; | |
} | |
#donation-sum { | |
position: absolute; | |
height: 50px; | |
width: 120px; | |
top: 110px; | |
left: 0; | |
text-align: center; | |
font-family: Impact; | |
text-shadow: 2px 2px 1px #000; | |
color: #fff; | |
} | |
</style> | |
<style type="text/css"></style></head> | |
<body> | |
<div id="follower-alert" style="background-image: url(template.png);"> | |
<div class="text" id="new-follower"></div> | |
</div> | |
<div id="donation-sum"></div> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> | |
<script src="gamers4refugees.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I've merged your changes, cause I made new ones, myself.