windows8 update compass
diff --git a/lib/windows8/plugin/windows8/CompassProxy.js b/lib/windows8/plugin/windows8/CompassProxy.js
index 91a4037..1d7e6b3 100644
--- a/lib/windows8/plugin/windows8/CompassProxy.js
+++ b/lib/windows8/plugin/windows8/CompassProxy.js
@@ -19,41 +19,43 @@
*
*/
-/*global Windows:true */
+/*jslint sloppy:true */
+/*global Windows:true, require, module, setTimeout */
var cordova = require('cordova'),
- CompassHeading = require('cordova/plugin/CompassHeading');
+ CompassHeading = require('cordova/plugin/CompassHeading'),
+ CompassError = require('cordova/plugin/CompassError');
module.exports = {
- onReadingChanged:null,
- getHeading:function(win,lose) {
+ onReadingChanged: null,
+ getHeading: function (win, lose) {
var deviceCompass = Windows.Devices.Sensors.Compass.getDefault();
- if(!deviceCompass) {
- setTimeout(function(){lose("Compass not available");},0);
- }
- else {
+ if (!deviceCompass) {
+ setTimeout(function () {
+ lose(CompassError.COMPASS_NOT_SUPPORTED);
+ }, 0);
+ } else {
- deviceCompass.reportInterval = Math.max(16,deviceCompass.minimumReportInterval);
+ deviceCompass.reportInterval = Math.max(16, deviceCompass.minimumReportInterval);
- this.onReadingChanged = function(e) {
- var reading = e.reading;
- var heading = new CompassHeading(reading.headingMagneticNorth, reading.headingTrueNorth);
+ this.onReadingChanged = function (e) {
+ var reading = e.reading,
+ heading = new CompassHeading(reading.headingMagneticNorth, reading.headingTrueNorth, null, reading.timestamp);
win(heading);
};
- deviceCompass.addEventListener("readingchanged",this.onReadingChanged);
+ deviceCompass.addEventListener("readingchanged", this.onReadingChanged);
}
-
},
- stopHeading:function(win,lose) {
+ stopHeading: function (win, lose) {
var deviceCompass = Windows.Devices.Sensors.Compass.getDefault();
- if(!deviceCompass) {
- setTimeout(function(){lose("Compass not available");},0);
- }
- else {
-
- deviceCompass.removeEventListener("readingchanged",this.onReadingChanged);
+ if (!deviceCompass) {
+ setTimeout(function () {
+ lose(CompassError.COMPASS_NOT_SUPPORTED);
+ }, 0);
+ } else {
+ deviceCompass.removeEventListener("readingchanged", this.onReadingChanged);
this.onReadingChanged = null;
deviceCompass.reportInterval = 0;
win();
@@ -62,4 +64,4 @@
}
};
-require("cordova/commandProxy").add("Compass",module.exports);
\ No newline at end of file
+require("cordova/commandProxy").add("Compass", module.exports);
\ No newline at end of file