Created
August 2, 2013 07:38
-
-
Save pongsh/6138131 to your computer and use it in GitHub Desktop.
Retrieves data from the humble bundle website and calculates the average.
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> | |
<body> | |
<div id="info"> | |
</div> | |
</body> | |
<script src=http://cdn.pubnub.com/pubnub-3.5.1.min.js ></script> | |
<script>(function(){ | |
// Init | |
var pubnub = PUBNUB.init({ | |
subscribe_key : '6b5eeae3-796b-11df-8b2d-ef048cc31d2e' | |
}) | |
// LISTEN | |
pubnub.subscribe({ | |
'channel': 'humbledeepsilver_bundle', | |
'callback': function(m){ | |
data = document.createElement('p'); | |
data.innerHTML = "Total payments: " + m.stats.rawtotal + "\n" + | |
"Number of purchases: " + m.stats.numberofcontributions.total + "\n" + | |
"Average: " + m.stats.rawtotal / m.stats.numberofcontributions.total; | |
info = document.getElementById('info'); | |
info.appendChild(data); | |
} | |
}) | |
})();</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment