Skip to content

Instantly share code, notes, and snippets.

@danwrong
Created February 23, 2011 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danwrong/841338 to your computer and use it in GitHub Desktop.
Save danwrong/841338 to your computer and use it in GitHub Desktop.
(function loadrunner(e){var w=e.document;var h=w.getElementsByTagName("script"),n,k;var B={},j={},v;for(var z=0,r;r=h[z];z++){if(r.src.match(/loadrunner\.js(\?|#|$)/)){n=r;break}}function c(i){if(i.length>0){return i.replace(/\/$/,"")+"/"}return""}function o(i){return Array.prototype.slice.call(i)}function b(s,E){for(var F=0,G;G=s[F];F++){if(E==G){return F}}return -1}function t(i){return !!i.match(/^(([a-zA-Z0-9\-_]+)\/)*[a-zA-Z0-9\-_]+$/)}function q(i){return[c(y.path),i,".js"].join("")}function d(i){if(i.match(/^(https?)?:?\/\//)){return i}if(i.match(/^\/[^\/]/)){return c(y.docRoot)+i}if(i.match(/^\$/)){return c(y.path)+i.replace(/^\$/,"")}return i}function p(s){var i;if(i=j[s]){return i}else{return s}}function f(){}f.prototype.addCallback=function(i){if(this.completed){i.apply(this,this.results)}else{this.callbacks=this.callbacks||[];this.callbacks.push(i)}};f.prototype.complete=function(){if(!this.completed){this.results=o(arguments);this.completed=true;if(this.callbacks){for(var E=0,s;s=this.callbacks[E];E++){s.apply(this,this.results)}}}};function D(s,i){this.id=s;var F=this;function E(G){F.exports=G;F.complete(F.exports)}if(typeof i=="function"){i(E)}else{this.exports=i;this.complete(this.exports)}y.loaded.push(s)}D.prototype=new f;var a={};function m(F,H){var G;if(!a[F]){G=new f;a[F]=G;var E=function(){delete a[F];G.complete(F)};var i=w.createElement("script");i.type="text/javascript";i.async=true;i.onload=E;i.onerror=function(){throw F+" not loaded"};i.onreadystatechange=function(){if(this.readyState=="loaded"||this.readyState=="complete"){this.onreadystatechange=null;E()}};i.src=F;var s=w.getElementsByTagName("head")[0];if(!s){s=w.createElement("head");w.documentElement.appendChild(s)}s.insertBefore(i,s.firstChild)}else{G=a[F]}if(H){G.addCallback(H)}return G}function u(s,i){i=[].concat(i);for(var E=0,F;F=i[E];E++){j[unescape(F)]=unescape(s)}}function y(){var E=new f,s=o(arguments),I=0,M=[];function G(){I++;if(I==s.length){var P;var S=[],R={},N;for(var Q=0,O;O=M[Q];Q++){N=B[O].exports;S.push(N);R[O]=N}E.complete.apply(E,S)}}function F(i,N){return function(){if(!B[i]){throw"File "+N+" does not provide module "+i}B[i].addCallback(function(){G()})}}if(typeof s[s.length-1]=="function"){E.addCallback(s.pop())}for(var J=0,H;H=s[J];J++){if(t(H)){var K=p(H);var L=(t(K))?q(K):K;M.push(H);if(b(y.loaded,H)>-1){F(H)()}else{y.load(d(L),F(H,L))}}else{if(b(y.loaded,H)>-1){G()}else{y.load(d(p(H)),G);y.loaded.push(H)}}}return E}y.loaded=[];y.path="";if(n){y.path=n.getAttribute("data-path")||n.src.split(/loadrunner\.js/)[0]||"";if(v=n.getAttribute("data-alias")||window.__lralias){for(var z=0,x,C=v.split("&");x=C[z]&&C[z].split("=");z++){var l=x[0],g=x[1].split(",");u(l,g)}}}y.docRoot=y.cwd="";y.reset=function(){y.loaded=[];B={}};function A(s,i){return B[s]=new D(s,i)}e.using=y;e.using.load=m;e.using.alias=u;e.provide=A;if(k=(n&&n.getAttribute("data-main"))){y.apply(e,k.split(/\s*,\s*/))}})(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment