HTML API: Battery Status / Page visibility / Vibrate

Date: 2018-10-23
navigator.getBattery().then((battery) => { console.log(battery.charging, battery.level); });
document.addEventListener('visibilitychange', (e) => console.log('visibilitychange', e, document.visibilityState), false);
// enable vibration support
navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate;

if (navigator.vibrate) {
	// vibration API supported
	navigator.vibrate(1000); // one second
	navigator.vibrate([500, 300, 100]); // one second pattern
}

 

15480cookie-checkHTML API: Battery Status / Page visibility / Vibrate