WebAPI/WebSTK: Difference between revisions

Line 708: Line 708:
== Menu Selection ==  
== Menu Selection ==  
<pre>
<pre>
function menuSelection(id, helpRequested) {
/**
   mozIcc.sendMenuSelection(id, helpRequested);
* onMenuSelected is the callback when some item of the menu is selected.
* @param id    The index of the item being selected.
* @param helpRequested    Request for help.
*/
function onMenuSelected(id, helpRequested) {
   var icc = navigator.mozMobileConnection.icc;
  icc.sendStkMenuSelection(id, helpRequested);
}
}
</pre>
</pre>
Line 717: Line 723:
// 'command' is got from onstkcommand
// 'command' is got from onstkcommand
// and assume it's a Select Item command.
// and assume it's a Select Item command.
var icc = navigator.mozMobileConnection.icc;
var response = {
var response = {
  commandNumber: command.commandNumber,
   resultCode : icc.STK_RESULT_OK,
  typeOfCommandL command.typeOfCommand,
   // 'id' is got from the choosed item identifier (menu.item[].identifier)
  commandQualifier: command.commandQualifier,
   resultCode : mozICC.STK_RESULT_OK,
   // 'id' is got from the chosen item identifier (menu.item[].identifier)
   itemIdentifier: id
   itemIdentifier: id
};
};
mozIcc.sendStkResponse(response);
mozIcc.sendStkResponse(command, response);
</pre>
</pre>


== Get Input ==
== Get Input ==
<pre>
<pre>
mozIcc.onstkcommand = function (command) {
var icc = navigator.mozMobileConnection.icc;
icc.onstkcommand = function (command) {
   switch (command.typeOfCommand) {
   switch (command.typeOfCommand) {
     case mozIcc.STK_CMD_GET_INPUT:
     case icc.STK_CMD_GET_INPUT:
       var input = command.options;
       var input = command.options;
       // create a TextInput-like UI according to 'input'
       // create a TextInput-like UI according to 'input'
Line 740: Line 745:


// onTextInput is the callback when user inputs complete.
// onTextInput is the callback when user inputs complete.
var icc = navigator.mozMobileConnection.icc;
function onTextInput(input) {
function onTextInput(input) {
   var response = {
   var response = {
    commandNumber: command.commandNumber,
    typeOfCommandL command.typeOfCommand,
    commandQualifier: command.commandQualifier,
     resultCode : mozICC.STK_RESULT_OK,
     resultCode : mozICC.STK_RESULT_OK,
     input: input
     input: input
   };
   };
   mozIcc.sendStkResponse(response);
   mozIcc.sendStkResponse(command, response);
}
}
</pre>
</pre>
Confirmed users
266

edits