window.addEventListener(
"deviceorientation",
function(event) {
console.log(event.alpha);
console.log(event.beta);
console.log(event.gamma);
},
true);
window.addEventListener(
"devicemotion",
function(event) {
console.log(
event.interval,
event.accelerationIncludingGravity.x,
event.acceleration.x,
event.rotationRate.alpha);
},
true);
if(typeof window.orientation == 'undefined'){
console.log(screen.mozOrientation);
}else{
console.log(window.orientation);
}
if (screen.mozLockOrientation([
"landscape-primary",
"landscape-secondary"
])) {
// Успешно заблокировали
} else {
// Невозможно заблокировать
}
screen.addEventListener(
"mozorientationchange",
callbackFunction,
true);
window.addEventListener(
'orientationchange',
callbackFunction,
true);
window.addEventListener(
"lightlevel",
function(event) {
console.log(event.value);
},
true);
window.addEventListener(
"devicelight",
function(event) {
console.log(event.value);
},
true);
window.addEventListener(
"deviceproximity",
function(event) {
console.log(event.value+' cm');
console.log(event.min+' cm');
console.log(event.max+' cm');
},
true);
window.addEventListener(
"userproximity",
function(event) {
if (event.near) {
// Близко
}else{
// Далеко
}},
true);
navigator.vibrate([50, 100, 1000]);
navigator.vibrate(500);
navigator.vibrate([]);
navigator.vibrate(0);
var connection = navigator.connection ||
navigator.mozConnection ||
navigator.webkitConnection;
function updateConnectionStatus() {
console.log(connection.bandwidth);
console.log(connection.metered);
}
connection.addEventListener(
"change",
updateConnectionStatus,
true);
updateConnectionStatus();
Notification.permission
Notification.requestPermission(callback);
function callback(permission){
if(permission == "granted"){
// Разрешено
}else{
// Запрещено
}
}
new Notification("Заголовок",{
icon: "icon.png",
body: "Сообщение",
dir: "ltr",
lang: "ru-RU",
tag: "deadline"
});
var battery = navigator.battery ||
navigator.mozBattery ||
navigator.webkitBattery;
Anton Nemtsev
http://frontender.info/
thesilentimp@gmail.com
@silentimp
skype: ravencry