----prueba1
The script itself is:
-----
1 && Math.random() > 1/this.sampling ) {
// not running test, but setting the cookie
if (this.docookies) this.setCookie('__ipprototest_last_run',this._testTime);
return this;
} else {
this.startTest();
}
}
return this;
} else
return new IPProtoTest(opts);
};
// public functions
IPProtoTest.prototype.doGAQ=function() {
var _gaq = window._gaq || []; // assuming google default
if (this.GAQ instanceof Object) { // .. but allow override
_gaq = this.GAQ;
}
//TODO document this
var ipv4 = this._result.r4td ? 'yes' : 'no';
var ipv6 = this._result.r6td ? 'yes' : 'no';
var dual = this._result.rdtd ? 'yes' : 'no';
if (this.dov6dns) {
var v6dns = this._result.rdt6 ? 'yes' : 'no';
}
if (this.dov6literal) {
var v6lit = this._result.v6lit ? 'yes' : 'no';
}
if (this.dotunnels) {
var v6stf = this._result.v6stf ? 'yes' : 'no';
var v6ter = this._result.v6ter ? 'yes' : 'no';
}
var summary = ((ipv4 == 'yes' ? 1 : 0) +
(ipv6 == 'yes' ? 2 : 0) +
(dual == 'yes' ? 4 : 0));
if (this.dov6dns) {
summary += ((v6dns == 'yes' ? 8 : 0));
}
if (this.dov6literal) {
summary += ((v6lit == 'yes' ? 16 : 0));
}
if (this.dotunnels) {
summary += ((v6stf == 'yes' ? 32 : 0) +
(v6ter == 'yes' ? 64 : 0));
}
// Normalize v4val to 0 if the v4 test fails.
// Normalize all other test times to relative to v4, if v4 worked
// If a test fails, set to zero.
// If v4 failed, set all tests to zero.
// This ensures zero cases, and no v4 do not contribute to avg times
var v4val = this._result.r4td ? this._result.r4td : 0;
var v6val = this._result.r6td ? (this._result.r4td ? (this._result.r6td - v4val) : 0) : 0;
var duval = this._result.rdtd ? (this._result.r4td ? (this._result.rdtd - v4val) : 0) : 0;
if (this.dov6dns) {
var dnval = this._result.v6dns ? (this._result.r4td ? (this._result.v6dns - v4val) : 0) : 0;
}
if (this.dov6literal) {
var lival = this._result.v6lit ? (this._result.r4td ? (this._result.v6lit - v4val) : 0) : 0;
}
if (this.dotunnels) {
var stval = this._result.v6stf ? (this._result.r4td ? (this._result.v6stf - v4val) : 0) : 0;
var teval = this._result.v6ter ? (this._result.r4td ? (this._result.v6ter - v4val) : 0) : 0;
}
if (this.domore) {
var stval = this._result.rd.td ? (this._result.r4td ? (this._result.td.td - v4val) : 0) : 0;
var teval = this._result.r6.td ? (this._result.r4td ? (this._result.r6.td - v4val) : 0) : 0;
}
_gaq.push(['_trackEvent', 'ipprototest', 'ipv4:' + ipv4, 'Tested', 0]);
_gaq.push(['_trackEvent', 'ipprototest', 'ipv6:' + ipv6, 'Tested', v6val]);
_gaq.push(['_trackEvent', 'ipprototest', 'dual:' + dual, 'Tested', duval]);
if (this.dov6dns) {
_gaq.push(['_trackEvent', 'ipprototest', 'v6lit:' + v6lit, 'Tested', lival]);
}
if (this.dov6literal) {
_gaq.push(['_trackEvent', 'ipprototest', 'v6dns:' + v6dns, 'Tested', dnval]);
}
if (this.dotunnels) {
_gaq.push(['_trackEvent', 'ipprototest', 'v6stf:' + v6stf, 'Tested', stval]);
_gaq.push(['_trackEvent', 'ipprototest', 'v6ter:' + v6ter, 'Tested', teval]);
}
// push summary line, this users testset.
_gaq.push(['_trackEvent', 'ipprototest', 'summary:' + summary]);
};
IPProtoTest.prototype.onFinishInit=function() {
if ( this.GAQ ) { // do Google analytics
this.doGAQ();
}
};
IPProtoTest.prototype.finishTest=function() {
// cancel the timeout
clearTimeout( __ipprototest._timeoutEvent );
if (! __ipprototest._done ) {
// report back results
var pfx = __ipprototest.getTestPfx();
for (var t_idx in __ipprototest.testSet) {
var test = __ipprototest.testSet[t_idx];
test = test.replace(/\./g,'');
pfx += [
'z',
test ,
'-' ,
__ipprototest._result[ test ] ?
__ipprototest._result[ test ] :
'null',
'.'
].join('');
}
var imgURL = [
'http://',
pfx,
'results.',
__ipprototest.domainSuffix,
'/1x1.png?',
pfx
].join('');
var req=document.createElement('img');
req.src = imgURL; // loads it
if(__ipprototest.docookies) __ipprototest.setCookie('__ipprototest_last_run', __ipprototest._testTime);
// do all the stuff that needs to be done when
// results are in
__ipprototest.onFinishInit();
__ipprototest._done = true;
// if there is a callback function, invoke it
if ( __ipprototest.callback instanceof Function ) __ipprototest.callback(__ipprototest._result);
}
};
IPProtoTest.prototype.getTestPfx = function() {
return [
't', this.timeout, '.',
'u', this._testTime , '.',
's', this._testId , '.',
'i', this.userId , '.',
'v', this._version , '.'
].join('');
};
IPProtoTest.prototype.startTest = function() {
var testPfx = this.getTestPfx();
var testPath='/1x1.png?'+testPfx;
for(var i=0;i= __ipprototest.testSetLen) {
__ipprototest.finishTest();
}
}
// inspired by gih_ajax-function by Geoff Huston, George Michaelson, Byron Ellacott (APNIC)
IPProtoTest.prototype.httpFetchImg=function( url, name ) {
var req=document.createElement('img');
req.name = name;
req._start = new Date().getTime();
req.onload = __ipprototest_onload;
req.src = url;
};
})();
// initialize variables and structs to avoid null ref bugs
var ipproto_user = ipproto_user || 'anon';
var ipproto_opts = ipproto_opts || {};
// if we have been correctly initialized for google analytics setup by the user...
// the set of externally defined variables we will accept
// userID takes the ipproto_user variable by default,
// or the value passed in array externally if provided
// defaults shown below.
var opts = {
'docookies' : true, // test based on noCheckInterval in cookie
'dov6dns' : true, // test v6 dns to a dual-stack URL
'dov6literal' : true, // test a v6 literal URL
'dotunnels' : false, // test for 6to4 and teredo tunnels
'domore' : true, // test for v6 using alt server
'randomize' : false, // by default, sorted test order
'noCheckInterval' : 86400000, // interval to test on, if docoookies is true
'sampling' : 1, // 1/sampling eg sampling=4 1/4th tested
'userId' : ipproto_user, // what to log in the collector website as
'callback' : function (results){}, // prototype function to receive callback of results
'GAQ' : false // hook into google analytics
};
if ( ipproto_opts instanceof Object ) {
// for the list we know, if its in the externally set object, map it in.
for ( prop in opts ) {
if (prop in ipproto_opts) { opts[prop] = ipproto_opts[prop]; }
}
}
var ippt = IPProtoTest(opts);
";
?>
Comentarios
Publicar un comentario