B2G/gaia/apps/communications/dialer/js/call_log_db.js
/**
   * Get the call group which is the nth group with matched type
   *
   * param position
   *        To indicate the nth group is requested, 1 means the last one
   * param sortedBy
   *        Field to sort by.
   * param prev
   *        Boolean flag to get the list in reverse order.
   * param type
   *        Type to indicate whether we want 'dialing' (outgoing)
   *        or 'incoming' call groups.
   *        If not specified, will match any types.
   * param callback
   *        Function to be called with the last group or an error message if
   *        needed.
   * return (via callback) the group or an error message if needed.
   */
Get the call group which is the nth group with matched type
param position
To indicate the nth group is requested, 1 means the last one
param sortedBy
Field to sort by.
param prev
Boolean flag to get the list in reverse order.
param type
Type to indicate whether we want 'dialing' (outgoing)
or 'incoming' call groups.
If not specified, will match any types.
param callback
Function to be called with the last group or an error message if
needed.
return (via callback) the group or an error message if needed.
Get the call group which is the nth group with matched type param position To indicate the nth group is requested 1 means the last one param sortedBy Field to sort by . param prev Boolean flag to get the list in reverse order . param type Type to indicate whether we want ' dialing ' ( outgoing ) or ' incoming ' call groups . If not specified will match any types . param callback Function to be called with the last group or an error message if needed . return ( via callback ) the group or an error message if needed .
function rdbm_getGroupAtPosition(position, sortedBy, prev,
                                                       type, callback) {
    if (!callback || !callback instanceof Function) {
      return;
    }
    var self = this;
    this._newTxn('readonly', this._dbGroupsStore,
                 function(error, txn, store) {
      if (error) {
        callback(error);
        return;
      }
      try {
        var request = null;
        var direction = prev ? 'prev' : 'next';
        if (sortedBy && sortedBy !== null) {
          request = store.index(sortedBy).openCursor(null, direction);
        } else {
          request = store.openCursor(null, direction);
        }
        var i = 0;
        request.onsuccess = function(event) {
          var cursor = event.target.result;
          if (!cursor) {
            callback(null);
            return;
          }
          var recentGroup = self._getGroupObject(cursor.value);
          var matched = !type || recentGroup.type.indexOf(type) != -1;
          if (matched) {
            i++;
          }
          if (matched && i == position) {
            callback(recentGroup);
          } else {
            cursor.continue();
          }
        };
        request.onerror = function(event) {
          callback(event.target.error.name);
        };
      } catch (e) {
        callback(e);
      }
    });
  }
function rdbm_getGroupAtPosition ( position , sortedBy , prev , type , callback ) { if ( ! callback || ! callback instanceof Function ) { return ; } var self = this ; this . _newTxn ( 'readonly' , this . _dbGroupsStore , function ( error , txn , store ) { if ( error ) { callback ( error ) ; return ; } try { var request = null ; var direction = prev ? 'prev' : 'next' ; if ( sortedBy && sortedBy !== null ) { request = store . index ( sortedBy ) . openCursor ( null , direction ) ; } else { request = store . openCursor ( null , direction ) ; } var i = 0 ; request . onsuccess = function ( event ) { var cursor = event . target . result ; if ( ! cursor ) { callback ( null ) ; return ; } var recentGroup = self . _getGroupObject ( cursor . value ) ; var matched = ! type || recentGroup . type . indexOf ( type ) != - 1 ; if ( matched ) { i ++ ; } if ( matched && i == position ) { callback ( recentGroup ) ; } else { cursor . continue ( ) ; } } ; request . onerror = function ( event ) { callback ( event . target . error . name ) ; } ; } catch ( e ) { callback ( e ) ; } } ) ; }
Get the call group which is the nth group with matched type
 param position
        To indicate the nth group is requested, 1 means the last one
 param sortedBy
        Field to sort by.
Get the call group which is the nth group with matched type param position To indicate the nth group is requested 1 means the last one param sortedBy Field to sort by .