1/** 2 * JS Help Functions 3 * Copyright 2011, Stephen Liu 4 * WiderFunnel Marketing Optimization 5 * Website: http://www.widerfunnel.com 6 * 7 * Date: 2011-10-06 8 */ 9 10// Widerfunnel Namespace 11var _wf = _wf || {}; 12 13if (typeof _wf.debug === 'undefined') { 14 _wf.debug = function(o) { 15 if (window.console && window.console.log) 16 window.console.log(o); 17 } 18} 19 20 21if (typeof _wf._lib_widerfunnel === 'undefined') { 22 23 (function() { 24 _wf._lib_widerfunnel = "2.1.1"; 25 26 var REFERRER_COOKIE_KEY = "wf_referrer"; 27 28 // Modded of http://www.quirksmode.org/js/cookies.html 29 // can still be modded to add change path 30 _wf.createCookie = function(name,value,days,domain) { 31 var expires = ""; 32 if (days) { 33 var date = new Date(); 34 date.setTime(date.getTime()+(days*24*60*60*1000)); 35 expires = "; expires="+date.toGMTString(); 36 } 37 var cookie = ""; 38 if (domain) { 39 cookie = name+"="+value+expires+"; path=/; domain=" + domain; 40 } else { 41 cookie = name+"="+value+expires+"; path=/"; 42 } 43 document.cookie = cookie; 44 }; 45 46 _wf.readCookie = function(name) { 47 var nameEQ = name + "="; 48 var ca = document.cookie.split(';'); 49 for(var i=0;i < ca.length;i++) { 50 var c = ca[i]; 51 while (c.charAt(0)==' ') c = c.substring(1,c.length); 52 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); 53 } 54 return null; 55 }; 56 57 _wf.eraseCookie = function(name) { 58 _wf.createCookie(name,"",-1); 59 }; 60 61 _wf.setControlReferrer = function(r) { 62 if (r) 63 _wf.createCookie(REFERRER_COOKIE_KEY, encodeURIComponent(r)); 64 else 65 _wf.eraseCookie(REFERRER_COOKIE_KEY); 66 }; 67 68 _wf.getControlReferrer = function() { 69 var r = _wf.readCookie(REFERRER_COOKIE_KEY); 70 if (r) 71 return decodeURIComponent(r); 72 else 73 return null; 74 }; 75 76 // Save referrer, then redirect 77 _wf.controlPageRedirect = function(param, debug) { 78 var d=document, l=location, s=l.search, h=l.href, arr=h.split("#"), url; 79 if (param.indexOf("wfvar=") === -1 ) { 80 // Redirect to URL 81 url = param + s; 82 } else { 83 // Redirect to same page, add ?wfvar= 84 var qs = param; 85 url = h.indexOf("?") === -1 ? arr[0] + "?" + qs: arr[0] + "&" + qs; 86 } 87 // Save referrer for GA 88 if (d.referrer) { 89 _wf.setControlReferrer(d.referrer); 90 } 91 92 if (debug) { 93 _wf.debug("redirect url:" + url + l.hash); 94 } else { 95 l.replace(url + l.hash); 96 } 97 }; 98 99 // Returns the combination order of a GWO test 100 _wf.combination = function() { 101 if (typeof utmx === 'function') { 102 var combo = utmx('combination'); 103 if (typeof combo !== 'undefined') { 104 return "" + combo; 105 } 106 } 107 108 return null; 109 }; 110 111 // 1.7 Modified http://stackoverflow.com/questions/901115/get-query-string-values-in-javascript 112 _wf.getQueryStringValue = function(name) { 113 name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); 114 var regexS = "[\\?&]" + name + "=([^&#]*)"; 115 var regex = new RegExp(regexS); 116 var results = regex.exec(window.location.href); 117 118 if (results != null) 119 return decodeURIComponent(results[1].replace(/\+/g, " ")); 120 else 121 return null; 122 }; 123 124 // Save referrer 125 _wf.refOverride = null; 126 127 var ref = _wf.getControlReferrer(); 128 129 if (ref !== null) { 130 _wf.refOverride = ref; 131 _wf.setControlReferrer(null); 132 } 133 134 })(); // closure 135 136} 137
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.