B2G/gaia/apps/costcontrol/js/costcontrol.js
// Transform data usage to the model accepted by the render
Transform data usage to the model accepted by the render
Transform data usage to the model accepted by the render
function adaptData(networkStatsResult, tags) {
    var data = networkStatsResult.data;
    var output = [];
    var totalData, accum = 0;
    for (var i = 0, item; item = data[i]; i++) {
      if (item.txBytes === undefined) {
        output.push({ date: item.date });
        continue;
      }
      totalData = 0;
      if (item.rxBytes) {
        totalData += item.rxBytes;
      }
      if (item.txBytes) {
        totalData += item.txBytes;
      }
      var usage = totalData;
      if (tags) {
        usage = MindGap.getUsage(tags, totalData, item.date);
      }
      if (usage === undefined) {
        continue;
      }
      accum += usage;
      output.push({
        value: usage,
        date: item.date
      });
    }
    return [output, accum];
  }
function adaptData ( networkStatsResult , tags ) { var data = networkStatsResult . data ; var output = [ ] ; var totalData , accum = 0 ; for ( var i = 0 , item ; item = data [ i ] ; i ++ ) { if ( item . txBytes === undefined ) { output . push ( { date : item . date } ) ; continue ; } totalData = 0 ; if ( item . rxBytes ) { totalData += item . rxBytes ; } if ( item . txBytes ) { totalData += item . txBytes ; } var usage = totalData ; if ( tags ) { usage = MindGap . getUsage ( tags , totalData , item . date ) ; } if ( usage === undefined ) { continue ; } accum += usage ; output . push ( { value : usage , date : item . date } ) ; } return [ output , accum ] ; }
Transform data usage to the model accepted by the render
Transform data usage to the model accepted by the render