Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
compassCallback = function (orientation) {
var heading = 360 - orientation.alpha;
if (compassReady) {
if (successCallback)
successCallback( new CompassHeading (heading, heading, 0, 0));
window.removeEventListener("deviceorientation", compassCallback, true);
}
compassReady = true;
};
compassReady = false; // workaround invalid first event value returned by WRT
window.addEventListener("deviceorientation", compassCallback, true);
}
else {
if (errorCallback)
errorCallback(CompassError.COMPASS_NOT_SUPPORTED);
}
},
compassCallback = function (orientation) {
var heading = 360 - orientation.alpha;
if (compassReady) {
if (successCallback)
successCallback( new CompassHeading (heading, heading, 0, 0));
window.removeEventListener("deviceorientation", compassCallback, true);
}
compassReady = true;
};
compassReady = false; // workaround invalid first event value returned by WRT
window.addEventListener("deviceorientation", compassCallback, true);
}
else {
if (errorCallback)
errorCallback(CompassError.COMPASS_NOT_SUPPORTED);
}
},
setTimeout(function () {
lose(CompassError.COMPASS_NOT_SUPPORTED);
}, 0);
} else {
setTimeout(function () {
lose(CompassError.COMPASS_NOT_SUPPORTED);
}, 0);
} else {