Presentation: http://sergey.makoveev.info/2013/01/frontend.js-apis-mobile.presentation/ .
Examples: http://goo.gl/5jv4i .
Sources: http://goo.gl/YYj0R .
//, var battery = navigator.battery || navigator.webkitBattery || navigator.mozBattery; //battery.level - ( 0...1) var onlevelchange = function(e) { console.warn("Battery level change: ", battery.level); }; //levelchange - battery.addEventListener("levelchange", onlevelchange); //battery.charging - (true - , false - ) var onchargingchange = function() { console.warn("Battery charge change: ", battery.charging); }; //chargingchange - battery.addEventListener("chargingchange", onchargingchange); //battery.chargingTime - var onchargingtimechange = function() { console.warn("Battery charge time change: ", battery.chargingTime); }; //chargingchange - battery.addEventListener("chargingtimechange", onchargingtimechange); //battery.dischargingTime - var ondischargingtimechange = function() { console.warn("Battery discharging time change: ", battery.dischargingTime); }; //dischargingtimechange - battery.addEventListener("dischargingtimechange", ondischargingtimechange);
// 1 navigator.vibrate(1000); //: 0.5 , 1 , 0.3 navigator.vibrate([500, 1000, 300]); // navigator.vibrate( ('111111111111111111'+ '111111111111111111').split('') .map(function(){ return 300; }) ); // navigator.vibrate(0); // 10 navigator.vibrate(10000); // navigator.vibrate([]);
// screen.orientation - console.log("orientation: " + screen.mozOrientation); // screen.onorientationchange - screen.addEventListener( "mozorientationchange", function() { console.log("orientation: " + screen.mozOrientation); } );
// window.ondeviceorientation - // e.alpha, e.beta, e.gamma - // x, y, z window.addEventListener( "deviceorientation", function(e){ console.log(e.alpha, e.beta, e.gamma); } );
// window.ondevicemotion - // x, y, z : // e.acceleration.x, e.acceleration.y, e.acceleration.z // x, y, z ( ) : // e.accelerationIncludingGravity.x, e.accelerationIncludingGravity.y, e.accelerationIncludingGravity.z // z, x, y ( ) : // e.rotationRate.alpha, e.rotationRate.beta, e.rotationRate.gamma window.addEventListener( "devicemotion", function(e){ console.dir(e.acceleration); console.dir(e.accelerationIncludingGravity); console.dir(e.rotationRate); }; );
window.addEventListener( "devicelight", //e.value - function(e){ console.log(e.value); } ); window.addEventListener( 'lightlevel', // e.value = ("normal"|"dim"|"bright") function(e) { console.log('lightlevel: ' + e.value); } );
window.addEventListener( "deviceproximity", function(e){console.log( e.value, // (!) e.min, // , (==0) e.max // , )} ); window.addEventListener( "userproximity", function(e){console.log( e.near //true - , false - )} );
// , : // document.hidden = (true|false) // document.visibilityState = ("hidden"|"visible"|"prerender"|"unloaded") console.log( document.mozHidden, document.mozVisibilityState ); // : // document.onvisibilitychange = function(e){ ... } document.addEventListener( 'mozvisibilitychange', function(){console.log( document.mozHidden, document.mozVisibilityState );} );
// : // document.fullScreenEnabled = (true|false) console.log('fullScreenEnabled :', document.mozFullScreenEnabled ); // DOM- : // el.requestFullScreen(); document.mozRequestFullScreen(); // , : // document.fullscreenElement console.log('fullscreenElement:', document.mozFullscreenElement); // : // document.cancelFullScreen(); document.mozCancelFullScreen();
Presentation: http://goo.gl/2CkWb .
Examples: http://goo.gl/5jv4i .
Sources: http://goo.gl/YYj0R .
Source: https://habr.com/ru/post/166413/
All Articles