1(function($){ 2 console.log('sort init'); 3 $(function(){ 4 const pub_count = sort_params.pub_count; 5 const show_mid_ad = sort_params.show_mid_ad; 6 const show_mid_hero = sort_params.show_mid_hero; 7 const loop_selector = show_mid_ad != false || show_mid_hero != false ? '#loop-pt-2' : '#loop-pt-1'; 8 9 let chunks = []; 10 var key = show_mid_ad != false || show_mid_hero != false ? 2 : 1; 11 if ($('body').hasClass('page-template-landingpage')) { 12 get_posts(); 13 } 14 $('#sort-landing-posts').on('change', function(){ 15 var sort_by = $(this).val(); 16 $.ajax({ 17 url:sort_params.ajaxurl, 18 data: { 19 'action': 'skal_sort', 20 'sortby': sort_by 21 }, 22 type: 'POST', 23 beforeSend:function(xhr){ 24 // filter.find('button').text('Processing...'); // changing the button label 25 }, 26 success:function(data){ 27 chunks = []; 28 var results = $.parseJSON(data); 29 // console.log(results); 30 for (c = 0; c <= results.length; c++) { 31 if (c % pub_count === 0) { 32 var end = parseInt(c)+parseInt(pub_count); 33 chunks.push(results.slice(c,end)); 34 } 35 } 36 add_initial_posts(chunks); 37 $('.showmore').unbind('click').click(paste_more_posts); 38 } 39 }); 40 }); 41 function paste_more_posts() { 42 if (typeof chunks[key] == 'undefined') { // start over 43 key = show_mid_ad != false || show_mid_hero != false ? 2 : 1; 44 } 45 if (key < chunks.length && typeof chunks[key] != 'undefined') { 46 $(loop_selector).append(chunks[key].join("")); 47 key++; 48 if (key == chunks.length) { 49 $(this).fadeOut(); 50 } 51 } 52 else if (typeof chunks[key] == 'undefined') { // it is still undefined 53 $(this).fadeOut(); 54 } 55 } 56 function get_posts() { 57 $.ajax({ 58 url:sort_params.ajaxurl, 59 data: { 60 'action': 'skal_sort', 61 }, 62 type: 'POST', 63 beforeSend:function(xhr){ 64 console.log("getting posts"); 65 }, 66 success:function(data){ 67 chunks = []; 68 var results = $.parseJSON(data); 69 // console.log(results); 70 for (c = 0; c <= results.length; c++) { 71 if (c % pub_count === 0) { 72 var end = parseInt(c)+parseInt(pub_count); 73 chunks.push(results.slice(c,end)); 74 } 75 } 76 // console.log(chunks); 77 add_initial_posts(chunks); 78 }, 79 error:function( xhr, status, error ) { 80 console.log("an error occurred"); 81 console.log(xhr.responseText,status,error); 82 } 83 }); 84 $('.showmore').click(paste_more_posts); 85 } 86 function add_initial_posts(chunks) { 87 var pt_1 = chunks[0].join(""); 88 var pt_2 = chunks[1].join(""); 89 $('#loop-pt-1').html(pt_1); 90 if (loop_selector == '#loop-pt-2') { 91 $(loop_selector).html(pt_2); 92 } 93 if (chunks.length > 2) { 94 $('.showmore').css('display', 'inline-block'); 95 } 96 else { 97 $('.showmore').fadeOut(); 98 } 99 } 100 }); 101})(jQuery);
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.