1/** 2 * Wrapper function to safely use $ 3 */ 4function wpsfWrapper($) { 5 var wpsf = { 6 7 /** 8 * Main entry point 9 */ 10 init: function () { 11 //Timestamp protection 12 if (window.wpsf_timestamp_enabled) { 13 $('#commentform, #setupform, #registerform').append('<input type="hidden" name="wpsfTS1" id="wpsfTS1" value="1" />'); 14 $('#commentform, #setupform, #registerform').append('<input type="hidden" name="wpsfTS2" id="wpsfTS2" value="1" />'); 15 16 $('#wpsfTS1').val((new Date).getTime()); 17 } 18 //Not a spammer protection 19 if (window.wpsf_not_a_spammer_enabled) { 20 var wpsf_checkbox = $("<input>").attr("type", "checkbox").attr("id", "wpsf_not_a_spammer").attr("name", "wpsf_not_a_spammer"); 21 var wpsf_label = $("<label />").text(window.not_a_spammer_label); 22 $("#wpsf_p").append(wpsf_label); 23 wpsf_label.append(wpsf_checkbox); 24 } 25 //No Captcha reCaptcha protection 26 if (window.wpsf_recaptcha_enabled) { 27 var wpsf_recaptcha = $("<div>").attr("class", "g-recaptcha").attr("data-sitekey", window.captcha_site_key); 28 $("#wpsf_p").append(wpsf_recaptcha); 29 } 30 $('#commentform, #setupform, #registerform').submit(validateCommentForm); 31 32 } 33 }; // end wpsf 34 35 $(document).ready(wpsf.init); 36 37} // end wpsfWrapper() 38 39wpsfWrapper(jQuery); 40 41/** 42 * Checks the user input and issues an error message if required. 43 * Returns true if the checks were fine and false if an error message was displayed. 44 * 45 * @returns {boolean} 46 */
47function validateCommentForm() { 48 //Timestamp protection 49 if (window.wpsf_timestamp_enabled) { 50 var wpsfTS1 = document.getElementById("wpsfTS1").value; 51 var wpsfTS2 = (new Date).getTime(); 52 document.getElementById("wpsfTS2").value = wpsfTS2; 53 var diff = wpsfTS2 - wpsfTS1; 54 var remaining = Math.round((window.wpsf_threshold - diff) / 1000); 55 if (diff <= window.wpsf_threshold) { 56 alert(window.wpsf_message.format([Math.round(window.wpsf_threshold / 1000), remaining])); 57 return false; 58 } 59 } 60 //Not a spammer protection 61 if (window.wpsf_not_a_spammer_enabled) { 62 var wpsf_checkbox = document.getElementById("wpsf_not_a_spammer"); 63 if (wpsf_checkbox.checked != true) { 64 alert(window.not_a_spammer_user_message); 65 return false; 66 } 67 } 68 //JavaScript protection 69 if (window.wpsf_javascript_enabled) { 70 jQuery("<input>").attr("type", "hidden").attr("name", "wpsf_javascript").attr("value", "WPSF_JAVASCRIPT_TOKEN").appendTo('#commentform, #setupform, #registerform'); 71 } 72 73 return true; 74}
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.