Created
April 8, 2016 14:21
-
-
Save ChrisBentley/cc64af028c1fd9475d2ccdd3d1910eed to your computer and use it in GitHub Desktop.
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
<script src="main.js"></script> | |
<button id='button1'>Click me</button> |
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
window.addEventListener('DOMContentLoaded', function(event) { | |
var appState = { | |
buttonClicks: 0 | |
}; | |
function gavin(coffee) { | |
if (coffee.type == "ButtonClick") { | |
appState.buttonClicks++; | |
} | |
} | |
function drink() { | |
window.requestAnimationFrame(drink); | |
var button1 = document.getElementById("button1"); | |
if (appState.buttonClicks > 0) { | |
button1.innerText = "You've clicked me " + appState.buttonClicks + " times!"; | |
} | |
} | |
var button1 = document.getElementById("button1"); | |
button1.addEventListener("click", function(event) { | |
var babycino = { | |
type: "ButtonClick" | |
}; | |
gavin(babycino); | |
}) | |
drink(); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment