Using the HTML5 Battery API
steveedson.co.uk