Skip to content

Instantly share code, notes, and snippets.

@yeldarby
Created April 5, 2014 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yeldarby/9994006 to your computer and use it in GitHub Desktop.
Save yeldarby/9994006 to your computer and use it in GitHub Desktop.
Firebase Web Counter
<html>
<head>
<script type='text/javascript' src='https://cdn.firebase.com/js/client/1.0.11/firebase.js'></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script>
$(function() {
var ref = new Firebase('https://cyhack.firebaseio.com');
var counter = ref.child('cyhack2');
counter.on('value', function(snapshot) {
var count = snapshot.val();
$('#counter').text(count);
});
counter.transaction(function(current_value) {
return current_value+1;
});
});
</script>
</head>
<body>
<div id="counter">Loading..</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment