Skip to content

Instantly share code, notes, and snippets.

@benfoxall
Created December 30, 2015 09:32
Show Gist options
  • Save benfoxall/5c032e69722f3db70a65 to your computer and use it in GitHub Desktop.
Save benfoxall/5c032e69722f3db70a65 to your computer and use it in GitHub Desktop.
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