1jQuery( document ).ready( function( $ ) { 2 $( document ).on( 'click', '.gallery-attributes.colors button', function() { 3 let color = $( this ).data('gallery'); 4 const url = new URL(window.location.href); 5 6 url.searchParams.delete('variation'); 7 url.searchParams.set('color', color); 8 window.history.replaceState(null, null, url); // pushState 9 } ); 10 11 $( document ).on( 'click', '.gallery-attributes.custom-variations div[data-gallery]', function() { 12 13 let value = $( this ).data('gallery'); 14 // value_arr = value.split('-'); // variation ID 15 16 const url = new URL(window.location.href); 17 18 if ( value ) { 19 url.searchParams.delete('color'); // Delete all params 20 url.searchParams.set('variation', value); 21 window.history.replaceState(null, null, url); // pushState 22 } 23 }); 24 25 // autoselect params 26 let urlParams = new URLSearchParams(window.location.search); //get all parameters 27 let color = urlParams.get('color'), 28 variation = urlParams.get('variation'); 29 30 setTimeout(function() { 31 if (color) { //check if foo parameter is set to anything 32 jQuery('button[data-gallery="'+color+'"]').click(); 33 } else if ( variation ) { 34 jQuery('div[data-gallery="'+variation+'"]').click(); 35 } 36 }, 200); 37} );
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.