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
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
getHeading: function (win, lose) {
var deviceCompass = Windows.Devices.Sensors.Compass.getDefault();
if (!deviceCompass) {
setTimeout(function () {
lose(CompassError.COMPASS_NOT_SUPPORTED);
}, 0);
} else {
var reading = deviceCompass.getCurrentReading(),
heading = new CompassHeading(reading.headingMagneticNorth, reading.headingTrueNorth, null, reading.timestamp.getTime());
setTimeout(function () {
win(heading);
}, 0);
}
},
stopHeading: function (win, lose) {
getHeading: function (win, lose) {
var deviceCompass = Windows.Devices.Sensors.Compass.getDefault();
if (!deviceCompass) {
setTimeout(function () {
lose(CompassError.COMPASS_NOT_SUPPORTED);
}, 0);
} else {
var reading = deviceCompass.getCurrentReading(),
heading = new CompassHeading(reading.headingMagneticNorth, reading.headingTrueNorth, null, reading.timestamp.getTime());
setTimeout(function () {
win(heading);
}, 0);
}
},
stopHeading: function (win, lose) {