All Projects → pstadler → Battery.js

pstadler / Battery.js

Licence: mit
A tiny wrapper for the HTML5 Battery Status API.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Battery.js

Uxp
This is a GitHub mirror of the Unified XUL Platform. The main repository can be found at https://repo.palemoon.org/MoonchildProductions/UXP/
Stars: ✭ 363 (+227.03%)
Mutual labels:  browser, html5
Discord.io
A small, single-file library for creating DiscordApp clients from Node.js or the browser
Stars: ✭ 511 (+360.36%)
Mutual labels:  library, browser
Lambdahack
Haskell game engine library for roguelike dungeon crawlers; please offer feedback, e.g., after trying out the sample game with the web frontend at
Stars: ✭ 439 (+295.5%)
Mutual labels:  library, html5
Layerjs
layerJS: Javascript UI composition framework
Stars: ✭ 1,825 (+1544.14%)
Mutual labels:  library, html5
Ip Kvm Interface
DIY IP-KVM for Remote Desktop Access
Stars: ✭ 62 (-44.14%)
Mutual labels:  browser, html5
Mtproto Core
Telegram API JS (MTProto) client library for browser and nodejs
Stars: ✭ 242 (+118.02%)
Mutual labels:  library, browser
Theannoyingsite.com
The Annoying Site a.k.a. "The Power of the Web Platform"
Stars: ✭ 446 (+301.8%)
Mutual labels:  browser, html5
Chromely
Build HTML Desktop Apps on .NET/.NET Core/.NET 5 using native GUI, HTML5, JavaScript, CSS
Stars: ✭ 2,728 (+2357.66%)
Mutual labels:  browser, html5
Minipaint
online image editor
Stars: ✭ 1,014 (+813.51%)
Mutual labels:  browser, html5
Slim.js
Fast & Robust Front-End Micro-framework based on modern standards
Stars: ✭ 789 (+610.81%)
Mutual labels:  library, html5
Fos
Web Components to turn your web app into a fake operating system
Stars: ✭ 151 (+36.04%)
Mutual labels:  library, html5
Front End Resource Collection
前后端日常总结
Stars: ✭ 82 (-26.13%)
Mutual labels:  browser, html5
Easydeviceinfo
📱 [Android Library] Get device information in a super easy way.
Stars: ✭ 1,698 (+1429.73%)
Mutual labels:  library, battery
Greenfield
HTML5 Wayland compositor 🌱
Stars: ✭ 296 (+166.67%)
Mutual labels:  browser, html5
Browser Id3 Writer
Pure JS library for writing ID3 tag to MP3 files in browsers and Node.js ✍️
Stars: ✭ 132 (+18.92%)
Mutual labels:  library, browser
Drag Drop
HTML5 drag & drop for humans
Stars: ✭ 443 (+299.1%)
Mutual labels:  browser, html5
Sheet Router
fast, modular client-side router
Stars: ✭ 219 (+97.3%)
Mutual labels:  browser, html5
Instascan
HTML5 QR code scanner using your webcam
Stars: ✭ 2,657 (+2293.69%)
Mutual labels:  browser, html5
Webworldwind
The NASA WorldWind Javascript SDK (WebWW) includes the library and examples for creating geo-browser web applications and for embedding a 3D globe in HTML5 web pages.
Stars: ✭ 628 (+465.77%)
Mutual labels:  browser, html5
Noduino
JavaScript and Node.js Framework for controlling Arduino with HTML and WebSockets
Stars: ✭ 1,202 (+982.88%)
Mutual labels:  browser, html5

Battery.js NPM version NPM downloads MIT License

A tiny JavaScript wrapper for the HTML5 Battery Status API.

As of October 2015 the Battery Status API is supported by Firefox, Chrome, Opera, Android Browser and Chrome for Android: http://caniuse.com/battery-status

Due to privacy concerns, support for the Battery Status API has been dropped from most browsers. See: https://caniuse.com/#feat=battery-status.

Install

$ npm install battery.js

Usage

var Battery = require('battery.js'); // or similar

function logBatteryStatus(status) {
  console.log('Level: ' + Math.floor(status.level * 100) + '%'); // 30%
  console.log('Charging: ' + status.charging);                   // true
  console.log('Time until charged: ' + status.chargingTime);     // 3600 (seconds) or Infinity
  console.log('Battery time left: ' + status.dischargingTime);   // 3600 (seconds) or Infinity
}

// Get battery status as soon as it's available
Battery.getStatus(function(status, error) {
  if(error) {
    console.error('Battery status is not supported');
    return;
  }

  logBatteryStatus(status);
});

// Register a handler to get notified when battery status changes
Battery.onUpdate(logBatteryStatus);

Demo

pstadler.sh/battery.js

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].