Skip to content

Instantly share code, notes, and snippets.

@picatz
Created August 30, 2018 13:53
Show Gist options
  • Save picatz/670c56e6b995266ace8db3bec5db43e0 to your computer and use it in GitHub Desktop.
Save picatz/670c56e6b995266ace8db3bec5db43e0 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<script src="https://cdn.rawgit.com/picatz/builderJS/8ca588fc/src/builder.js"></script>
</html>
<script>
// instantiate a new builder
var b = new Builder();
// getTime() is a simple function to return the current
// time in the HH:MM:SS format
function getTime() {
return new Date().toLocaleString().split(", ")[1]
}
// currentTime element is an h1 HTML element that updates
// itself every second to show the current time using the
// getTime() function
var currentTime = b.heading({
text: getTime(),
events: {
tick: function() { currentTime.innerText = getTime() }
}
})
// append currentTime element to the document's body
b.append(currentTime)
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment