[OpenLayers-Commits] r11192 - sandbox/cmoullet/openlayers/examples

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Mon Feb 21 10:19:08 EST 2011


Author: cmoullet
Date: 2011-02-21 07:19:08 -0800 (Mon, 21 Feb 2011)
New Revision: 11192

Modified:
   sandbox/cmoullet/openlayers/examples/accelerometer.html
Log:
Fix event handling of acceleration

Modified: sandbox/cmoullet/openlayers/examples/accelerometer.html
===================================================================
--- sandbox/cmoullet/openlayers/examples/accelerometer.html	2011-02-21 15:16:37 UTC (rev 11191)
+++ sandbox/cmoullet/openlayers/examples/accelerometer.html	2011-02-21 15:19:08 UTC (rev 11192)
@@ -15,11 +15,10 @@
     </style>
     <script type="text/javascript">
         function init() {
-            document.getElementById('result');
             if (isEventSupported('deviceorientation', window) || isEventSupported('mozorientation', window) || isEventSupported('devicemotion', window)) {
                 if (window.DeviceOrientationEvent) {
                     alert("window.DeviceOrientationEvent supported");
-                    window.addEventListener("deviceorientation", function () {
+                    window.addEventListener("deviceorientation", function (event) {
                         document.getElementById('result').innerHTML = "Alpha: " + event.alpha;
                         document.getElementById('result').innerHTML = document.getElementById('result').innerHTML + "Beta: " + event.beta;
                         document.getElementById('result').innerHTML = document.getElementById('result').innerHTML + "Gamma: " + event.gamma;
@@ -27,7 +26,7 @@
                 }
                 if (window.DeviceMotionEvent) {
                     alert("window.DeviceMotionEvent supported");
-                    window.addEventListener('devicemotion', function () {
+                    window.addEventListener('devicemotion', function (event) {
                         document.getElementById('result').innerHTML = "acceleration.x: " + event.acceleration.x;
                         document.getElementById('result').innerHTML = document.getElementById('result').innerHTML + "acceleration.y: " + event.acceleration.y;
                         document.getElementById('result').innerHTML = document.getElementById('result').innerHTML + "acceleration.z: " + event.acceleration.z;
@@ -41,7 +40,7 @@
                 }
                 if (window.MozOrientation) {
                     alert("window.MozOrientation supported");
-                    window.addEventListener("MozOrientation", function () {
+                    window.addEventListener("MozOrientation", function (orientation) {
                         document.getElementById('result').innerHTML = "orientation.x: " + orientation.x;
                         document.getElementById('result').innerHTML = document.getElementById('result').innerHTML + "orientation.y: " + orientation.y;
                         document.getElementById('result').innerHTML = document.getElementById('result').innerHTML + "orientation.z: " + orientation.z;



More information about the Commits mailing list