function on_index_html(html) {
    // Look for patterns like:  href="couchbase-server-community_x86_64_2.0.0c-709-rel.rpm.manifest.xml"

    var urls = {}
    var hier = {} // Hierarchy of maps, keyed by name / version / build / arch / pkg.

    var hrefs = html.match(/href="[^\"]+\.manifest\.xml"/g);
    for (var i = 0; i < hrefs.length; i++) {
        var href = hrefs[i];
        var url = href.split('"')[1];
        var s = url.split('_');
        var name = s[0];
        var arch = s.slice(1, s.length - 1).join("_");
        var suffix = s[s.length - 1].split('-');
        var version = suffix[0];
        var build = suffix[1];
        if (suffix && suffix[2]) {
            var pkg = suffix[2].split('.')[suffix[2].split('.').length - 3];

            var p = { "url": url,
                      "name": name,
                      "version": version,
                      "build": build,
                      "arch": arch,
                      "pkg": pkg };
            urls[url] = p;

            add_entry(hier, [name, version, build, arch, pkg], p);
        }
    }

    $('#content').html(gen(hier));
}

function add_entry(hier, path, val) {
    for (var i = 0; i < path.length - 1; i++) {
        var m = hier[path[i]];
        if (!m) {
            m = hier[path[i]] = {};
        }
        hier = m;
    }
    hier[path[path.length - 1]] = val;
}

function gen(hier) {
    var r = [];
    for (var name in keys(hier).sort()) {
        r[r.length] = '<div class="name">' + name + '<div class="versions">';
        var versions = hier[name];
        for (var version in keys(versions).sort()) {
            r[r.length] = '<div class="version">' + version + '<div class="builds">';
            var builds = versions[version];
            for (var build in keys(builds).sort().reverse()) {
                r[r.length] = '<div class="build">' + build + '<div class="archs">';
                var archs = builds[build];
                for (var arch in keys(archs).sort()) {
                    r[r.length] = '<div class="arch">' + arch + '<div class="pkgs">';
                    var pkgs = archs[arch];
                    for (var pkg in keys(pkgs).sort()) {
                        var p = pkgs[pkg];
                        var u = (p.url || '').replace('.manifest.xml', '');
                        r[r.length] = '<div class="pkg"><a href="' + u + '">' + pkg + '</a></div>';
                    }
                    r[r.length] = '</div></div>';
                }
                r[r.length] = '</div></div>';
            }
            r[r.length] = '</div></div>';
        }
        r[r.length] = '</div></div>';
    }
    return r;
}

function keys(m) {
    var keys = [];
    for (var key in m) {
        keys[keys.length] = key;
    }
    return keys;
}

function on_ready() {
    $.get("../../index.html", null,
          function(response, textStatus, jqXHR){
              on_index_html(response);
          });
}

$(document).ready(on_ready);

@@ -1410,21 +1410,16 @@
     
-for (
 var name
  in 
@@ -1414,19 +1414,19 @@
 var name
- in
+s =
  keys(hi
@@ -1427,35 +1427,111 @@
 eys(hier).sort()
-) %7B
+;%0A    for (var i0 = 0; i0 %3C names.length; i0++) %7B%0A        var name = names%5Bi0%5D;
 %0A        r%5Br.len
@@ -1640,27 +1640,16 @@
     
-for (var version in
+var k1 =
  key
@@ -1658,35 +1658,116 @@
 versions).sort()
-) %7B
+;%0A        for (var i1 = 0; i1 %3C k1.length; i1++) %7B%0A            var version = k1%5Bi1%5D;
 %0A            r%5Br
@@ -1897,25 +1897,16 @@
     
-for (var build in
+var k2 =
  key
@@ -1931,19 +1931,106 @@
 everse()
-) %7B
+;%0A            for (var i2 = 0; i2 %3C k2.length; i2++) %7B%0A                var build = k2%5Bi2%5D;
 %0A       
@@ -2170,24 +2170,16 @@
     
-for (var arch in
+var k3 =
  key
@@ -2185,35 +2185,129 @@
 ys(archs).sort()
-) %7B
+;%0A                for (var i3 = 0; i3 %3C k3.length; i3++) %7B%0A                    var arch = k3%5Bi3%5D;
 %0A               
@@ -2445,23 +2445,16 @@
     
-for (var pkg in
+var k4 =
  key
@@ -2467,19 +2467,120 @@
 ).sort()
-) %7B
+;%0A                    for (var i4 = 0; i4 %3C k4.length; i4++) %7B%0A                        var pkg = k4%5Bi4%5D;
 %0A       

correct array iteration