1(function ($) { 2 const args = window.javo_points_args || [] 3 $(document).ready(function () { 4 // Apply points button click event handler 5 $('#apply-points-btn').on('click', function (e) { 6 e.preventDefault(); // Prevent default action 7 8 // Check if AJAX request is already in progress 9 if ($(this).hasClass('ajax-in-progress')) { 10 return; // Exit function if AJAX request is already in progress 11 } 12 13 var button = $(this); 14 var buttonText = button.find('.button-text'); 15 var spinner = button.find('.spinner-border'); 16 var pointsToUse = parseInt($('#javo-points-input').val()); 17 18 // Add class to indicate AJAX request is in progress 19 button.addClass('ajax-in-progress'); 20 button.prop('disabled', true); // Disable button 21 buttonText.addClass('visually-hidden'); // Hide button text 22 spinner.removeClass('visually-hidden'); // Show spinner 23 24 // Apply point discount and update cart using AJAX 25 $.ajax({ 26 url: args.ajax_url, // WordPress AJAX URL 27 type: 'POST', 28 data: { 29 action: 'apply_points_discount', // AJAX handler action 30 points_to_use: pointsToUse // Points to use 31 }, 32 success: function (response) { 33 // Call JavaScript function to update cart 34 // updateCart(); 35 // console.log('ok2'); 36 // jQuery(document.body).trigger('wc_fragment_refresh'); 37 jQuery('body').trigger('update_checkout'); 38 }, 39 error: function (xhr, status, error) { 40 // Handle errors if AJAX request fails 41 console.error(error); 42 }, 43 complete: function () { 44 // Remove class indicating AJAX request is in progress upon completion 45 button.removeClass('ajax-in-progress'); 46 button.prop('disabled', false); // Re-enable button 47 buttonText.removeClass('visually-hidden'); // Show button text 48 spinner.addClass('visually-hidden'); // Hide spinner 49 } 50 }); 51 }); 52 53 // Bootstrap Table 54 var $table = $('#jv-point-table'); 55 56 $table.bootstrapTable({ 57 sortReset: true 58 }); 59 60 $('#resetSort').click(function () { 61 $table.bootstrapTable('resetView'); 62 console.log('Reset sort button clicked'); 63 $table.bootstrapTable('refresh'); 64 65 $table.bootstrapTable('refreshOptions', { 66 sortReset: true 67 }); 68 }); 69 70 }); 71})(jQuery); 72 73function customSort(sortName, sortOrder, data) { 74 var order = sortOrder === 'desc' ? -1 : 1; 75 data.sort(function (a, b) { 76 var aa = +((a[sortName] + '').replace(/[^\d]/g, '')); 77 var bb = +((b[sortName] + '').replace(/[^\d]/g, '')); 78 if (aa < bb) { 79 return order * -1; 80 } 81 if (aa > bb) { 82 return order; 83 } 84 return 0; 85 }); 86}
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.