1(function ($) { 2 3 var el_form = $('#form-new-post'), 4 el_form_submit = $('.submit', el_form); 5 6 // Fires when the form is submitted. 7 el_form.on('submit', function (e) { 8 e.preventDefault(); 9 10 el_form_submit.attr('disabled', 'disabled'); 11 //var donotsell_email= jQuery('input[name="donotsell_email"]').val(); 12 //console.log(isEmail(donotsell_email)); 13 new_post(); 14 }); 15 /* function isEmail(email) { 16 var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; 17 return regex.test(email); 18 } */ 19 // Ajax request. 20 function new_post() { 21 $.ajax({ 22 url: localized_donot_sell_form.admin_donot_sell_ajax_url, 23 type: 'POST', 24 dataType: 'json', 25 data: { 26 action: 'donot_sell_save_post', // Set action without prefix 'wp_ajax_'. 27 form_data: el_form.serialize() 28 }, 29 cache: false 30 }).done(function (r) { 31 console.log(r); 32 if (r.donotsellrequests !== '') { 33 console.log('complete') 34 jQuery('#donotsellmsg').addClass('donotsell-msg'); 35 jQuery('#donotsellmsg').removeClass('donotsell-error-msg'); 36 jQuery('#donotsellmsg').text('Request has been submitted successfully!!').delay(10000).fadeOut(); 37 //el_form_submit.attr('data-is-updated', 'true'); 38 //el_form_submit.text(el_form_submit.data('is-update-text')); 39 } 40 console.log(r.error) 41 if(r.error !=='' && r.error != undefined){ 42 jQuery('#donotsellmsg').removeClass('donotsell-msg'); 43 jQuery('#donotsellmsg').addClass('donotsell-error-msg'); 44 jQuery('#donotsell-error-msg').text(r.error).delay(10000).fadeOut(); 45 } 46 el_form_submit.removeAttr('disabled'); 47 }); 48 } 49 50 // Used to trigger/simulate post submission without user action. 51 function trigger_new_post() { 52 el_form.trigger('submit'); 53 } 54 55 // Sets interval so the post the can be updated automatically provided that it was already created. 56 /* setInterval(function () { 57 if (el_form_submit.attr('data-is-updated') === 'false') { 58 return false; 59 } 60 61 trigger_new_post(); 62 }, 5000); // Set to 5 seconds. */ 63 64})(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.