Feedback Sample Overview

Wearable web

The Feedback application demonstrates how you can use the Feedback API to play sound or vibration associated with an action.

The following figure illustrates the main screen and the settings screen of the Feedback application.

Figure: Feedback screens

Feedback main screen Feedback settings screen

The application opens with the main screen, which shows the list of feedback patterns and the Settings button. To go to the Settings view, click Settings. In the Settings view, you can select the type of feedback.

The application is divided into several pages in the index.html file. Their IDs are:

  • main-page: The main page that shows the list on patterns.
  • settings-page: The Settings page for selecting the type of feedback.

Source Files

You can create and view the sample application project, including the source files, in the IDE.

Table: Source files
File name Description
config.xml This file contains the project properties.
css/style.css This file contains CSS styling for the application.
index.html This file is a start-up file of the application.
js/app.js This file contains the application code.


To implement the application:

  1. After the application has been loaded, it defines a handler to subscribe to specific events.

    /* This handler function is called when a pattern is selected on the list on the main page */
    myapp.ui.mainpage.patternslist.onclick = function(event) 
       var id =;
       /* If the event target ID is 'patterns-list', it is ignored */
       if (id === myapp.MAIN_PAGE_PATTERNS_LIST)
   = document.querySelector('#' + id).innerHTML;
    /* This handler function is called when Settings on the main page is clicked */
    myapp.ui.mainpage.settingsbutton.onclick = function()
    /* This handler function is called when one of the radio buttons on the Settings page is selected */
    myapp.ui.settingspage.radiobutton.onclick = function(event)
    { =;
    /* This handler function is called when OK on an error popup is clicked */
    myapp.ui.errorpopup.button.onclick = function()
    /* Create the list to display on the main page */
  2. The following example shows the detailed code for the method. The code shows how to check whether a type and a pattern are supported on a device and to play the type and the pattern.
       Plays a feedback by and
    */ = function() 
             Checks whether a selected pattern is supported
             If the pattern is not supported, an error popup opens
          var isSupported = false;
          isSupported =,;
          if (isSupported === false)
             self.ui.errorpopup.message.innerHTML = 'Not Supported Pattern';
             tau.openPopup('#' + self.ERROR_POPUP);
          /* If the pattern is supported, play the pattern */
       catch (error)
          self.ui.errorpopup.message.innerHTML = + ': ' + error.message;
          tau.openPopup('#' + self.ERROR_POPUP);