1jQuery(document).ready(function($) { 2 3 var formid; 4 var formid_long; 5 6 // Helper function to decode URL and fix double slashes 7 function decodeRedirectUrl(url) { 8 // Decode JSON escaped slashes and fix any double slashes 9 var decodedUrl = url.replace(/\\\//g, '/'); 10 // Remove any double slashes except after protocol (http:// or https://) 11 decodedUrl = decodedUrl.replace(/([^:]\/)\/+/g, '$1'); 12 return decodedUrl; 13 } 14 15 // for redirect method 1 16 document.addEventListener('wpcf7mailsent', function( event ) { 17 var id_long = event.detail.id; 18 var id = event.detail.contactFormId; 19 20 var formid = id_long; 21 var formid = id; 22 23 var forms = cf7rl_ajax_object.cf7rl_forms; 24 25 var array_list = forms.split(","); 26 27 array_list.forEach(function(item) { 28 29 // check to see if this array item has redirect enabled 30 var result_url = forms.indexOf(id+'|url'); 31 var result_thank = forms.indexOf(id+'|thank'); 32 33 34 var item_list = item.split("|"); 35 36 if (item_list[1] == id) { 37 38 var url = decodeRedirectUrl(item_list[3]); 39 var tab = item_list[4]; 40 41 42 // url 43 if (result_url > -1) { 44 // open in same tab 45 if (tab == 0) { 46 window.location.href = url; 47 } 48 // open in new tab 49 if (tab == 1) { 50 var win = window.open(url, '_blank'); 51 win.focus(); 52 } 53 } 54 55 56 // thank you page 57 if (result_thank > -1) { 58 59 var data = { 60 'action': 'cf7rl_get_form_thank', 61 'formid': formid, 62 'nonce': cf7rl_ajax_object.cf7rl_nonce, 63 }; 64 65 jQuery.ajax({ 66 type: "POST", 67 data: data, 68 dataType: "json", 69 async: false, 70 url: cf7rl_ajax_object.cf7rl_ajax_url, 71 xhrFields: { 72 withCredentials: true 73 }, 74 success: function (response) { 75 76 var formidPrefix = 'wpcf7-f'; 77 var formid_new = formidPrefix + formid; 78 79 jQuery('[id^="'+formid_new+'"]').html(response.html); 80 81 } 82 }); 83 84 } 85 86 } 87 88 }); 89 90 }, false ); 91 92 93 94 95 96 97 98 99 100 101 102 // for redirect method 2 - with WPCF7_LOAD_JS off 103 if (jQuery('.wpcf7-form[data-status="sent"]')[0]) { 104 105 jQuery('.wpcf7-form[data-status="sent"]').each(function() { 106 var id_long = jQuery(this).closest('.wpcf7').attr("id"); 107 var id = id_long.split('f').pop().split('-').shift(); 108 109 var formid = id_long; 110 var formid = id; 111 112 var forms = cf7rl_ajax_object.cf7rl_forms; 113 114 var array_list = forms.split(","); 115 116 array_list.forEach(function(item) { 117 118 // check to see if this array item has redirect enabled 119 var result_url = forms.indexOf(id+'|url'); 120 var result_thank = forms.indexOf(id+'|thank'); 121 122 123 var item_list = item.split("|"); 124 125 if (item_list[1] == id) { 126 127 var url = decodeRedirectUrl(item_list[3]); 128 var tab = item_list[4]; 129 130 131 // url 132 if (result_url > -1) { 133 // open in same tab 134 if (tab == 0) { 135 window.location.href = url; 136 } 137 // open in new tab 138 if (tab == 1) { 139 var win = window.open(url, '_blank'); 140 win.focus(); 141 } 142 } 143 144 145 // thank you page 146 if (result_thank > -1) { 147 148 var data = { 149 'action': 'cf7rl_get_form_thank', 150 'formid': formid, 151 'nonce': cf7rl_ajax_object.cf7rl_nonce, 152 }; 153 154 jQuery.ajax({ 155 type: "POST", 156 data: data, 157 dataType: "json", 158 async: false, 159 url: cf7rl_ajax_object.cf7rl_ajax_url, 160 xhrFields: { 161 withCredentials: true 162 }, 163 success: function (response) { 164 165 var formidPrefix = 'wpcf7-f'; 166 var formid_new = formidPrefix + formid; 167 168 jQuery('[id^="'+formid_new+'"]').html(response.html); 169 170 } 171 }); 172 173 } 174 175 } 176 177 }); 178 }); 179 }; 180 181 182 183 184 185 186 187});
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.