Skip to content
Extraits de code Groupes Projets
Valider 7e4e0d9d rédigé par robocoder's avatar robocoder
Parcourir les fichiers

reorganize code a bit

git-svn-id: http://dev.piwik.org/svn/trunk@3378 59fd770c-687e-43c8-a1e3-f5a4ff64c105
parent 3bace178
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -9,11 +9,10 @@
* @version $Id$
*/
// Refer to README for build instructions when minifying this file for distribution.
/*jslint browser:true, forin:true, plusplus:false, onevar:false, eqeqeq:false, strict:false */
/*global window escape unescape ActiveXObject _paq:true */
// Note: YUICompressor 2.4.2 won't compress piwik_log() because of the the "evil" eval().
// Override this behaviour using http://yuilibrary.com/projects/yuicompressor/ticket/2343811
/*jslint evil:true */
/*
......@@ -24,11 +23,12 @@
* - IE5 - named anonymous functions and array.push introduced in IE5.5
*/
// Guard against loading the script twice
var Piwik, piwik_log, piwik_track;
if (!this.Piwik) {
var
// asynchronous tracker (or proxy)
_paq = _paq || [],
// Piwik singleton and namespace
Piwik = (function () {
Piwik = Piwik || (function() {
/************************************************************
* Private data
************************************************************/
......@@ -78,9 +78,9 @@ if (!this.Piwik) {
* apply wrapper
*
* @param array parameterArray An array comprising either:
* [ 'methodName', optional_parameters ]
* [ 'methodName', optional_parameters ]
* or:
* [ functionObject, optional_parameters ]
* [ functionObject, optional_parameters ]
*/
function apply(parameterArray) {
var f = parameterArray.shift();
......@@ -1065,32 +1065,16 @@ if (!this.Piwik) {
};
}
/*
/************************************************************
* Proxy object
*/
************************************************************/
function TrackerProxy() {
return {
push: apply
};
}
/*
* Process asynchronous tracking requests
*/
function processAsynchronousTracker()
{
if (isDefined(_paq)) {
asyncTracker = new Tracker();
for (var i = 0; i < _paq.length; i++) {
apply(_paq[i]);
}
// replace initialization array with proxy object
_paq = new TrackerProxy();
}
}
/************************************************************
* Constructor
************************************************************/
......@@ -1098,7 +1082,15 @@ if (!this.Piwik) {
// initialize the Piwik singleton
addEventListener(windowAlias, 'beforeunload', beforeUnloadHandler, false);
addReadyListener();
processAsynchronousTracker();
asyncTracker = new Tracker();
for (var i = 0; i < _paq.length; i++) {
apply(_paq[i]);
}
// replace initialization array with proxy object
_paq = new TrackerProxy();
/************************************************************
* Public data and methods
......@@ -1119,7 +1111,7 @@ if (!this.Piwik) {
return new Tracker(piwikUrl, siteId);
}
};
}());
}()),
/************************************************************
* Deprecated functionality below
......@@ -1132,6 +1124,8 @@ if (!this.Piwik) {
* var piwik_install_tracker, piwik_tracker_pause, piwik_download_extensions, piwik_hosts_alias, piwik_ignore_classes;
*/
piwik_track,
/*
* Track page visit
*/
......@@ -1177,4 +1171,3 @@ if (!this.Piwik) {
piwikTracker.enableLinkTracking();
}
};
}
......@@ -8,12 +8,12 @@
* @license http://www.opensource.org/licenses/bsd-license.php Simplified BSD
* @version $Id$
*/
var Piwik,piwik_log,piwik_track;if(!this.Piwik){Piwik=(function(){var j,r={},d=document,h=navigator,q=screen,y=window,g=false,u=[],o=y.encodeURIComponent||escape,c=y.decodeURIComponent||unescape,x;function a(z){return(z=typeof z)!=="undefined"&&z!=="unknown"}function t(A){var z=A.shift();if(typeof z=="string"){x[z].apply(this,A)}else{z.apply(this,A)}}function p(C,B,A,z){if(C.addEventListener){C.addEventListener(B,A,z);return true}if(C.attachEvent){return C.attachEvent("on"+B,A)}C["on"+B]=A}function f(A,D){var z="",C,B;for(C in r){B=r[C][A];if(typeof B==="function"){z+=B(D)}}return z}function v(z){f("unload");if(a(j)){var A;do{A=new Date()}while(A.getTime()<j)}}function i(A){if(!g){g=true;f("load");
for(var z=0;z<u.length;z++){u[z]()}}return true}function s(){if(d.addEventListener){p(d,"DOMContentLoaded",function z(){d.removeEventListener("DOMContentLoaded",z,false);i()})}else{if(d.attachEvent){d.attachEvent("onreadystatechange",function z(){if(d.readyState==="complete"){d.detachEvent("onreadystatechange",z);i()}});if(d.documentElement.doScroll&&y==y.top){(function z(){if(!g){try{d.documentElement.doScroll("left")}catch(A){setTimeout(z,0);return}i()}}())}}}p(y,"load",i,false)}function e(){var z="";try{z=top.document.referrer}catch(B){if(parent){try{z=parent.document.referrer}catch(A){z=""}}}if(z===""){z=d.referrer}return z}function k(z){var B=new RegExp("^(?:(?:https?|ftp):)/*(?:[^@]+@)?([^:/#]+)"),A=B.exec(z);return A?A[1]:z}function m(A,E){var D=new RegExp("^(?:https?|ftp)(?::/*(?:[^?]+)[?])([^#]+)"),C=D.exec(A),B=new RegExp("(?:^|&)"+E+"=([^&]*)"),z=C?B.exec(C[1]):0;return z?c(z[1]):""}function l(A,z,B){if(A=="webcache.googleusercontent.com"||A=="cc.bingj.com"||A.substr(0,5)=="74.6."){z=d.links[0].href;
A=k(z)}else{if(A=="translate.googleusercontent.com"){if(B===""){B=z}z=m(z,"u");A=k(z)}}return[A,z,B]}function w(Z,Y){var Q=l(y.location.hostname,y.location.href,e()),E=Q[0],I=Q[1],aa=Q[2],B="GET",M=Z||"",ak=Y||"",af,aj=d.title,P="7z|aac|ar[cj]|as[fx]|avi|bin|csv|deb|dmg|doc|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|ms[ip]|od[bfgpst]|og[gv]|pdf|phps|png|ppt|qtm?|ra[mr]?|rpm|sea|sit|tar|t?bz2?|tgz|torrent|txt|wav|wm[av]|wpd||xls|xml|z|zip",ab=[E],D=[],ac=[],ad=[],L=500,X,F="0",J={pdf:["pdf","application/pdf","0"],quicktime:["qt","video/quicktime","0"],realplayer:["realp","audio/x-pn-realaudio-plugin","0"],wma:["wma","application/x-mplayer2","0"],director:["dir","application/x-director","0"],flash:["fla","application/x-shockwave-flash","0"],java:["java","application/x-java-vm","0"],gears:["gears","application/x-googlegears","0"],silverlight:["ag","application/x-silverlight","0"]},T=false,al=function(ao){var ar=new RegExp('[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]',"g"),ap={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};
var _paq=_paq||[],Piwik=Piwik||(function(){var k,r={},d=document,h=navigator,q=screen,z=window,g=false,u=[],o=z.encodeURIComponent||escape,c=z.decodeURIComponent||unescape,y;function a(i){return(i=typeof i)!=="undefined"&&i!=="unknown"}function t(A){var i=A.shift();if(typeof i=="string"){y[i].apply(this,A)}else{i.apply(this,A)}}function p(C,B,A,i){if(C.addEventListener){C.addEventListener(B,A,i);return true}if(C.attachEvent){return C.attachEvent("on"+B,A)}C["on"+B]=A}function f(B,E){var A="",D,C;for(D in r){C=r[D][B];if(typeof C==="function"){A+=C(E)}}return A}function v(i){f("unload");if(a(k)){var A;do{A=new Date()}while(A.getTime()<k)}}function j(B){if(!g){g=true;f("load");for(var A=0;A<u.length;
A++){u[A]()}}return true}function s(){if(d.addEventListener){p(d,"DOMContentLoaded",function i(){d.removeEventListener("DOMContentLoaded",i,false);j()})}else{if(d.attachEvent){d.attachEvent("onreadystatechange",function i(){if(d.readyState==="complete"){d.detachEvent("onreadystatechange",i);j()}});if(d.documentElement.doScroll&&z==z.top){(function i(){if(!g){try{d.documentElement.doScroll("left")}catch(A){setTimeout(i,0);return}j()}}())}}}p(z,"load",j,false)}function e(){var i="";try{i=top.document.referrer}catch(B){if(parent){try{i=parent.document.referrer}catch(A){i=""}}}if(i===""){i=d.referrer}return i}function l(i){var B=new RegExp("^(?:(?:https?|ftp):)/*(?:[^@]+@)?([^:/#]+)"),A=B.exec(i);return A?A[1]:i}function n(A,E){var D=new RegExp("^(?:https?|ftp)(?::/*(?:[^?]+)[?])([^#]+)"),C=D.exec(A),B=new RegExp("(?:^|&)"+E+"=([^&]*)"),i=C?B.exec(C[1]):0;return i?c(i[1]):""}function m(A,i,B){if(A=="webcache.googleusercontent.com"||A=="cc.bingj.com"||A.substr(0,5)=="74.6."){i=d.links[0].href;
A=l(i)}else{if(A=="translate.googleusercontent.com"){if(B===""){B=i}i=n(i,"u");A=l(i)}}return[A,i,B]}function x(Z,Y){var Q=m(z.location.hostname,z.location.href,e()),E=Q[0],I=Q[1],aa=Q[2],B="GET",M=Z||"",ak=Y||"",af,aj=d.title,P="7z|aac|ar[cj]|as[fx]|avi|bin|csv|deb|dmg|doc|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|ms[ip]|od[bfgpst]|og[gv]|pdf|phps|png|ppt|qtm?|ra[mr]?|rpm|sea|sit|tar|t?bz2?|tgz|torrent|txt|wav|wm[av]|wpd||xls|xml|z|zip",ab=[E],D=[],ac=[],ad=[],L=500,X,F="0",J={pdf:["pdf","application/pdf","0"],quicktime:["qt","video/quicktime","0"],realplayer:["realp","audio/x-pn-realaudio-plugin","0"],wma:["wma","application/x-mplayer2","0"],director:["dir","application/x-director","0"],flash:["fla","application/x-shockwave-flash","0"],java:["java","application/x-java-vm","0"],gears:["gears","application/x-googlegears","0"],silverlight:["ag","application/x-silverlight","0"]},T=false,al=function(ao){var ar=new RegExp('[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]',"g"),ap={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};
function am(at){ar.lastIndex=0;return ar.test(at)?'"'+at.replace(ar,function(au){var av=ap[au];return typeof av==="string"?av:"\\u"+("0000"+au.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+at+'"'}function an(at){return at<10?"0"+at:at}function aq(ay,ax){var aw,av,au,at,az=ax[ay];if(az===null){return"null"}if(az&&typeof az==="object"&&typeof az.toJSON==="function"){az=az.toJSON(ay)}switch(typeof az){case"string":return am(az);case"number":return isFinite(az)?String(az):"null";case"boolean":case"null":return String(az);case"object":at=[];if(az instanceof Array){for(aw=0;aw<az.length;aw++){at[aw]=aq(aw,az)||"null"}au=at.length===0?"[]":"["+at.join(",")+"]";return au}if(az instanceof Date){return am(az.getUTCFullYear()+"-"+an(az.getUTCMonth()+1)+"-"+an(az.getUTCDate())+"T"+an(az.getUTCHours())+":"+an(az.getUTCMinutes())+":"+an(az.getUTCSeconds())+"Z")}for(av in az){au=aq(av,az);if(au){at.push(am(av)+":"+au)}}au=at.length===0?"{}":"{"+at.join(",")+"}";return au}}return aq("",{"":ao})};function G(at,ap,an,ar,ao,aq){var am;
if(an){am=new Date();am.setTime(am.getTime()+an*86400000)}d.cookie=at+"="+o(ap)+(an?";expires="+am.toGMTString():"")+";path="+(ar?ar:"/")+(ao?";domain="+ao:"")+(aq?";secure":"")}function C(ao){var am=new RegExp("(^|;)[ ]*"+ao+"=([^;]*)"),an=am.exec(d.cookie);return an?c(an[2]):0}function z(am){var an=new Image(1,1);an.onLoad=function(){};an.src=M+"?"+am}function K(am){try{var ao=y.XMLHttpRequest?new y.XMLHttpRequest():y.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):null;ao.open("POST",M,true);ao.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ao.setRequestHeader("Content-Length",am.length);ao.setRequestHeader("Connection","close");ao.send(am)}catch(an){z(am)}}function ag(ao,an){var am=new Date();j=am.getTime()+an;if(B=="POST"){K(ao)}else{z(ao)}}function H(){var am,an;if(a(h.javaEnabled)&&h.javaEnabled()){J.java[2]="1"}if(typeof y.GearsFactory==="function"){J.gears[2]="1"}if(h.mimeTypes&&h.mimeTypes.length){for(am in J){an=h.mimeTypes[J[am][1]];
if(an){am=new Date();am.setTime(am.getTime()+an*86400000)}d.cookie=at+"="+o(ap)+(an?";expires="+am.toGMTString():"")+";path="+(ar?ar:"/")+(ao?";domain="+ao:"")+(aq?";secure":"")}function C(ao){var am=new RegExp("(^|;)[ ]*"+ao+"=([^;]*)"),an=am.exec(d.cookie);return an?c(an[2]):0}function i(am){var an=new Image(1,1);an.onLoad=function(){};an.src=M+"?"+am}function K(am){try{var ao=z.XMLHttpRequest?new z.XMLHttpRequest():z.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):null;ao.open("POST",M,true);ao.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");ao.setRequestHeader("Content-Length",am.length);ao.setRequestHeader("Connection","close");ao.send(am)}catch(an){i(am)}}function ag(ao,an){var am=new Date();k=am.getTime()+an;if(B=="POST"){K(ao)}else{i(ao)}}function H(){var am,an;if(a(h.javaEnabled)&&h.javaEnabled()){J.java[2]="1"}if(typeof z.GearsFactory==="function"){J.gears[2]="1"}if(h.mimeTypes&&h.mimeTypes.length){for(am in J){an=h.mimeTypes[J[am][1]];
if(an&&an.enabledPlugin){J[am][2]="1"}}}}function W(){var am="_pk_testcookie";if(!a(h.cookieEnabled)){G(am,"1");return C(am)=="1"?"1":"0"}return h.cookieEnabled?"1":"0"}function R(aq,an){var ao,am=new Date(),ap="idsite="+ak+"&rec=1&rand="+Math.random()+"&h="+am.getHours()+"&m="+am.getMinutes()+"&s="+am.getSeconds()+"&url="+o(a(af)?af:I)+"&urlref="+o(aa)+"&res="+q.width+"x"+q.height+"&cookie="+F;for(ao in J){ap+="&"+J[ao][0]+"="+J[ao][2]}if(a(aq)){if(aq!==null){ap+="&data="+o(al(aq))}}else{if(a(X)){ap+="&data="+o(al(X))}}ap+=f(an);return ap}function A(an,ao){var am=R(ao,"log")+"&action_name="+o(a(an)?an:aj);ag(am,L)}function ah(am,ap,ao){var an=R(ao,"goal")+"&idgoal="+am;if(a(ap)&&ap!==null){an+="&revenue="+ap}ag(an,L)}function O(an,am,ap){var ao=R(ap,"click")+"&"+am+"="+o(an)+"&redirect=0";ag(ao,L)}function U(ap){var an,am,ao;for(an=0;an<ab.length;an++){am=ab[an].toLowerCase();if(ap==am){return true}if(am.substr(0,2)=="*."){if((ap)==am.substr(2)){return true}ao=ap.length-am.length+1;if((ao>0)&&(ap.substr(ao)==am.substr(1))){return true
}}}return false}function V(ao,an){var ap,am="(^| )(piwik[_-]"+an;if(a(ao)){for(ap=0;ap<ao.length;ap++){am+="|"+ao[ap]}}am+=")( |$)";return new RegExp(am)}function ai(ap,am,aq){if(!aq){return"link"}var ao=V(ac,"download"),an=V(ad,"link"),ar=new RegExp("\\.("+P+")([?&#]|$)","i");return an.test(ap)?"link":(ao.test(ap)||ar.test(am)?"download":0)}function N(au){var an,at,av,am;if(!a(au)){au=y.event}if(a(au.target)){an=au.target}else{if(a(au.srcElement)){an=au.srcElement}else{return}}while((at=an.parentNode)&&((av=an.tagName)!="A"&&av!="AREA")){an=at}if(a(an.href)){var ar=an.hostname,ap=ar.toLowerCase(),ao=an.href.replace(ar,ap),aq=new RegExp("^(javascript|vbscript|jscript|mocha|livescript|ecmascript): *","i");if(!aq.test(ao)){am=ai(an.className,ao,U(ap));if(am){O(ao,am)}}}}function ae(am){p(am,"click",N,false)}function S(){if(!T){T=true;var an,am=V(D,"ignore"),ao=d.links;if(ao){for(an=0;an<ao.length;an++){if(!am.test(ao[an].className)){ae(ao[an])}}}}}F=W();H();return{setTrackerUrl:function(am){if(a(am)){M=am
}}}return false}function V(ao,an){var ap,am="(^| )(piwik[_-]"+an;if(a(ao)){for(ap=0;ap<ao.length;ap++){am+="|"+ao[ap]}}am+=")( |$)";return new RegExp(am)}function ai(ap,am,aq){if(!aq){return"link"}var ao=V(ac,"download"),an=V(ad,"link"),ar=new RegExp("\\.("+P+")([?&#]|$)","i");return an.test(ap)?"link":(ao.test(ap)||ar.test(am)?"download":0)}function N(au){var an,at,av,am;if(!a(au)){au=z.event}if(a(au.target)){an=au.target}else{if(a(au.srcElement)){an=au.srcElement}else{return}}while((at=an.parentNode)&&((av=an.tagName)!="A"&&av!="AREA")){an=at}if(a(an.href)){var ar=an.hostname,ap=ar.toLowerCase(),ao=an.href.replace(ar,ap),aq=new RegExp("^(javascript|vbscript|jscript|mocha|livescript|ecmascript): *","i");if(!aq.test(ao)){am=ai(an.className,ao,U(ap));if(am){O(ao,am)}}}}function ae(am){p(am,"click",N,false)}function S(){if(!T){T=true;var an,am=V(D,"ignore"),ao=d.links;if(ao){for(an=0;an<ao.length;an++){if(!am.test(ao[an].className)){ae(ao[an])}}}}}F=W();H();return{setTrackerUrl:function(am){if(a(am)){M=am
}},setSiteId:function(am){if(a(am)){ak=am}},setCustomData:function(am){if(a(am)){X=am}},setLinkTrackingTimer:function(am){if(a(am)){L=am}},setDownloadExtensions:function(am){if(a(am)){P=am}},addDownloadExtensions:function(am){if(a(am)){P+="|"+am}},setDomains:function(am){if(typeof am=="object"&&am instanceof Array){ab=am;ab.push(E)}else{if(typeof am=="string"){ab=[am,E]}}},setIgnoreClasses:function(am){if(typeof am=="object"&&am instanceof Array){D=am}else{if(typeof am=="string"){D=[am]}}},setRequestMethod:function(am){B=am||"GET"},setReferrerUrl:function(am){if(a(am)){aa=am}},setCustomUrl:function(am){if(a(am)){af=am}},setDocumentTitle:function(am){if(a(am)){aj=am}},setDownloadClasses:function(am){if(typeof am=="object"&&am instanceof Array){ac=am}else{if(typeof am=="string"){ac=[am]}}},setDownloadClass:function(am){if(typeof am=="string"){ac=[am]}},setLinkClasses:function(am){if(typeof am=="object"&&am instanceof Array){ad=am}else{if(typeof am=="string"){ad=[am]}}},setLinkClass:function(am){if(typeof am=="string"){ad=[am]
}},addListener:function(am){if(a(am)){ae(am)}},enableLinkTracking:function(){if(g){S()}else{u[u.length]=function(){S()}}},trackGoal:function(am,ao,an){ah(am,ao,an)},trackLink:function(an,am,ao){O(an,am,ao)},trackPageView:function(am,an){A(am,an)}}}function b(){return{push:t}}function n(){if(a(_paq)){x=new w();for(var z=0;z<_paq.length;z++){t(_paq[z])}_paq=new b()}}p(y,"beforeunload",v,false);s();n();return{addPlugin:function(z,A){r[z]=A},getTracker:function(z,A){return new w(z,A)}}}());piwik_log=function(b,e,c,f){function a(g){try{return eval("piwik_"+g)}catch(h){}return}var d=Piwik.getTracker(c,e);d.setDocumentTitle(b);d.setCustomData(f);d.setLinkTrackingTimer(a("tracker_pause"));d.setDownloadExtensions(a("download_extensions"));d.setDomains(a("hosts_alias"));d.setIgnoreClasses(a("ignore_classes"));d.trackPageView();if(a("install_tracker")!==false){piwik_track=function(h,j,i,g){d.setSiteId(j);d.setTrackerUrl(i);d.trackLink(h,g)};d.enableLinkTracking()}}};
\ No newline at end of file
}},addListener:function(am){if(a(am)){ae(am)}},enableLinkTracking:function(){if(g){S()}else{u[u.length]=function(){S()}}},trackGoal:function(am,ao,an){ah(am,ao,an)},trackLink:function(an,am,ao){O(an,am,ao)},trackPageView:function(am,an){A(am,an)}}}function b(){return{push:t}}p(z,"beforeunload",v,false);s();y=new x();for(var w=0;w<_paq.length;w++){t(_paq[w])}_paq=new b();return{addPlugin:function(i,A){r[i]=A},getTracker:function(i,A){return new x(i,A)}}}()),piwik_track,piwik_log=function(b,e,c,f){function a(g){try{return eval("piwik_"+g)}catch(h){}return}var d=Piwik.getTracker(c,e);d.setDocumentTitle(b);d.setCustomData(f);d.setLinkTrackingTimer(a("tracker_pause"));d.setDownloadExtensions(a("download_extensions"));d.setDomains(a("hosts_alias"));d.setIgnoreClasses(a("ignore_classes"));d.trackPageView();if(a("install_tracker")!==false){piwik_track=function(h,j,i,g){d.setSiteId(j);d.setTrackerUrl(i);d.trackLink(h,g)};d.enableLinkTracking()}};
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter