[Compass]update Compass(tizen_2.1)
authorgs86.lee <gs86.lee@samsung.com>
Fri, 12 Apr 2013 06:29:20 +0000 (15:29 +0900)
committergs86.lee <gs86.lee@samsung.com>
Fri, 12 Apr 2013 06:29:20 +0000 (15:29 +0900)
Change-Id: I4a0c7908b0e857954ada6f64de6979b3b3dbbab9

NOTICE [new file with mode: 0644]
config.xml
index.html
js/main.js

diff --git a/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..85044e4
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,4 @@
+Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Flora License, Version 1.
+Please, see the LICENSE.Flora file for Flora License terms and conditions.
+
index 4b57404..4f4fec7 100644 (file)
@@ -1,11 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<widget xmlns:tizen="http://tizen.org/ns/widgets" xmlns="http://www.w3.org/ns/widgets" id="http://sample-web-application.tizen.org/compass" version="2.0.0" viewmodes="fullscreen">
-       <icon src="icon.png"/>
+<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://sample-web-application.tizen.org/compass" version="2.1.0" viewmodes="fullscreen">
+       <tizen:application id="2dKf9wyV6t.Compass" package="2dKf9wyV6t" required_version="2.1"/>
        <content src="index.html"/>
+       <icon src="icon.png"/>
+       <name>Compass</name>
        <tizen:privilege name="http://tizen.org/privilege/application.read"/>
        <tizen:privilege name="http://tizen.org/privilege/systeminfo"/>
-       <tizen:privilege name="http://tizen.org/privilege/tizen"/>
-       <name>Compass</name>
-       <tizen:application id="8hcnf3vfws" required_version="1.0"/>
-       <tizen:setting screen-orientation="portrait"/>
+       <tizen:setting screen-orientation="portrait" context-menu="disable" background-support="enable" encryption="disable" install-location="auto"/>
 </widget>
index 293fa0f..cc094bb 100644 (file)
@@ -5,18 +5,16 @@
 <meta name="viewport" content="user-scalable=no, width=480">
 <title>Compass</title>
 <link rel="stylesheet" href="./css/style.css" />
-<script type="text/javascript" src="./js/jquery-1.7.1.min.js"></script>
-<script src="./js/main.js"></script>
+<script type="text/javascript" src="./js/jquery-1.7.1.min.js" defer="defer"></script>
+<script src="./js/main.js" defer="defer"></script>
 </head>
-
 <body>
   <div id="application">
     <div id="rotation"><canvas id="canvas" width="392" height="392"></canvas></div>
     <div id="shadow"></div>
-    <div id="direction">NORTHWEST</div>
-    <div id="angle">329<sup>o</sup></div>
-    <div class="exit_button normal" id="exit_button"/></div>
+    <div id="direction"></div>
+    <div id="angle"></div>
+    <div class="exit_button normal" id="exit_button"></div>
   </div>
 </body>
-
 </html>
\ No newline at end of file
index 4d39601..2e57e00 100644 (file)
  *      limitations under the License.
  */
 
-/*jslint browser: true, devel: true */
-/*global tizen, $*/
+/*global document, window, tizen, $*/
 
-var angleMemory = 0,
-       $direction = null,
+var angleMemory = -1,
        rotation = 0;
 
 function onDeviceOrientation(dataEvent) {
        "use strict";
-       var angle = dataEvent.alpha,
-               deltaAngle;
-
-       if (angle <= 22) {
-               $direction.html('NORTH');
-       } else if (angle <= 68) {
-               $direction.html('NORTHEAST');
-       } else if (angle <= 112) {
-               $direction.html('EAST');
-       } else if (angle <= 158) {
-               $direction.html('SOUTHEAST');
-       } else if (angle <= 202) {
-               $direction.html('SOUTH');
-       } else if (angle <= 248) {
-               $direction.html('SOUTHWEST');
-       } else if (angle <= 292) {
-               $direction.html('WEST');
-       } else if (angle <= 338) {
-               $direction.html('NORTHWEST');
-       } else {
-               $direction.html('NORTH');
-       }
-
-       deltaAngle = angleMemory - angle;
+       if (dataEvent.alpha !== angleMemory) {
+               var angle = dataEvent.alpha,
+                       deltaAngle, text = '';
+
+               if (angle < 68 || angle > 292) {
+                       text += 'NORTH';
+               } else if (angle > 112 && angle < 248) {
+                       text += 'SOUTH';
+               }
+               if (angle > 22 && angle < 158) {
+                       text += 'EAST';
+               } else if (angle > 202 && angle < 338) {
+                       text += 'WEST';
+               }
 
-       if (Math.abs(deltaAngle) > 180) {
-               if (deltaAngle > 0) {
-                       rotation -= ((360 - angleMemory) + angle);
+               deltaAngle = angleMemory - angle;
+               if (Math.abs(deltaAngle) > 180) {
+                       if (deltaAngle > 0) {
+                               rotation -= ((360 - angleMemory) + angle);
+                       } else {
+                               rotation += (angleMemory + (360 - angle));
+                       }
                } else {
-                       rotation += (angleMemory + (360 - angle));
+                       rotation += deltaAngle;
                }
-       } else {
-               rotation += deltaAngle;
-       }
 
-       $("#angle").html(Math.round(angle) + "<sup>o</sup>");
-       $('#rotation').css('-webkit-transform', 'rotate(' + (rotation) + 'deg)');
+               angleMemory = angle;
 
-       angleMemory = angle;
+               $('#direction').text(text);
+               $("#angle").html(Math.round(angle) + "<sup>o</sup>");
+               $('#rotation').css('-webkit-transform', 'rotate(' + rotation + 'deg)');
+       }
 }
 
 function startSensor() {
@@ -69,25 +60,17 @@ function startSensor() {
        window.addEventListener("deviceorientation", onDeviceOrientation, false);
 }
 
-function init() {
+function exitButton() {
        "use strict";
-
-       var button = $('#exit_button');
-       $direction = $('#direction');
-
-       button.ontouchstart = function ontouchstart() {
-               $(this).removeClass('normal').addClass('pushed');
-       };
-
-       button.ontouchend = function ontouchend() {
-               $(this).removeClass('pushed').addClass('normal');
+       $('#exit_button').on('click', function () {
+               window.removeEventListener("deviceorientation", onDeviceOrientation, false);
                tizen.application.getCurrentApplication().exit();
-       };
-
-       button
-               .on('touchstart', button.ontouchstart)
-               .on('touchend', button.ontouchend);
+       });
+}
 
+function init() {
+       "use strict";
+       exitButton();
        startSensor();
 }