I’d like to have this fired off from an “OnClick” function of a button, rather than “onLoad”. I’d also like to know how to stop it doing continuous updates. Example. Click a second time, or run for 2 seconds and stop.
if (window.DeviceOrientationEvent) {
console.log(“DeviceOrientation is supported”);
window.addEventListener(‘deviceorientation’, function(eventData) {
var Cant = eventData.gamma;
var Angle = eventData.beta;
var Dir = eventData.webkitCompassHeading;// take webkitcompass out of here
deviceOrientationHandler(Cant, Angle, Dir);
}, false);
} else {
alert(“Not supported on your device or browser. Sorry.”);
}
function deviceOrientationHandler(Cant, Angle, Dir){
$(‘#m1-Learning-textField4’).val(Angle);
$(‘#m1-Learning-textField5’).val(Dir);
}
-SKnox