Created
December 3, 2015 10:47
-
-
Save badeball/8757770c016e2bf9034e 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
function benchmark (callback) { | |
var start = new Date().getMilliseconds(); | |
callback(function () { | |
var end = new Date().getMilliseconds(); | |
console.log("This operation took " + (end - start) + " milliseconds."); | |
}); | |
} | |
benchmark(function (done) { | |
var oldInnerHTML = document.body.innerHTML; | |
document.body.innerHTML = ""; | |
setTimeout(function () { | |
document.body.innerHTML = oldInnerHTML; | |
done(); | |
}); | |
}); |
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
<div id="container"></div> | |
<script> | |
var isSignedIn = false, | |
signedInUser = null; | |
function render () { | |
var container = getELementById("container"); | |
if (isSignedIn) { | |
container.innerHTML = "<p>" + signedInUser + "</p>"; | |
} else { | |
container.innerHTML = "<p>Not signed in</p>"; | |
} | |
} | |
$(window).on("signin", function (user) { | |
isSignedIn = true; | |
signedInUser = user; | |
render(); | |
}); | |
$(window).on("signout", function () { | |
i | |
}); | |
</script> |
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
<div> | |
<p id="user"> | |
Not signed in | |
</p> | |
</div> | |
<script> | |
$(window).on("signin", function (user) { | |
getElementById("user").innerText = "Signed as " + user; | |
}); | |
</script> | |
<script> | |
$(window).on("signout", function () { | |
getElementById("user").innerText = "Not signed in"; | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment