LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code

JS
// Get the location.
navigator.geolocation.getCurrentPosition(function(position) {
    // Get the positioning coordinates.
    var lat = position.coords.latitude;
    var long = position.coords.longitude;

    console.log(lat, long)
});

// DEVICE ORIENTATION
if (window.DeviceOrientationEvent) {
  // Create an event listener
window.addEventListener('deviceorientation', function(event){
      // Get the left-to-right tilt (in degrees).
    var tiltLR = event.gamma;

    // Get the front-to-back tilt (in degrees).
    var titleFB = event.beta;

      // Get the direction of the device (in degrees).
    var direction = event.alpha;
  
    document.querySelector('p').innerText = `TILTLR: ${tiltLR}, TILTFB: ${titleFB}, DIRECTION: ${direction}`;
  });
}

// // Vibrate for 1 second (1000 milliseconds).
// navigator.vibrate(1000);

// Vibrate in sequence.
// navigator.vibrate([500, 250, 500]);

// window.addEventListener('DeviceMotionEvent', function(event) {
//     // Get the ambient light level in lux.
//     var lightLevel = event.value;
  
//     document.querySelector('p').innerText = lightLevel;
// });

// // An event listener for a DeviceProximityEvent.
// window.addEventListener('deviceproximity', function(event) {
//     // The maximum distance the sensor covers (in cm).
//     var max = event.max;

//     // The minimum distance the sensor covers (in cm).
//     var min = event.min;

//     // The device proximity (in cm).
//     var proximity = event.value;
  
//   document.querySelector('p').innerText = max, min, proximity;
// });

// An event listener for a UserProximityEvent.
// window.addEventListener('userproximity', function(event) {
//     if (event.near) {
//         console.log('teste 1')
//     } else {
//         console.log('teste 2')
//     }
// });

// Get the current power level.
// navigator.getBattery().then(function(battery) {
//     document.querySelector('p').innerText = `${battery.level * 100}%`;
// })
Term
Sat, 04/14/2018 - 20:46

Related Codes

Pen ID
Pen ID
Pen ID
Square Adv