// Since we don't set a beacon_url, we'll just subscribe to the before_beacon function
// and print the results into the browser itself.
BOOMR.subscribe('before_beacon', function(o) {
var html = "", t_name, t_other, others = [];
if(!o.t_other) o.t_other = "";
for(var k in o) {
if(!k.match(/^(t_done|t_other|bw|lat|bw_err|lat_err|u|r2?)$/)) {
if(k.match(/^t_/)) {
o.t_other += "," + k + "|" + o[k];
}
else {
others.push(k + " = " + o[k]);
}
}
}
if(o.t_done) { html += "This page took " + o.t_done + " ms to load
"; }
if(o.t_other) {
t_other = o.t_other.replace(/^,/, '').replace(/\|/g, ' = ').split(',');
html += "Other timers measured:
";
for(var i=0; i";
}
}
if(o.bw) { html += "Your bandwidth to this server is " + parseInt(o.bw*8/1024) + "kbps (±" + parseInt(o.bw_err*100/o.bw) + "%)
"; }
if(o.lat) { html += "Your latency to this server is " + parseInt(o.lat) + "±" + o.lat_err + "ms
"; }
var r = document.getElementById('results');
r.innerHTML = html;
if(others.length) {
r.innerHTML += "Other parameters:
";
for(var i=0; i";
}
}
});