Repository: cordova-plugin-device-motion Updated Branches: refs/heads/master 2eab1bb8b -> 596258c88
Renamed windows8 -> windows Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/commit/2fe2227a Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/tree/2fe2227a Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/diff/2fe2227a Branch: refs/heads/master Commit: 2fe2227a8eede0f6771780e83029f1499c8873af Parents: 2eab1bb Author: sgrebnov <[email protected]> Authored: Wed Nov 26 20:54:20 2014 +0300 Committer: sgrebnov <[email protected]> Committed: Wed Nov 26 20:54:20 2014 +0300 ---------------------------------------------------------------------- doc/index.md | 4 +- plugin.xml | 9 ++++- src/windows/AccelerometerProxy.js | 70 +++++++++++++++++++++++++++++++++ src/windows8/AccelerometerProxy.js | 70 --------------------------------- 4 files changed, 80 insertions(+), 73 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/2fe2227a/doc/index.md ---------------------------------------------------------------------- diff --git a/doc/index.md b/doc/index.md index 49c23f9..2760621 100644 --- a/doc/index.md +++ b/doc/index.md @@ -46,8 +46,8 @@ Although the object is attached to the global scoped `navigator`, it is not avai - Firefox OS - iOS - Tizen -- Windows Phone 7 and 8 -- Windows 8 +- Windows Phone 8 +- Windows ## Methods http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/2fe2227a/plugin.xml ---------------------------------------------------------------------- diff --git a/plugin.xml b/plugin.xml index 92c3e5b..7ef96dc 100644 --- a/plugin.xml +++ b/plugin.xml @@ -137,7 +137,14 @@ <!-- windows8 --> <platform name="windows8"> - <js-module src="src/windows8/AccelerometerProxy.js" name="AccelerometerProxy"> + <js-module src="src/windows/AccelerometerProxy.js" name="AccelerometerProxy"> + <merges target="" /> + </js-module> + </platform> + + <!-- windows --> + <platform name="windows"> + <js-module src="src/windows/AccelerometerProxy.js" name="AccelerometerProxy"> <merges target="" /> </js-module> </platform> http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/2fe2227a/src/windows/AccelerometerProxy.js ---------------------------------------------------------------------- diff --git a/src/windows/AccelerometerProxy.js b/src/windows/AccelerometerProxy.js new file mode 100644 index 0000000..0b41ba7 --- /dev/null +++ b/src/windows/AccelerometerProxy.js @@ -0,0 +1,70 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + +/*global Windows:true */ + +var cordova = require('cordova'), + Acceleration = require('org.apache.cordova.device-motion.Acceleration'); + +/* This is the actual implementation part that returns the result on Windows 8 +*/ + +module.exports = { + onDataChanged:null, + start:function(win,lose){ + + var accel = Windows.Devices.Sensors.Accelerometer.getDefault(); + if(!accel) { + lose && lose("No accelerometer found"); + } + else { + var self = this; + accel.reportInterval = Math.max(16,accel.minimumReportInterval); + + // store our bound function + this.onDataChanged = function(e) { + var a = e.reading; + win(new Acceleration(a.accelerationX,a.accelerationY,a.accelerationZ)); + }; + accel.addEventListener("readingchanged",this.onDataChanged); + + setTimeout(function(){ + var a = accel.getCurrentReading(); + win(new Acceleration(a.accelerationX,a.accelerationY,a.accelerationZ)); + },0); // async do later + } + }, + stop:function(win,lose){ + win = win || function(){}; + var accel = Windows.Devices.Sensors.Accelerometer.getDefault(); + if(!accel) { + lose && lose("No accelerometer found"); + } + else { + accel.removeEventListener("readingchanged",this.onDataChanged); + this.onDataChanged = null; + accel.reportInterval = 0; // back to the default + win(); + } + } +}; + +require("cordova/exec/proxy").add("Accelerometer",module.exports); http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion/blob/2fe2227a/src/windows8/AccelerometerProxy.js ---------------------------------------------------------------------- diff --git a/src/windows8/AccelerometerProxy.js b/src/windows8/AccelerometerProxy.js deleted file mode 100644 index 0b41ba7..0000000 --- a/src/windows8/AccelerometerProxy.js +++ /dev/null @@ -1,70 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -/*global Windows:true */ - -var cordova = require('cordova'), - Acceleration = require('org.apache.cordova.device-motion.Acceleration'); - -/* This is the actual implementation part that returns the result on Windows 8 -*/ - -module.exports = { - onDataChanged:null, - start:function(win,lose){ - - var accel = Windows.Devices.Sensors.Accelerometer.getDefault(); - if(!accel) { - lose && lose("No accelerometer found"); - } - else { - var self = this; - accel.reportInterval = Math.max(16,accel.minimumReportInterval); - - // store our bound function - this.onDataChanged = function(e) { - var a = e.reading; - win(new Acceleration(a.accelerationX,a.accelerationY,a.accelerationZ)); - }; - accel.addEventListener("readingchanged",this.onDataChanged); - - setTimeout(function(){ - var a = accel.getCurrentReading(); - win(new Acceleration(a.accelerationX,a.accelerationY,a.accelerationZ)); - },0); // async do later - } - }, - stop:function(win,lose){ - win = win || function(){}; - var accel = Windows.Devices.Sensors.Accelerometer.getDefault(); - if(!accel) { - lose && lose("No accelerometer found"); - } - else { - accel.removeEventListener("readingchanged",this.onDataChanged); - this.onDataChanged = null; - accel.reportInterval = 0; // back to the default - win(); - } - } -}; - -require("cordova/exec/proxy").add("Accelerometer",module.exports); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
