B2G/gaia/apps/sms/js/message_manager.js
// consider splitting this method for the different use cases
consider splitting this method for the different use cases
consider splitting this method for the different use cases
function mm_send(recipients, content,
                            onsuccess, onerror, oncomplete) {
    var requests;
    if (!Array.isArray(recipients)) {
      recipients = [recipients];
    }
    var i = 0;
    var requestResult = { success: [], error: [] };
    requests = this._mozMobileMessage.send(recipients, content);
    var numberOfRequests = requests.length;
    requests.forEach(function(request) {
      request.onsuccess = function onSuccess(event) {
        onsuccess && onsuccess(event.target.result);
        requestResult.success.push(event.target.result);
        if (i === numberOfRequests - 1) {
          oncomplete && oncomplete(requestResult);
        }
        i++;
      };
      request.onerror = function onError(event) {
        console.log('Error Sending: ' + JSON.stringify(event.target.error));
        onerror && onerror(event.target.error);
        requestResult.error.push(event.target.error);
        if (i === numberOfRequests - 1) {
          oncomplete && oncomplete(requestResult);
        }
        i++;
      };
    });
  }
function mm_send ( recipients , content , onsuccess , onerror , oncomplete ) { var requests ; if ( ! Array . isArray ( recipients ) ) { recipients = [ recipients ] ; } var i = 0 ; var requestResult = { success : [ ] , error : [ ] } ; requests = this . _mozMobileMessage . send ( recipients , content ) ; var numberOfRequests = requests . length ; requests . forEach ( function ( request ) { request . onsuccess = function onSuccess ( event ) { onsuccess && onsuccess ( event . target . result ) ; requestResult . success . push ( event . target . result ) ; if ( i === numberOfRequests - 1 ) { oncomplete && oncomplete ( requestResult ) ; } i ++ ; } ; request . onerror = function onError ( event ) { console . log ( 'Error Sending: ' + JSON . stringify ( event . target . error ) ) ; onerror && onerror ( event . target . error ) ; requestResult . error . push ( event . target . error ) ; if ( i === numberOfRequests - 1 ) { oncomplete && oncomplete ( requestResult ) ; } i ++ ; } ; } ) ; }
consider splitting this method for the different use cases
consider splitting this method for the different use cases
// The returned value is not a DOM request! // Instead, It's an array of DOM requests.