Created
December 30, 2015 09:32
-
-
Save benfoxall/5c032e69722f3db70a65 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
if('registerElement' in document) { | |
var BenTime = Object.create(HTMLElement.prototype); | |
BenTime.createdCallback = function() { | |
var stamp = parseInt(this.getAttribute('stamp'),10) | |
var delta = Math.abs(stamp - new Date) | |
var s = ~~(delta / 1000) | |
this.innerHTML = s + 's' | |
}; | |
document.registerElement('ben-time', {prototype: BenTime}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment