Guest User

Untitled

a guest
Dec 11th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. var database = firebase.database();
  2.  
  3.  
  4.  
  5. database.ref().on("value", function(snapshot) {
  6.  
  7. console.log("Logging snapshot.val " + snapshot.val());
  8.  
  9. console.log("Logging hits " + snapshot.val().hits);
  10.  
  11. var hitCounter = snapshot.val().hits;
  12.  
  13. console.log("hitCounter is " + hitCounter)
  14. }, function(errorObject) {
  15.  
  16. console.log("The read failed: " + errorObject.code);
  17. });
  18.  
  19. //so I can get it to display the value in the database, but not to increase. WTF
  20. function showStuff() {
  21. $("#content").fadeIn("slow");
  22.  
  23. hitCounter++;
  24. console.log("hitCounter in showstuff() function is = " + hitCounter);
  25. //this console log above doesn't even fire. WTF!?
  26. //Ask on stack overflow some other time
  27.  
  28. database.ref().set({
  29. hits: hitCounter
  30. });
  31.  
  32.  
  33. }
Add Comment
Please, Sign In to add comment