lib/asset/htracr-ui.js
function index_capture (capture) {

    function server_sortfunc (a, b) {
      return capture.sessions[a[0]][a[1][a[1].length - 1]].start -
             capture.sessions[b[0]][b[1][b[1].length - 1]]
    }

    function conn_sortfunc (a, b) {
      return a.start - b.start;
    }

    var servers = [];
    var start;
    var end;
    for (var server_id in capture.sessions) {
      if (capture.sessions.hasOwnProperty(server_id)) {
        var conns = [];
        for (var conn_id in capture.sessions[server_id]) {
          if (capture.sessions[server_id].hasOwnProperty(conn_id)) {
            var conn = capture.sessions[server_id][conn_id];
            if (conn.http_reqs.length) {
              conns.push(conn);
            }
          }
        }
        conns.sort(conn_sortfunc);
        var conn_ids = [];
        conns.forEach(function (conn) {
          conn_ids.push(conn.local_port);
          
        })

        if (conn_ids.length) {
          if (! start || conns[0].start < start) {
            start = conns[0].start || capture.start;
          }
          if (! end || conns[conns.length - 1].end > end) {
            end = conns[conns.length - 1].end || capture.end;
          }
          servers.push([server_id, conn_ids]);
        }
      }
    }
    servers.sort(server_sortfunc);
    return {
      start: start,
      end: end,
      servers: servers
    };
  }
function index_capture (capture) {

    function server_sortfunc (a, b) {
      return capture.sessions[a[0]][a[1][a[1].length - 1]].start -
             capture.sessions[b[0]][b[1][b[1].length - 1]]
    }

    function conn_sortfunc (a, b) {
      return a.start - b.start;
    }

    var servers = [];
    var start;
    var end;
    for (var server_id in capture.sessions) {
      if (capture.sessions.hasOwnProperty(server_id)) {
        var conns = [];
        for (var conn_id in capture.sessions[server_id]) {
          if (capture.sessions[server_id].hasOwnProperty(conn_id)) {
            var conn = capture.sessions[server_id][conn_id];
            if (conn.http_reqs.length) {
              conns.push(conn);
            }
          }
        }
        conns.sort(conn_sortfunc);
        var conn_ids = [];
        conns.forEach(function (conn) {
          conn_ids.push(conn.local_port);
          
        })

        if (conn_ids.length) {
          if (! start || conns[0].start < start) {
            start = conns[0].start || capture.start;
          }
          if (! end || conns[conns.length - 1].end > end) {
            end = conns[conns.length - 1].end || capture.end;
          }
          servers.push([server_id, conn_ids]);
        }
      }
    }
    servers.sort(server_sortfunc);
    return {
      start: start,
      end: end,
      servers: servers
    };
  }
Given a hash of {server: {conn_id: [...]}}, return an ordered list of [server_name, [conn_id1...], start], based upon first connection.