1( function ( $ ) { 2 $( function () { 3 // Enable Flatpickr on Date Fields 4 $( '.view-search-date-single' ).each( function () { 5 var type = $( this ).data( 'date-type' ); 6 var altFormat = $( this ).data( 'alt-format' ); 7 //var type = $( this ).data( 'date-type' ); 8 var options = { 9 dateFormat: $( this ).data( 'format' ), 10 altFormat: altFormat, 11 altInput: true, 12 altInputClass: 'wpf-views-date' 13 }; 14 if ( type === 'date-time' ) { 15 options.enableTime = true; 16 if ( $( this ).data( 'time_24hr' ) ) { 17 options.time_24hr = true 18 } 19 } else if ( type === 'time' ) { 20 options.enableTime = true; 21 options.noCalendar = true; 22 options.altInput = false; 23 24 if ( $( this ).data( 'time_24hr' ) ) { 25 options.time_24hr = true 26 } 27 } 28 29 console.log( options ); 30 $( this ).flatpickr( options ); 31 } ) 32 $( '.view-search-entry-date' ).flatpickr(); 33 // Enable Flatpickr on Date Range Fields 34 $( '.view-search-date-range' ).flatpickr( { mode: 'range', } ); 35 36 // Handle duplicate entry AJAX call 37 $( document ).on( 'click', '.wpf_views_duplicate_entry', function ( e ) { 38 e.preventDefault(); 39 40 var $link = $( this ); 41 var entryId = $link.data( 'entry-id' ); 42 var nonce = $link.data( 'nonce' ); 43 var redirectEnabled = $link.data( 'redirect-enabled' ); 44 var editPageUrl = $link.data( 'edit-page-url' ); 45 var originalText = $link.text(); 46 47 // Show confirmation dialog 48 if ( !confirm( 'Are you sure you want to duplicate this entry?' ) ) { 49 return; 50 } 51 52 // Disable link and show loading state 53 $link.addClass( 'wpf-views-processing' ).text( 'Duplicating...' ); 54 55 // Perform AJAX request 56 $.ajax( { 57 url: wpforms_views_ajax.ajax_url, 58 type: 'POST', 59 data: { 60 action: 'wpf_views_duplicate_entry', 61 entry_id: entryId, 62 nonce: nonce 63 }, 64 dataType: 'json', 65 success: function ( response ) { 66 if ( response.success ) { 67 // Check if redirect to edit entry is enabled 68 if ( redirectEnabled === true && editPageUrl ) { 69 // The editPageUrl already has the placeholder entry_id in query params 70 // Replace the entry_id with the new duplicated entry_id 71 var editUrl = editPageUrl.replace( 72 /wpfentry_id=\d+/, 73 'wpfentry_id=' + response.data.new_entry_id 74 ); 75 76 // Redirect to edit entry page 77 window.location.href = editUrl; 78 } else { 79 // Default behavior: show message and reload 80 alert( response.data.message ); 81 window.location.reload(); 82 } 83 } else { 84 alert( 'Error: ' + response.data.message ); 85 $link.removeClass( 'wpf-views-processing' ).text( originalText ); 86 } 87 }, 88 error: function ( xhr, status, error ) { 89 console.error( 'AJAX Error:', error ); 90 alert( 'An error occurred while duplicating the entry. Please try again.' ); 91 $link.removeClass( 'wpf-views-processing' ).text( originalText ); 92 } 93 } ); 94 } ); 95 } ); 96} )( jQuery ); 97 98function wpf_views_clearForm( oForm ) { 99 var elements = oForm.elements; 100 101 oForm.reset(); 102 103 for ( i = 0; i < elements.length; i++ ) { 104 field_type = elements[ i ].type.toLowerCase(); 105 106 switch ( field_type ) { 107 case 'text': 108 case 'password': 109 case 'textarea': 110 elements[ i ].value = ''; 111 break; 112 113 case 'radio': 114 case 'checkbox': 115 if ( elements[ i ].checked ) { 116 elements[ i ].checked = false; 117 } 118 break; 119 120 case 'select-one': 121 case 'select-multi': 122 elements[ i ].selectedIndex = -1; 123 break; 124 case 'hidden': 125 break; 126 default: 127 break; 128 } 129 } 130 131 oForm.submit(); 132}
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.