1jQuery(document).ready(function(){ 2 3 if( !bt_frontend_script_vars.is_preview && jQuery('.conversion-module').length > 0 ) { 4 jQuery('.conversion-module').remove(); 5 } 6 7 if( window.bt_conversion_vars ) { 8 9 jQuery.each(bt_conversion_vars, function(key, conversion_el) { 10 11 // page load conversion 12 if ( conversion_el.type !== 'click' ) 13 { 14 var eid = conversion_el.eid; 15 var variationObj = abstGetCookie('btab_'+eid); 16 17 if( !variationObj ) { 18 return true; 19 } 20 21 variationObj = JSON.parse(variationObj); 22 23 if( bt_experiments[eid] === undefined ) { 24 return false; 25 } 26 27 // if its converted already 28 if( variationObj.conversion == 1 ) { 29 console.info('AB Split test already converted.'); 30 return true; 31 } 32 33 // if its not an empty conversion URL or page, then it must be defined elsewhere 34 if( bt_experiments[eid].conversion_url != '' || bt_experiments[eid].conversion_page != '' ) { 35 if(bt_experiments[eid].conversion_url == 'embed') 36 console.info('AB Split Test conversion defined as external URL, but conversion module used. Please check your configuration settings. This is a soft error and a conversion event has not been blocked.'); 37 else 38 return true; 39 } 40 41 42 variation = variationObj.variation; 43 44 var convertType = conversion_el.type; 45 var convertClickSelector = conversion_el.selector; 46 47 if (typeof conversion_details !== 'undefined' ) // we have a conversion page URL set, 48 { 49 if(typeof conversion_details[eid] !== 'undefined') 50 { 51 console.log('Possible duplicate conversion event. Check your set up.'); 52 } 53 } 54 55 if(variation){ 56 bt_experiment_w(eid,variation,'conversion',false); 57 variationObj.conversion = 1; 58 variationObj = JSON.stringify(variationObj); 59 abstSetCookie('btab_'+eid, variationObj, 1000); 60 } 61 } 62 63 // click conversion 64 if( conversion_el.type == 'click' ) 65 { 66 var convertClickSelector = conversion_el.selector; 67 //find link 68 if( jQuery(convertClickSelector).length > 0 ) { 69 //cool 70 } 71 else if( jQuery(convertClickSelector + " a").length > 0 ) { 72 //add the "a" 73 convertClickSelector += " a"; 74 } 75 else if( jQuery(convertClickSelector + " img").length > 0 ) { 76 //add the "a" 77 convertClickSelector += " img"; 78 } 79 else 80 { 81 console.log("no conversion elements found"); 82 } 83 84 if( jQuery(convertClickSelector).length > 0 ) { 85 86 jQuery('body').on('click', convertClickSelector,function(event){ 87 var convertElement = jQuery(this); 88 var url = convertElement.attr('href'); 89 var target = convertElement.attr('target'); 90 var eid = conversion_el.eid; 91 92 var variationObj = abstGetCookie('btab_'+eid); 93 variationObj = JSON.parse(variationObj); 94 95 //console.log('variationObj', variationObj); 96 97 if( bt_experiments[eid] === undefined ) { 98 return false; 99 } 100 101 if( variationObj.conversion == 1 ) { 102 console.log('ab test already converted.'); 103 return true; 104 } 105 106 variation = variationObj.variation; 107 108 if(url && (target !== '_blank')) 109 { 110 event.preventDefault(); 111 bt_experiment_w(eid,variation,'conversion',url); 112 } 113 else 114 { 115 bt_experiment_w(eid,variation,'conversion',false); 116 } 117 118 variationObj.conversion = 1; 119 variationObj = JSON.stringify(variationObj); 120 abstSetCookie('btab_'+eid, variationObj, 1000); 121 }); 122 123 } 124 } 125 }); 126 127 } 128 129 // admin bar test helper... 130 var submenus = ''; 131 var bt_conversion_icon = '<div class="ab-flag-filled"></div>'; 132 var bt_variation_icon = '<div class="ab-split"></div>'; 133 var bt_split_test_icon = '<div class="ab-test-tube"></div>'; 134 var conversions = {}; 135 136 //clean up conversions 137 if(window.bt_conversion_vars) 138 { 139 jQuery.each(bt_conversion_vars, function(index,value){ 140 conversions[value.eid] = value; 141 }); 142 } 143 144 if(window.bt_experiments) 145 { 146 jQuery.each(bt_experiments, function(index,test){ 147 //each experiment 148 shownPrimary = false; 149 150 if(!jQuery('[bt-eid="'+index+'"]').length && !conversions[index] && bt_experiments[index].test_type !== 'magic') // if no tests or conversions, then skip er{} 151 return; 152 153 //create experiment menu 154 155 // magic tests 156 if(test.test_type == 'magic' && test.magic_definition && test.magic_definition.length > 0) 157 { 158 try { 159 // Parse the magic_definition if it's a string 160 let magicDefs = typeof test.magic_definition === 'string' 161 ? JSON.parse(test.magic_definition) 162 : test.magic_definition; 163 164 if(Array.isArray(magicDefs)) { 165 // Each magic definition 166 //we only care abt 1st item 167 magicItem = magicDefs[0]; 168 if(jQuery(magicItem.selector).length > 0) { 169 if(!shownPrimary) { 170 submenus += '<li><a class="ab-item" target="_blank" href="'+bt_adminurl+'post.php?post='+index+'&action=edit">'+bt_split_test_icon+'<strong>'+ test.name +'</strong></a></li>'; 171 shownPrimary = true; 172 magicResults = true; 173 } 174 // Get variation display text 175 if (magicItem.variations && magicItem.variations.length > 0) { 176 varName = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]; 177 magicItem.variations.forEach((variation, ix) => { 178 variationText = bt_variation_icon + " Variation " + varName[ix]; 179 if(ix == 0)
180 variationText += " (Original)"; 181 submenus += '<li><a class="ab-item" magic-eid="' + index + '" magic-index="' + ix + '"> '+ variationText + '</a></li>'; 182 }); 183 } 184 } 185 } else { 186 console.log('Invalid magic test definition:', magicItem); 187 } 188 } catch(e) { 189 console.log('Error parsing magic test definition:', e); 190 } 191 } // end magic test 192 else 193 submenus += '<li><a class="ab-item" target="_blank" href="'+bt_adminurl+'post.php?post='+index+'&action=edit">'+bt_split_test_icon+'<strong>'+ test.name +'</strong></a></li>'; 194 195 variations = []; 196 //list test variations 197 jQuery('[bt-eid="'+index+'"]').each(function(){ 198 spantext = ''; 199 if(jQuery(this).attr('bt-url')) 200 spantext = jQuery(this).attr('bt-url').replace(/^.*\/\/[^\/]+/, ''); 201 else if(btab_vars.post_id == jQuery(this).attr('bt-variation')) 202 spantext = 'Current Page'; 203 else 204 spantext = jQuery(this).attr('bt-variation'); 205 206 if( variations.indexOf(jQuery(this).attr('bt-variation')) === -1) 207 { 208 variations.push(jQuery(this).attr('bt-variation')); 209 submenus += '<li><a class="ab-item ab-test" show-css = "'+jQuery(this).attr('bt-variation')+'" show-url="' + jQuery(this).attr('bt-url') + '" show-eid="' + jQuery(this).attr('bt-eid') + '"show-variation="' + jQuery(this).attr('bt-variation') + '"> ' + bt_variation_icon + ' <span class="variation-tag-button">' + spantext + '</span></a></li>'; 210 } 211 }); 212 213 214 //list conversions 215 if(conversions[index]) 216 { 217 if(conversions[index]['type'] != 'load') 218 submenus += '<li><a class="ab-item ab-test test-conversion">'+bt_conversion_icon+' '+ conversions[index]['type'] + " <div class='ab-test-selector'>" + conversions[index]['selector'] + '</div></a></li>'; 219 else 220 submenus += '<li><a class="ab-item ab-test test-conversion">'+bt_conversion_icon+' On page load</a></li>'; 221 } 222 }); 223 224 } 225 226 var bt_variations_found = jQuery('[bt-eid]:not([bt-eid=""])[bt-variation]:not([bt-variation=""])'); 227 228 if(bt_variations_found.length || !jQuery.isEmptyObject(conversions) || magicResults) 229 { 230 submenus += '<li><a class="ab-item ab-sub-secondary" id="ab-clear-test-cookies">Clear AB Test Cookies</a></li>'; 231 232 //add admin bar if not there 233 if(!jQuery('#wp-admin-bar-ab-test').length) 234 jQuery("#wp-admin-bar-root-default").append('<li id="wp-admin-bar-ab-test" class="menupop"><div class="ab-item ab-empty-item" aria-haspopup="true">'+bt_split_test_icon+'A/B Split Test</div><div class="ab-sub-wrapper"><ul class="ab-submenu"></ul></div></li>'); 235 236 jQuery("#wp-admin-bar-ab-test ul.ab-submenu").prepend(submenus); 237 238 jQuery('#wp-admin-bar-ab-test [show-variation]').click(function(){ 239 240 var showeid = jQuery(this).attr('show-eid'); 241 var showevar = jQuery(this).attr('show-variation'); 242 var showurl = jQuery(this).attr('show-url'); 243 244 if(showevar.indexOf('test-css-') != -1) 245 { 246 result = showevar.replace(/-\d+$/, ''); 247 removeTestClasses(jQuery('body'),showeid ); 248 jQuery('body').addClass(showevar); 249 } 250 251 if(showurl != 'undefined') 252 { 253 var win = window.open(showurl, '_blank'); 254 if (win) { 255 //Browser has allowed it to be opened 256 win.focus(); 257 } else { 258 //Browser has blocked it 259 alert('Please allow popups to preview full page test pages'); 260 } 261 } 262 263 jQuery('[bt-eid="'+showeid+'"]').removeClass('bt-show-variation'); 264 jQuery('[bt-eid="'+showeid+'"][bt-variation="'+showevar+'"]').addClass('bt-show-variation'); 265 bt_highlight('[bt-eid="'+showeid+'"][bt-variation="'+showevar+'"]'); 266 jQuery('body').trigger('ab-test-setup-complete'); 267 window.dispatchEvent(new Event('resize')); // trigger a window resize event. Useful for sliders etc. that dynamically resize 268 269 }); // end show variation 270 271 jQuery('#wp-admin-bar-ab-test>a').mouseenter(function(){ 272 bt_highlight("[bt-eid]"); 273 }); 274 275 jQuery('#wp-admin-bar-ab-test>a').click(function(){ 276 bt_highlight("[bt-eid]"); 277 }); 278 279 jQuery('.test-conversion').click(function(){ 280 bt_highlight(jQuery(this).find('.ab-test-selector').text()); 281 }); 282 283 jQuery('#ab-clear-test-cookies').click(function(){ 284 if(confirm("Clear your A/B Split Test cookies?")) 285 { 286 alert('A/B split test cookies cleared\n\nRefresh your page to see another random variation.'); 287 //get all experiments on page 288 jQuery('[bt-eid]').each(function(){ 289 abstSetCookie('btab_' + jQuery(this).attr('bt-eid'), '', -1); 290 }); 291 } 292 }); 293 294 if ( typeof(jQuery.fn.hoverIntent) == 'undefined' ) 295 !function(I){I.fn.hoverIntent=function(e,t,n){function r(e){o=e.pageX,v=e.pageY}var o,v,i,u,s={interval:100,sensitivity:6,timeout:0},s="object"==typeof e?I.extend(s,e):I.isFunction(t)?I.extend(s,{over:e,out:t,selector:n}):I.extend(s,{over:e,out:e,selector:t}),h=function(e,t){if(t.hoverIntent_t=clearTimeout(t.hoverIntent_t),Math.sqrt((i-o)*(i-o)+(u-v)*(u-v))<s.sensitivity)return I(t).off("mousemove.hoverIntent",r),t.hoverIntent_s=!0,s.over.apply(t,[e]);i=o,u=v,t.hoverIntent_t=setTimeout(function(){h(e,t)},s.interval)},t=function(e){var n=I.extend({},e),o=this;o.hoverIntent_t&&(o.hoverIntent_t=clearTimeout(o.hoverIntent_t)),"mouseenter"
295===e.type?(i=n.pageX,u=n.pageY,I(o).on("mousemove.hoverIntent",r),o.hoverIntent_s||(o.hoverIntent_t=setTimeout(function(){h(n,o)},s.interval))):(I(o).off("mousemove.hoverIntent",r),o.hoverIntent_s&&(o.hoverIntent_t=setTimeout(function(){var e,t;e=n,(t=o).hoverIntent_t=clearTimeout(t.hoverIntent_t),t.hoverIntent_s=!1,s.out.apply(t,[e])},s.timeout)))};return this.on({"mouseenter.hoverIntent":t,"mouseleave.hoverIntent":t},s.selector)}}(jQuery); 296 //add hoverintent for the data 297 jQuery('#wp-admin-bar-ab-test').hoverIntent({ 298 over: function(e){ 299 jQuery(this).addClass('hover'); 300 }, 301 out: function(e){ 302 jQuery(this).removeClass('hover'); 303 }, 304 timeout: 180, 305 sensitivity: 7, 306 interval: 100 307 }); 308 } 309}); 310 311function removeTestClasses(element, testId) { 312 var classNames = element.attr('class').split(/\s+/); 313 jQuery.each(classNames, function (index, className) { 314 var regex = new RegExp('test-css-' + testId + '-\\d+'); 315 if (regex.test(className)) { 316 element.removeClass(className); 317 } 318 }); 319}
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.