Update code lines in Training based on new rules 82/134082/1
authorEditor Lionbridge <TizenEditor.SEL@lionbridge.com>
Wed, 14 Jun 2017 11:35:00 +0000 (14:35 +0300)
committerEditor Lionbridge <TizenEditor.SEL@lionbridge.com>
Wed, 14 Jun 2017 11:35:00 +0000 (14:35 +0300)
This is a manual cherry-pick from the #130714 change in the tizen_3.0
branch.
The cherry-pick is not identical, because the branches have some synch
differences, but the same code-related checks have been made and all
found issues fixed.

Change-Id: I55e0c389ef76fed921426b526aa5cf063ed5db1d

12 files changed:
org.tizen.training/html/native/details/app_filtering_n.htm
org.tizen.training/html/native/feature/app_connectivity_operation_n.htm
org.tizen.training/html/native/feature/app_connectivity_usage_n.htm
org.tizen.training/html/native/feature/app_contacts_management_n.htm
org.tizen.training/html/native/feature/app_multimedia_audio_n.htm
org.tizen.training/html/native/feature/app_multimedia_video_n.htm
org.tizen.training/html/web/details/app_filtering_w.htm
org.tizen.training/html/web/details/event_handling_w.htm
org.tizen.training/html/web/mobile/first_app_mw.htm
org.tizen.training/html/web/wearable/first_app_ww.htm
org.tizen.training/html/web/wearable_watch/first_app_watch_ww.htm
org.tizen.training/html/web/wearable_widget/first_app_widget_ww.htm

index 137a30d..7c908a2 100644 (file)
 <p>In a native application, the profile name element can be added to the <code>tizen-manifest.xml</code> file as follows:</p>
 <pre class="prettyprint">
 &lt;manifest xmlns="http://tizen.org/ns/packages" api-version="2.3.1" ... &gt;
-&lt;profile name="mobile"/&gt;
+   &lt;profile name="mobile"/&gt;
 </pre>
 
 <p>The Tizen Store compares the device profile and the <code>profile name</code> element in an application. The store only shows the applications with a profile name matching the device profile to prevent unsupported applications from being installed.</p>
index c696b74..8a46b94 100644 (file)
@@ -176,7 +176,8 @@ main(int argc, char* argv[])
 
 /*
    start_downloading() function utilizes the ecore_thread_feedback_run() function
-   to allow the download_thread_run_cb() function to call the download_feedback_cb function
+   to allow the download_thread_run_cb() function to call the
+   download_feedback_cb function
 */
 static void
 start_downloading(void *data)
@@ -231,7 +232,10 @@ download_thread_run_cb(void *data, Ecore_Thread *thread)
 {
     download_contents(data);
 
-    /* ecore_thread_feedback() invokes download_feedback_cb() registered by ecore_thread_feedback_run () */
+    /*
+       ecore_thread_feedback() invokes download_feedback_cb()
+       registered by ecore_thread_feedback_run()
+    */
     <span class="highlight">ecore_thread_feedback(thread, data);</span>
 }
 
@@ -391,7 +395,8 @@ start_downloading()
 
     /*
        Set the destination path and file name
-       If the values are not given, the default storage and an auto-generated file name are used
+       If the values are not given,
+       the default storage and an auto-generated file name are used
     */
     char *data_path = app_get_data_path();
     error = download_set_destination(download_id, data_path);
index d9c683e..7494d75 100644 (file)
@@ -177,7 +177,8 @@ get_telephony_information(appdata_s *ad, Evas_Object *obj, void *event_info)
 {
     /* Create a telephony handle */
     telephony_handle_list_s handle_list;
-    ret = telephony_init(&amp;handle_list); /* In case of a single SIM, you get only one handle */
+    /* In the case of a single SIM, you get only one handle */
+    ret = telephony_init(&amp;handle_list);
 
     /* Print */
     for (i = 0; i &lt; app_data-&gt;handle_list.count; i++) {
@@ -314,7 +315,8 @@ monitor_telephony_information(appdata_s *ad, Evas_Object *obj, void *event_info)
 {
     /*  Create a telephony handle */
     telephony_handle_list_s handle_list;
-    ret = telephony_init(&amp;handle_list); /* In case of a single SIM, you get only one handle */
+    /* In the case of a single SIM, you get only one handle */
+    ret = telephony_init(&amp;handle_list);
 
     /*
        Register the network_service_state_noti_cb() callback function
index 8f46ad6..fe40f89 100644 (file)
@@ -134,7 +134,7 @@ _get_associated_contacts(contacts_record_h record, contacts_list_h *associated_c
     error_code += contacts_filter_add_int(filter, _contacts_contact.person_id, CONTACTS_MATCH_EQUAL, person_id);
     error_code += contacts_query_set_filter(query, filter);
 
-    /* Run the query to retrieve a list of all contacts associated with the person ID */
+    /* Run the query to retrieve a list of contacts associated with the person ID */
     error_code += contacts_db_get_records_with_query(query, 0, 0, associated_contacts);
 
     /* Destroy the filter and query handles and release all their resources */
@@ -164,7 +164,10 @@ _get_default_phone_number(contacts_record_h record, char **default_phone_number)
     /* Retrieve the person ID from the person record */
     error_code += contacts_record_get_int(record, _contacts_person.id, &amp;person_id);
 
-    /* Create a phone number query with filters for the person ID and default phone number */
+    /*
+       Create a phone number query with filters
+       for the person ID and default phone number
+    */
     error_code += contacts_query_create(_contacts_person_number._uri, &amp;query);
     error_code += contacts_filter_create(_contacts_person_number._uri, &amp;filter);
     error_code += contacts_filter_add_int(filter, _contacts_person_number.person_id, CONTACTS_MATCH_EQUAL, person_id);
@@ -172,7 +175,10 @@ _get_default_phone_number(contacts_record_h record, char **default_phone_number)
     error_code += contacts_filter_add_bool(filter, _contacts_person_number.is_primary_default, true);
     error_code += contacts_query_set_filter(query, filter);
 
-    /* Run the query to retrieve the phone number records containing the default phone number */
+    /*
+       Run the query to retrieve the phone number records
+       containing the default phone number
+    */
     error_code += contacts_db_get_records_with_query(query, 0, 0, &amp;list);
 
     /* Retrieve the current record from the query list */
@@ -432,7 +438,10 @@ error_code += contacts_record_create(_contacts_number._uri, &amp;number);
 error_code += contacts_record_set_str(number, _contacts_number.number, "+8210-1234-5678");
 error_code += contacts_record_add_child_record(contact, _contacts_contact.number, number);
 
-/* Contact is linked automatically if an existing person has the same number in a different address book */
+/*
+   Contact is linked automatically if an existing person has the same number
+   in a different address book
+*/
 error_code += contacts_db_insert_record(contact, NULL);
 
 contacts_record_destroy(contact, true);
index 4893cfe..2a1bc33 100644 (file)
@@ -181,7 +181,10 @@ _player_interrupted_cb(player_interrupted_code_e code, void *data)
     appdata_s *ad = data;
     player_state_e state;
 
-    /* All the interrupted_code_e is deprecated from Tizen 3.0 except PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT */
+    /*
+       All the interrupted_code_e is deprecated since Tizen 3.0
+       except PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT
+    */
     player_get_state(ad-&gt;player, &amp;state);
     dlog_print(DLOG_INFO, LOG_TAG, "current player state = %d", state);
     /* If the state is PLAYER_STATE_PAUSED, update the UI (for example, button) */
@@ -208,7 +211,10 @@ _player_completed_cb(void *data)
 static void
 init_base_player(appdata_s *ad)
 {
-    /* Set a completed callback if the application wants to know when the playback ends */
+    /*
+       Set a completed callback if the application wants to
+       know when the playback ends
+    */
     error_code = player_set_completed_cb(ad-&gt;player, _player_completed_cb, ad);
 
     if (error_code != PLAYER_ERROR_NONE)
index fabd7d1..80abf80 100644 (file)
@@ -182,7 +182,10 @@ _player_interrupted_cb(player_interrupted_code_e code, void *data)
     appdata_s *ad = data;
     player_state_e state;
 
-    /* All the interrupted_code_e is deprecated from Tizen 3.0 except PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT */
+    /*
+       All the interrupted_code_e is deprecated since Tizen 3.0
+       except PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT
+    */
     player_get_state(ad-&gt;player, &amp;state);
     dlog_print(DLOG_INFO, LOG_TAG, "current player state = %d", state);
     /* If the state is PLAYER_STATE_PAUSED, update the UI (for example, button) */
index 5c8fbc2..7d5613d 100644 (file)
 <p>In a Web application, the profile name element can be added to the <code>config.xml</code> file as follows:</p>
 <pre class="prettyprint">
 &lt;widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" ... &gt;
-&lt;tizen:profile name="mobile"/&gt;
-&lt;!--OR--&gt;
-&lt;tizen:profile name="wearable"/&gt;
+   &lt;tizen:profile name="mobile"/&gt;
 </pre>
 
 <p>The Tizen Store compares the device profile and the <code>profile name</code> element in an application. The store only shows the applications with a profile name matching the device profile to prevent unsupported applications from being installed.</p>
index 72c323e..035f98c 100644 (file)
 
 <p>To bind an event callback on rotary events, use the following code:</p>
 <pre class="prettyprint">
-document.addEventListener("rotarydetent", function(ev)
-{
-   /* Get the direction value from the event */
-   var direction = ev.detail.direction;
-
-   if (direction == "CW")
-   {
-      /* Add behavior for clockwise rotation */
-      console.log("clockwise");
-   }
-   else if (direction == "CCW")
-   {
-      /* Add behavior for counter-clockwise rotation */
-      console.log("counter-clockwise");
-   }
+document.addEventListener('rotarydetent', function(ev) {
+    /* Get the direction value from the event */
+    var direction = ev.detail.direction;
+
+    if (direction == 'CW') {
+        /* Add behavior for clockwise rotation */
+        console.log('clockwise');
+    } else if (direction == 'CCW') {
+        /* Add behavior for counter-clockwise rotation */
+        console.log('counter-clockwise');
+    }
 });
 </pre>
 
@@ -92,7 +88,7 @@ document.addEventListener("rotarydetent", function(ev)
 
 <pre class="prettyprint">
 /* Check whether high color mode is supported */
-var isHighColorMode = tizen.systeminfo.getCapability("http://tizen.org/feature/screen.always_on.high_color");
+var isHighColorMode = tizen.systeminfo.getCapability('http://tizen.org/feature/screen.always_on.high_color');
 </pre>
 
 <p>The following table describes the ambient mode events.</p>
@@ -128,22 +124,17 @@ var isHighColorMode = tizen.systeminfo.getCapability("http://tizen.org/feature/s
 
 <p>To bind an event callback on ambient events, use the following code:</p>
 <pre class="prettyprint">
-document.addEventListener("ambientmodechanged", function(ev)
-{
-   var mode = ev.detail.ambientMode;
-   if (mode == true)
-   {
-      /* Change the UI for ambient mode */
-   }
-   else
-   {
-      /* Change the UI for normal mode */
-   }
+document.addEventListener('ambientmodechanged', function(ev) {
+    var mode = ev.detail.ambientMode;
+    if (mode == true) {
+        /* Change the UI for ambient mode */
+    } else {
+        /* Change the UI for normal mode */
+    }
 });
 
-document.addEventListener("timetick", function(ev)
-{
-   /* Update the UI */
+document.addEventListener('timetick', function(ev) {
+    /* Update the UI */
 });
 </pre>
 
index 88db5c1..d4309c1 100644 (file)
 <li><code>css/style.css</code>:
 <pre class="prettyprint">
 html,
-body
-{
+body {
    width: 100%;
    height: 100%;
    margin: 0 auto;
@@ -468,21 +467,18 @@ body
    background-color: #222222;
    color: #ffffff;
 }
-.page
-{
+.page {
    width: 100%;
    height: 100%;
    display: table;
 }
-.contents
-{
+.contents {
    display: table-cell;
    vertical-align: middle;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
 }
-#content-text
-{
+#content-text {
    font-weight: bold;
    font-size: 5em;
 }
@@ -503,8 +499,7 @@ body
 <p>By default, the text uses the <code>#ffffff</code> color (white), defined for the <code>&lt;body&gt;</code> element. If you change the CSS code and add a separate color for the <code>content-text</code> class, the text color changes (in this case, to <code>#ff0000</code> red):</p>
 
 <pre class="prettyprint">
-#content-text
-{
+#content-text {
    font-weight: bold;
    font-size: 5em;
    <span class="highlight">color: #ff0000;</span>
@@ -651,12 +646,10 @@ body
 <p>In the <code>style.css</code> file, add the CSS styles for the new <code>id</code> attributes:
 </p>
 <pre class="prettyprint">
-#contentArea
-{
+#contentArea {
    background-color: white;
 }
-#footerArea
-{
+#footerArea {
    background-color: blue;
 }
 </pre>
@@ -773,8 +766,7 @@ body
 <p> Decorate the page in the same way as <code>index.html</code>. In the <code>style.css</code> file, add the following CSS style:</p>
 
 <pre class="prettyprint">
-#secondPage
-{
+#secondPage {
    background-color: white;
 }
 </pre>
@@ -830,21 +822,17 @@ body
 <p>In the <code>app.js</code> file, all kinds of logic can be added to the application. In this case, add several lines for handling navigation:</p>
 
 <pre class="prettyprint">
-(function()
-{
-   window.addEventListener('tizenhwkey', function(ev)
-   {
-      if (ev.keyName === "back")
-      {
-         var page = document.getElementsByClassName('ui-page-active')[0],
-             pageid = page ? page.id : "";
-
-         if (pageid !== "main")
-         {
-            window.history.back();
-         }
-      }
-   });
+(function() {
+    window.addEventListener('tizenhwkey', function(ev) {
+        if (ev.keyName === 'back') {
+            var page = document.getElementsByClassName('ui-page-active')[0],
+                pageid = page ? page.id : '';
+
+            if (pageid !== 'main') {
+                window.history.back();
+            }
+        }
+    });
 }());
 </pre></li></ol>
 </li>
@@ -854,31 +842,21 @@ body
 <p>You have to consider the fact that when the user clicks the back key, the application can only exit if it is showing the main page. If the second page is showing, the application must return to the main page.</p>
 <p>The following example shows how to handle the back key input with page navigation and application exit. This code is included in the <strong>TAU Basic</strong> project template <code>main.js</code> file by default.</p>
 <pre class="prettyprint">
-(function()
-{
-   window.addEventListener('tizenhwkey', function(ev)
-   {
-      if (ev.keyName === "back")
-      {
-         var page = document.getElementsByClassName('ui-page-active')[0],
-             pageid = page ? page.id : "";
-
-         if (pageid === "main")
-         {
-            try
-            {
-               tizen.application.getCurrentApplication().exit();
-            }
-            catch (ignore)
-            {
+(function() {
+    window.addEventListener('tizenhwkey', function(ev) {
+        if (ev.keyName === 'back') {
+            var page = document.getElementsByClassName('ui-page-active')[0],
+                pageid = page ? page.id : '';
+
+            if (pageid === 'main') {
+                try {
+                    tizen.application.getCurrentApplication().exit();
+                } catch (ignore) {}
+            } else {
+                window.history.back();
             }
-         }
-         else
-         {
-            window.history.back();
-         }
-      }
-   });
+        }
+    });
 }());
 </pre>
 
index f65815d..ed15492 100644 (file)
 <li><code>css/style.css</code>:
 <pre class="prettyprint">
 html,
-body
-{
+body {
    width: 100%;
    height: 100%;
    margin: 0 auto;
@@ -482,21 +481,18 @@ body
    background-color: #222222;
    color: #ffffff;
 }
-.page
-{
+.page {
    width: 100%;
    height: 100%;
    display: table;
 }
-.contents
-{
+.contents {
    display: table-cell;
    vertical-align: middle;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
 }
-#content-text
-{
+#content-text {
    font-weight: bold;
    font-size: 5em;
 }
@@ -517,8 +513,7 @@ body
 <p>By default, the text uses the <code>#ffffff</code> color (white), defined for the <code>&lt;body&gt;</code> element. If you change the CSS code and add a separate color for the <code>content-text</code> class, the text color changes (in this case, to <code>#ff0000</code> red):</p>
 
 <pre class="prettyprint">
-#content-text
-{
+#content-text {
    font-weight: bold;
    font-size: 5em;
    <span class="highlight">color: #ff0000;</span>
@@ -662,8 +657,7 @@ body
 
 <p>In the <code>style.css</code> file, add a CSS style for the new <code>id</code> attribute:</p>
 <pre class="prettyprint">
-#contentArea
-{
+#contentArea {
    color: #8be3d1;
 }
 </pre>
@@ -699,31 +693,26 @@ body
 
 <p>The following example shows how to create a SnapListview using the <code>tau.helper</code> class:</p>
 <pre class="prettyprint">
-(function(tau)
-{
-   var page,
-       list,
-       listHelper;
-
-   /* Check for a circular device */
-   if (tau.support.shape.circle)
-   {
-      document.addEventListener("pagebeforeshow", function(e)
-      {
-         page = e.target;
-         list = page.querySelector(".ui-listview");
-         if (list)
-         {
-            /* Create SnapListView and binding rotary event using tau.helper */
-            listHelper = tau.helper.SnapListStyle.create(list);
-         }
-      });
-
-      document.addEventListener("pagebeforehide", function(e)
-      {
-         listHelper.destroy();
-      });
-   }
+(function(tau) {
+    var page,
+        list,
+        listHelper;
+
+    /* Check for a circular device */
+    if (tau.support.shape.circle) {
+        document.addEventListener('pagebeforeshow', function(e) {
+            page = e.target;
+            list = page.querySelector('.ui-listview');
+            if (list) {
+                /* Create SnapListView and binding rotary event using tau.helper */
+                listHelper = tau.helper.SnapListStyle.create(list);
+            }
+        });
+
+        document.addEventListener('pagebeforehide', function(e) {
+            listHelper.destroy();
+        });
+    }
 }(tau));
 </pre>
 
@@ -812,21 +801,17 @@ body
 
 <p>Overwrite the <code>app.js</code> file content with the following code:</p>
 <pre class="prettyprint">
-(function()
-{
-   window.addEventListener('tizenhwkey', function(ev)
-   {
-      if (ev.keyName === "back")
-      {
-         var page = document.getElementsByClassName('ui-page-active')[0],
-             pageid = page ? page.id : "";
-
-         if (pageid !== "main")
-         {
-            window.history.back();
-         }
-      }
-   });
+(function() {
+    window.addEventListener('tizenhwkey', function(ev) {
+        if (ev.keyName === 'back') {
+            var page = document.getElementsByClassName('ui-page-active')[0],
+                pageid = page ? page.id : '';
+
+            if (pageid !== 'main') {
+                window.history.back();
+            }
+        }
+    });
 }());
 </pre></li></ol>
 </li>
@@ -836,31 +821,21 @@ body
 <p>You have to consider the fact that when the user clicks the back key, the application can only exit if it is showing the main page. If the second page is showing, the application must return to the main page.</p>
 <p>The following example shows how to handle the back key input with page navigation and application exit. This code is included in the <strong>TAU Basic</strong> project template <code>main.js</code> file by default.</p>
 <pre class="prettyprint">
-(function()
-{
-   window.addEventListener('tizenhwkey', function(ev)
-   {
-      if (ev.keyName === "back")
-      {
-         var page = document.getElementsByClassName('ui-page-active')[0],
-             pageid = page ? page.id : "";
-
-         if (pageid === "main")
-         {
-            try
-            {
-               tizen.application.getCurrentApplication().exit();
-            }
-            catch (ignore)
-            {
+(function() {
+    window.addEventListener('tizenhwkey', function(ev) {
+        if (ev.keyName === 'back') {
+            var page = document.getElementsByClassName('ui-page-active')[0],
+                pageid = page ? page.id : '';
+
+            if (pageid === 'main') {
+                try {
+                     tizen.application.getCurrentApplication().exit();
+                } catch (ignore) {}
+            } else {
+                window.history.back();
             }
-         }
-         else
-         {
-            window.history.back();
-         }
-      }
-   });
+        }
+    });
 }());
 </pre>
 
index ad9ddaf..b58e619 100644 (file)
@@ -409,54 +409,48 @@ cd tizen-sdk/tools
 <p>Modify the <code>window.requestAnimationFrame()</code> method to make the application compatible with the main browsers:</p>
 <pre class="prettyprint">
 window.requestAnimationFrame = window.requestAnimationFrame ||
-   window.webkitRequestAnimationFrame ||
-   window.mozRequestAnimationFrame ||
-   window.oRequestAnimationFrame ||
-   window.msRequestAnimationFrame ||
-   function(callback)
-   {
-      'use strict';
-      window.setTimeout(callback, 1000 / 60);
-   };</pre>
+    window.webkitRequestAnimationFrame ||
+    window.mozRequestAnimationFrame ||
+    window.oRequestAnimationFrame ||
+    window.msRequestAnimationFrame ||
+    function(callback) {
+        'use strict';
+        window.setTimeout(callback, 1000 / 60);
+    };
+</pre>
 </li>
 <li>Initialize the canvas context and define the canvas area:
 <pre class="prettyprint">
-window.onload = function onLoad()
-{
-   'use strict';
+window.onload = function onLoad() {
+    'use strict';
 
-   canvas = document.querySelector('canvas');
-   ctx = canvas.getContext('2d');
-   clockRadius = document.body.clientWidth / 2;
+    canvas = document.querySelector('canvas');
+    ctx = canvas.getContext('2d');
+    clockRadius = document.body.clientWidth / 2;
 
-   canvas.width = document.body.clientWidth;
-   canvas.height = canvas.width;</pre>
+    canvas.width = document.body.clientWidth;
+    canvas.height = canvas.width;
+</pre>
 </li>
 <li>Define an event listener to detect back key events and time tick:
 <pre class="prettyprint">
-   /* Add eventListener for tizenhwkey */
-   window.addEventListener('tizenhwkey', function(e)
-   {
-      if (e.keyName === 'back')
-      {
-         try
-         {
-            tizen.application.getCurrentApplication().exit();
-         }
-         catch (err)
-         {
-            console.error('Error: ', err.message);
-         }
-      }
-   });
-
-   /* Add eventListener for timetick */
-   window.addEventListener('timetick', function()
-   {
-      console.log("timetick is called");
-      ambientWatch();
-   });
-}
+    /* Add eventListener for tizenhwkey */
+    window.addEventListener('tizenhwkey', function(e) {
+        if (e.keyName === 'back') {
+            try {
+                tizen.application.getCurrentApplication().exit();
+            } catch (err) {
+                console.error('Error: ', err.message);
+            }
+        }
+    });
+
+    /* Add eventListener for timetick */
+    window.addEventListener('timetick', function() {
+        console.log('timetick is called');
+        ambientWatch();
+    });
+};
 </pre>
 </li>
 
@@ -493,46 +487,47 @@ window.onload = function onLoad()
 <li>
 <p>Create the clock in the middle of the canvas, and define the watch face style:</p>
 <pre class="prettyprint">
-function renderDots()
-{
-   'use strict';
-
-   var dx = 0,
-       dy = 0,
-       i = 1,
-       angle = null;
-
-   ctx.save();
-   ctx.translate(canvas.width / 2, canvas.height / 2);
-   ctx.beginPath();
-   ctx.fillStyle = '#999999';</pre>
+function renderDots() {
+    'use strict';
+
+    var dx = 0,
+        dy = 0,
+        i = 1,
+        angle = null;
+
+    ctx.save();
+    ctx.translate(canvas.width / 2, canvas.height / 2);
+    ctx.beginPath();
+    ctx.fillStyle = '#999999';
+</pre>
 </li>
 <li>Create 4 dots on the sides of the watch face and use the <code>fill()</code> method to style the dots:
 <pre class="prettyprint">
-   for (i = 1; i &lt;= 4; i++)
-   {
-      angle = (i - 3) * (Math.PI * 2) / 4;
-      dx = clockRadius * 0.9 * Math.cos(angle);
-      dy = clockRadius * 0.9 * Math.sin(angle);
-
-      ctx.arc(dx, dy, 3, 0, 2 * Math.PI, false);
-      ctx.fill();
-   }
-   ctx.closePath();</pre>
+    for (i = 1; i &lt;= 4; i++) {
+        angle = (i - 3) * (Math.PI * 2) / 4;
+        dx = clockRadius * 0.9 * Math.cos(angle);
+        dy = clockRadius * 0.9 * Math.sin(angle);
+
+        ctx.arc(dx, dy, 3, 0, 2 * Math.PI, false);
+        ctx.fill();
+    }
+    ctx.closePath();
+</pre>
 </li>
 <li>Create the center point:
 <pre class="prettyprint">
-   ctx.beginPath();
+    ctx.beginPath();
 
-   ctx.fillStyle = '#ff9000';
-   ctx.strokeStyle = '#fff';
-   ctx.lineWidth = 4;
+    ctx.fillStyle = '#ff9000';
+    ctx.strokeStyle = '#fff';
+    ctx.lineWidth = 4;
 
-   ctx.arc(0, 0, 7, 0, 2 * Math.PI, false);
-   ctx.fill();
-   ctx.stroke();
-   ctx.closePath();
-}</pre>
+    ctx.arc(0, 0, 7, 0, 2 * Math.PI, false);
+    ctx.fill();
+    ctx.stroke();
+    ctx.closePath();
+}
+</pre>
 </li>
 </ol>
 </li>
@@ -542,49 +537,49 @@ function renderDots()
 <li>The needles can be created using the <code>renderNeedle()</code> method.
 <p>To create the needle as a triangle or a polygon, assign the coordinate of the beginning point with the <code>moveTo()</code> method. To assign the rest of the points of the triangle or polygon, use the <code>lineTo()</code> method, which defines the position of the next connecting vertex. You can also adjust the size of each clock needle with the <code>lineTo()</code> method.</p>
 <pre class="prettyprint">
-function renderNeedle(angle, radius)
-{
-   'use strict';
-   ctx.save();
-   ctx.rotate(angle);
-   ctx.beginPath();
-   ctx.lineWidth = 4;
-   ctx.strokeStyle = '#fff';
-   ctx.moveTo(6, 0);
-   ctx.lineTo(radius, 0);
-   ctx.closePath();
-   ctx.stroke();
-   ctx.closePath();
-   ctx.restore();
-}</pre>
+function renderNeedle(angle, radius) {
+    'use strict';
+    ctx.save();
+    ctx.rotate(angle);
+    ctx.beginPath();
+    ctx.lineWidth = 4;
+    ctx.strokeStyle = '#fff';
+    ctx.moveTo(6, 0);
+    ctx.lineTo(radius, 0);
+    ctx.closePath();
+    ctx.stroke();
+    ctx.closePath();
+    ctx.restore();
+}
+</pre>
 </li>
 <li>Create the hour needle using the <code>renderHourNeedle()</code> method:
 <pre class="prettyprint">
-function renderHourNeedle(hour)
-{
-   'use strict';
+function renderHourNeedle(hour) {
+    'use strict';
 
-   var angle = null,
-       radius = null;
+    var angle = null,
+        radius = null;
 
-   angle = (hour - 3) * (Math.PI * 2) / 12;
-   radius = clockRadius * 0.55;
-   renderNeedle(angle, radius);
-}</pre>
+    angle = (hour - 3) * (Math.PI * 2) / 12;
+    radius = clockRadius * 0.55;
+    renderNeedle(angle, radius);
+}
+</pre>
 </li>
 <li>Create the minute needle using the <code>renderMinuteNeedle()</code> method:
 <pre class="prettyprint">
-function renderMinuteNeedle(minute)
-{
-   'use strict';
+function renderMinuteNeedle(minute) {
+    'use strict';
 
-   var angle = null,
-       radius = null;
+    var angle = null,
+        radius = null;
 
-   angle = (minute - 15) * (Math.PI * 2) / 60;
-   radius = clockRadius * 0.75;
-   renderNeedle(angle, radius);
-}</pre>
+    angle = (minute - 15) * (Math.PI * 2) / 60;
+    radius = clockRadius * 0.75;
+    renderNeedle(angle, radius);
+}
+</pre>
 </li>
 </ol>
 </li>
@@ -593,57 +588,53 @@ function renderMinuteNeedle(minute)
 <li>Determine the current time using the <code>new Date()</code> method.
 <p>To point the needles accurately, define variables for the current hour and minute.</p>
 <pre class="prettyprint">
-function getDate()
-{
-   'use strict';
-
-   var date;
-   try
-   {
-      date = tizen.time.getCurrentDateTime();
-   }
-   catch (err)
-   {
-      console.error('Error: ', err.message);
-      date = new Date();
-   }
-
-   return date;
+function getDate() {
+    'use strict';
+
+    var date;
+    try {
+        date = tizen.time.getCurrentDateTime();
+    } catch (err) {
+        console.error('Error: ', err.message);
+        date = new Date();
+    }
+
+    return date;
 }
 
-function watch()
-{
-   'use strict';
+function watch() {
+    'use strict';
 
-   if (isAmbientMode === true)
-   {
-      return;
-   }
+    if (isAmbientMode === true) {
+        return;
+    }
 
-   var date = getDate(),
-       hours = date.getHours(),
-       minutes = date.getMinutes(),
-       seconds = date.getSeconds(),
-       hour = hours + minutes / 60,
-       minute = minutes + seconds / 60,
-       nextMove = 1000 - date.getMilliseconds();</pre>
+    var date = getDate(),
+        hours = date.getHours(),
+        minutes = date.getMinutes(),
+        seconds = date.getSeconds(),
+        hour = hours + minutes / 60,
+        minute = minutes + seconds / 60,
+        nextMove = 1000 - date.getMilliseconds();
+</pre>
 </li>
 <li>Every time a new time is indicated, erase the previous time (the previously positioned needles) using the <code>clearRect()</code> method:
 <pre class="prettyprint">
-   ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);</pre>
+    ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
+</pre>
 </li>
 <li>Point the clock needles to display the current time:
 <pre class="prettyprint">
-   renderDots();
-   renderHourNeedle(hour);
-   renderMinuteNeedle(minute);
-
-   ctx.restore();
-   setTimeout(function()
-   {
-      window.requestAnimationFrame(watch);
-   }, nextMove);
-}</pre>
+    renderDots();
+    renderHourNeedle(hour);
+    renderMinuteNeedle(minute);
+
+    ctx.restore();
+    setTimeout(function() {
+        window.requestAnimationFrame(watch);
+    }, nextMove);
+}
+</pre>
 </li>
 
 </ol>
@@ -666,7 +657,7 @@ function watch()
 bool support;
 int ret;
 
-ret = system_info_get_platform_bool("http://tizen.org/feature/screen.always_on.high_color", &amp;support);
+ret = system_info_get_platform_bool('http://tizen.org/feature/screen.always_on.high_color', &amp;support);
 </pre>
     </div>
 
@@ -675,74 +666,67 @@ ret = system_info_get_platform_bool("http://tizen.org/feature/screen.always_on.h
 <li>Define an event listener for the ambient mode:
 <pre class="prettyprint">
 /* Add eventListener for ambientmodechanged */
-window.addEventListener('ambientmodechanged', function(e)
-{
-   console.log("ambientmodechanged: " + e.detail.ambientMode);
-   if (e.detail.ambientMode === true)
-   {
-      /* Render ambient mode */
-      isAmbientMode = true;
-      ambientWatch();
-   }
-   else
-   {
-      /* Render normal mode */
-      isAmbientMode = false;
-      window.requestAnimationFrame(watch);
-   }
+window.addEventListener('ambientmodechanged', function(e) {
+    console.log('ambientmodechanged: ' + e.detail.ambientMode);
+    if (e.detail.ambientMode === true) {
+        /* Render ambient mode */
+        isAmbientMode = true;
+        ambientWatch();
+    } else {
+        /* Render normal mode */
+        isAmbientMode = false;
+        window.requestAnimationFrame(watch);
+    }
 });
 
 /* Normal mode */
 isAmbientMode = false;
 window.requestAnimationFrame(watch);
-};
 </pre>
 </li>
 
 <li>Create the ambient mode dots:
 <pre class="prettyprint">
-function renderAmbientDots()
-{
-   'use strict';
+function renderAmbientDots() {
+    'use strict';
 
-   ctx.save();
+    ctx.save();
 
-   ctx.translate(canvas.width / 2, canvas.height / 2);
+    ctx.translate(canvas.width / 2, canvas.height / 2);
 
-   ctx.beginPath();
+    ctx.beginPath();
 
-   ctx.fillStyle = '#000000';
-   ctx.strokeStyle = '#fff';
-   ctx.lineWidth = 4;
+    ctx.fillStyle = '#000000';
+    ctx.strokeStyle = '#fff';
+    ctx.lineWidth = 4;
 
-   ctx.arc(0, 0, 7, 0, 2 * Math.PI, false);
-   ctx.fill();
-   ctx.stroke();
-   ctx.closePath();
+    ctx.arc(0, 0, 7, 0, 2 * Math.PI, false);
+    ctx.fill();
+    ctx.stroke();
+    ctx.closePath();
 }
 </pre>
 </li>
 <li>Indicate time in the ambient mode:
 <pre class="prettyprint">
-function ambientWatch()
-{
-   'use strict';
-   /* Get the current time */
-   var date = getDate(),
-       hours = date.getHours(),
-       minutes = date.getMinutes(),
-       seconds = date.getSeconds(),
-       hour = hours + minutes / 60,
-       minute = minutes + seconds / 60;
-
-   /* Erase the previous time */
-   ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
-
-   renderAmbientDots();
-   renderHourNeedle(hour);
-   renderMinuteNeedle(minute);
-
-   ctx.restore();
+function ambientWatch() {
+    'use strict';
+    /* Get the current time */
+    var date = getDate(),
+        hours = date.getHours(),
+        minutes = date.getMinutes(),
+        seconds = date.getSeconds(),
+        hour = hours + minutes / 60,
+        minute = minutes + seconds / 60;
+
+    /* Erase the previous time */
+    ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
+
+    renderAmbientDots();
+    renderHourNeedle(hour);
+    renderMinuteNeedle(minute);
+
+    ctx.restore();
 }
 </pre>
 </li>
index 7deb014..b91e127 100644 (file)
@@ -497,30 +497,26 @@ widget
 <li>The <code>style.css</code> file indicates the style properties of various HTML elements.
 <p>The <code>index.html</code> file imports the <code>style.css</code> file.</p>
 <pre class="prettyprint">
-html, body
-{
+html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
 }
-#page
-{
+#page {
    background-color: #000;
    color: #fff;
    height: 100%;
    position: relative;
    width: 100%;
 }
-#container
-{
+#container {
    left: 50%;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
 }
-#content-text
-{
+#content-text {
    font-weight: bold;
    font-size: 40px;
 }