-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathjquery.gatling.min.js
14 lines (14 loc) · 2.9 KB
/
jquery.gatling.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*!
* Gatling Analytics v0.1.5
*
* Copyright (c) 2010 Knewton
* Dual licensed under:
* MIT: http://www.opensource.org/licenses/mit-license.php
* GPLv3: http://www.opensource.org/licenses/gpl-3.0.html
*/
(function(b){function j(a){if(a.attr("src")===undefined)a.appendTo("body");else{var c,d=[];b.each(i,function(){if(this.regex.test(a.attr("src")))c=this.listener;else d.push(this)});i=d;b.getScript(a.attr("src"),c)}}function k(a){if(l)if(o.test(a)){a=b(a);a.is("script")?j(a):b("script",a).each(function(){j(b(this))});a.not("script").appendTo("body")}else m.call(document,a);else m.call(document,a)}function p(a){var c=[];b.each(a,function(d,e){c.push(d+"="+e)});return c.length>0?"?"+c.join("&"):""}function q(a){var c=
{};b.each(a.params,function(d,e){if(a.globals[d]===true)window[d]=e;else c[d]=e});return c}function r(a){var c="http"+(n?"s":"")+"://",d={};if(a.securePrefix!==undefined&&n)c+=a.securePrefix;else if(a.prefix!==undefined)c+=a.prefix;c+=a.path||a.image;a.params=q(a);a.params=b.extend(a.params,{trackerID:a.trackerID});b.each(a.params,function(e,h){if(a.replacements[e])c=c.replace(a.replacements[e],h);else d[e]=h});c+=p(d);l=true;if(a.path!==undefined)b.getScript(c,function(){b.isFunction(a.loaded)?a.loaded(a):
a.ready(a)});else if(a.image!==undefined){s.src=c;b.isFunction(a.loaded)&&a.loaded(a)}}var t=new Date,u=[".deferred-script-load{ display: none; }"],g={},o=/<\/?\w+((\s+(\w|\w[\w\-]*\w)(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)\/?>/i,n=document.location.protocol==="https:",f={},i=[],v={path:undefined,globals:undefined,loaded:undefined,prefix:undefined,securePrefix:undefined,image:undefined,trackerID:undefined,ready:b.noop,params:undefined,replacements:undefined},w={trackerID:"%gatling-tracker-id%"},
s=new Image,m=document.write,l;b.extend(g,{loadTime:{start:undefined,end:undefined},defineTracker:function(a,c,d){if(f[a]===undefined){f[a]=b.extend(true,{},v,c);f[a].replacements=b.extend({},w,d);var e={};f[a].globals!==undefined&&b.each(f[a].globals,function(){e[this]=true});f[a].globals=e}},createTracker:function(a,c,d,e,h){if(f[a]===undefined)return false;a=b.extend(true,{},f[a]);a.params=e||{};a.ready=b.isFunction(d)?d:b.noop||function(){};a.trackerID=c;a.loaded=h||a.loaded;r(a);return a},declare:function(a){b.each(a,
function(){g.defineTracker(this.name,this.definition,this.replacements)})},load:function(a){var c=[];b.each(a,function(){c.push(g.createTracker(this.type,this.id,this.listener,this.params,this.loaded))});return c},scriptListener:function(a,c){i.push({regex:a,listener:c});return g}});b.gatling=g;b.urlParam=function(a){a=RegExp("[\\?&]"+a+"=([^&#]*)").exec(window.location.href);return b.isArray(a)?a[1]:undefined};document.write=k;document.writeln=k;g.loadTime.start=t;b(function(){b('<style type="text/css">'+
u.join("")+"</style>").appendTo("head");g.loadTime.end=new Date;b("a.deferred-script-load").each(function(){b.getScript(b(this).attr("href"))})})})(jQuery);