1var incomCaptcha = (function ($) { 2 // Hold Reference to all forms for debugging. 3 var forms = []; 4 // On Load Store each form in forms and add appropriate listeners 5 $(document).ready(function(){ 6 // For each form Add form into forms array 7 $('form.incom-js').each(function(index){ 8 $(this).data('index',index); 9 var form = { 10 timestamp: 0, 11 el: $(this), 12 isModified: false, 13 handler: '', 14 formID: $(this).attr('id'), 15 index: index 16 }; 17 forms.push(form); // Push reference into forms for debugging 18 bindUserAction(form); // Bind user actions for tracking first interaction 19 form.handler = form.el.submit(function(e) { 20 // Prevent Submission untill timestamp is added 21 if(!form.el.data('validator')){ 22 form.el.find('input[type="submit"]').attr('disabled','disabled'); 23 getIntervalAndSubmit(e,form, ''); 24 } else { 25 form.handler = ''; 26 } 27 }); 28 }); 29 }); 30 31 32 // Bind change event to all elements of the form and then update timestamp for particular form. 33 function bindUserAction(form){ 34 var el = form.el.find('input[name="edit[form_firsttm]"]'); 35 var firsttime = el.val(); 36 form.el.find('input, textarea, select').each(function(){ 37 $(this).change(function(){ 38 if(form.isModified || (firsttime != '0')){ 39 return; 40 } 41 // If form has not been modified yet, set modified to true and set up form timestamp 42 form.isModified = true; 43 form.timestamp = Date.now(); 44 el.attr('value', form.timestamp); 45 }) 46 }) 47 }; 48 49 // Function to set the interval into the input element 50 function getIntervalAndSubmit(event,form,callback) { 51 event.preventDefault(); // Prevent Default event find fime input and add interval and hmac 52 var el = form.el.find('input[name="edit[form_tm]"]'); 53 var firsttime = form.el.find('input[name="edit[form_firsttm]"]').val(); 54 var endtime = Date.now(); 55 $.get('/incomCaptcha/generateHmac/'+ Math.round(endtime / 1000), function(data){ 56 var jsToken = data; 57 var interval = Math.floor((endtime - firsttime) / 1000); 58 el.attr('value', jsToken + '|' + interval); 59 if(form.handler != ''){ 60 form.el.unbind('submit').submit(); 61 } else{ 62 form.el.find('input[type="submit"]').attr('disabled','disabled'); 63 } 64 if(typeof(callback) === 'function'){ 65 callback(); 66 } 67 }) 68 }; 69 70 // Utility function to get form from form object by ID 71 function getFormByID(formID,index){ 72 return forms.find(function(form){ 73 return (form.formID === formID && index === form.index) 74 }) 75 } 76 // Return In object 77 return { 78 getIntervalAndSubmit:getIntervalAndSubmit, 79 getFormByID:getFormByID, 80 forms:forms // comment this variable once no longer debugging to expose less. 81 } 82}(jQuery)); 83 84 85function sendPin(ff, em, resend){ 86 $.ajax({ 87 url: '/sendpinemail', 88 type: "POST", 89 data: ff.serialize()+ '&allemail='+em, 90 success: function(result){ 91 if(result){ 92 if (result.indexOf('Our mailing system') == -1){ 93 $('.wrapper-pin #edit-pin').attr('data-pin',result); 94 if (resend) {$('#pin_form #error_message span').replaceWith('<span>PIN successfully resent to '+em+'</span>'); $('#pin_form #error_message span').delay(3000).fadeOut('slow');} 95 }else{ 96 $('#pin_form #error_message span').replaceWith('<span>'+result+'</span>'); 97 } 98 } 99 }, 100 error:function (xhr, ajaxOptions, thrownError){ 101 alert(xhr.status); 102 alert(thrownError); 103 } 104 }); 105} 106 107function checkEmail(e,f){ 108 $.ajax({ 109 url: '/checkemail', 110 type: "POST", 111 data: "chemail="+e, 112 success: function(result){ 113 if(result.indexOf('email confirmed') == -1){ 114 sendPin(f, e, false); 115 $('.wrapper-pin').show("slow"); 116 } else{ 117 f.submit(); 118 } 119 }, 120 error:function (xhr, ajaxOptions, thrownError){ 121 alert(xhr.status); 122 alert(thrownError); 123 } 124 }); 125} 126 127 128function getCookie(cname) { 129 var name = cname + "="; 130 var decodedCookie = decodeURIComponent(document.cookie); 131 var ca = decodedCookie.split(';'); 132 for(var i = 0; i <ca.length; i++) { 133 var c = ca[i]; 134 while (c.charAt(0) == ' ') { 135 c = c.substring(1); 136 } 137 if (c.indexOf(name) == 0) { 138 return c.substring(name.length, c.length); 139 } 140 } 141 return ""; 142} 143 144 145function validatePhone(phn,em,f,chzip,zp,cn,fid) { 146 $.ajax({ 147 url: '/validatephone', 148 type: "POST", 149 data: "phonev="+phn+'&countr='+cn+'&def='+fid, 150 success: function(result) { 151 if(result.indexOf('phone confirmed') != -1){ 152 if (chzip) validateZip(zp,cn,em,f); else checkEmail(em,f); 153 } else{ 154 f.submit(); 155 } 156 }, 157 error:function (xhr, ajaxOptions, thrownError){ 158 alert(xhr.status); 159 alert(thrownError); 160 } 161 }); 162} 163 164 165function validateZip(zp,cn,em,f) { 166 $.ajax({ 167 url: '/validatezip', 168 type: "POST", 169 data: "zipv="+zp+'&countryv='+cn, 170 success: function(result) { 171 if(result.indexOf('zip confirmed') != -1){ 172 checkEmail(em,f); 173 } else{ 174 f.submit(); 175 } 176 }, 177 error:function (xhr, ajaxOptions, thrownError){ 178 alert(xhr.status); 179 alert(thrownError); 180 } 181 }); 182} 183 184/** 185 * 186 * @param fvalue - field value to verify format 187 * @param fType - field type to verify 188 * @returns return field is valid or not, in TRUE and FALSE 189 */ 190function IsFieldEntry(fvalue, $fType = '') { 191 var regex = ''; 192 if($fType!=''){ 193 if($fType == 'email'){ 194 regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/; 195 } 196 if($fType == 'phonenumber'){ 197 regex = /^\s*(?:\+?(\d{1,3}))?[-. (]*(\d{3})[-. )]*(\d{3})[-. ]*(\d{4})(?: *x(\d+))?\s*$/; 198 } 199 if (!regex.test(fvalue)) { 200 return false;
201 } 202 else { 203 return true; 204 } 205 } 206 return true; 207} 208 209 210$(document).ready(function(){ 211 212var widgetId =''; 213var formId; 214var emailF=''; 215var precondo=''; 216 217 218if ($('#pin_form').length>0){ 219 220 $('.pin-js input[type="submit"]').on("click",function(){ 221 var form = $(this).parents('.pin-js'); 222 var nameF=''; 223 var term = true; 224 var dailyselect = true; 225 var phoneempty = false; 226 var phoneF = form.find('#edit-phone'); 227 var checkF = form.find('#edit-consent-terms'); 228 var checkphone = false; 229 var checkzip = false; 230 var checkCommon = true; 231 var zip=''; 232 var country = 'CANADA'; 233 var fd=''; 234 var invalidF = false; // invalid field 235 236 if(!checkF[0].checked){ 237 return; 238 } 239 formId = form.find('input[name="edit[form_id]"]').val(); 240 241 switch (formId){ 242 case 'ask_questions_widget_form': 243 widgetId = $(this).parents('.widget').attr('id'); 244 nameF = form.find('#ask-question-fname').val(); 245 emailF = form.find('#ask-question-email').val(); 246 break; 247 case 'pre_construction_landing_form': 248 case 'properties_landing_form': 249 case 'power_of_sale_form': 250 case 'get_your_dream_commercial_property_form': 251 case 'commercial_property_evaluation_form': 252 nameF = form.find('#edit-fname').val(); 253 var eml = form.find('#edit-email'); 254 if (!eml.hasClass('error')){ 255 emailF = form.find('#edit-email').val(); 256 } 257 if (phoneF.hasClass('error')) phoneempty = true; 258 break; 259 case 'landing_email_alerts_form': 260 nameF = form.find('#edit-fname').val(); 261 var eml2 = form.find('#edit-email'); 262 if (!eml2.hasClass('error')){ 263 emailF = form.find('#edit-email').val(); 264 } 265 var type= form.find('#edit-home_type').find(":selected").text(); 266 var bed = form.find('#edit-bedroom').find(":selected").text(); 267 var bath = form.find('#edit-bathrooms').find(":selected").text(); 268 var drip = form.find('#edit-drip_group').find(":selected").text(); 269 if ((type == 'Type of home *') || (bed == 'Bedrooms *') || (bath == 'Bathrooms *') || (drip == 'Select Group *')){ 270 dailyselect = false; 271 } 272 term = form.find('#edit-terms_conditions').prop('checked'); 273 if (phoneF.hasClass('error')) phoneempty = true; 274 break; 275 case 'free_evaluation_form': 276 nameF = form.find('#edit-fname').val(); 277 emailF = form.find('#edit-email').val(); 278 phoneFV = phoneF.val(); 279 if (emailF && typeof emailF !== 'undefined' && IsFieldEntry(emailF,'email') == false) { 280 invalidF = true; // just making this true to stop submission 281 event.preventDefault(); 282 } 283 if(phoneFV && typeof phoneFV !== 'undefined' && IsFieldEntry(phoneFV,'phonenumber') == false){ 284 invalidF = true; // just making this true to stop submission 285 event.preventDefault(); 286 } 287 break; 288 case 'get_your_dream_home_form': 289 case 'get_neighbourhood_buzzer_form': 290 case 'distressed_sales_form_landing': 291 nameF = form.find('#edit-fname').val(); 292 emailF = form.find('#edit-email').val(); 293 term = form.find('#edit-consent-terms').prop('checked'); 294 break; 295 case 'contactSite_node_form': 296 nameF = form.find('#edit-name').val(); 297 if (nameF =='') nameF = ' '; 298 emailF = form.find('#edit-email').val(); 299 break; 300 case 'distressed_sales_node_form': 301 nameF = form.find('#edit-name').val(); 302 emailF = form.find('#edit-email').val(); 303 checkphone = true; 304 break; 305 case 'FreeReport-form': 306 nameF = form.find('#edit-fname').val(); 307 emailF = form.find('#edit-email').val(); 308 checkmarkReport = form.find('input[id*="edit-reportIDs"]:checked'); 309 if (checkmarkReport.length == 0) checkCommon = false;
310 break; 311 case 'sweepstakes_node_form': 312 nameF = form.find('#edit-first_name').val(); 313 emailF = form.find('#email').val(); 314 phoneF = form.find('#phone'); 315 var province = form.find('#edit-prov_state').find(":selected").text(); 316 var country = form.find('#edit-country').find(":selected").text(); 317 if (province == 'Select') { checkCommon = false; } 318 if (country == 'Other') { 319 if ($('#edit-otherProvState').val()==''){ 320 checkCommon = false; 321 } else { checkCommon = true;} 322 } 323 checkphone = true; 324 checkzip = true; 325 zip = form.find('#edit-zip_postal').val(); 326 country = form.find('#edit-country').find(":selected").text(); 327 break; 328 case 'contact_agent_form': 329 case 'contact_broker_form': 330 nameF = form.find('#edit-name').val(); 331 emailF = form.find('#edit-email').val(); 332 checkphone = true; 333 fd='contactform'; 334 break; 335 case 'pre_Construction_contact_form': 336 nameF = form.find('#edit-name').val(); 337 emailF = form.find('#edit-email').val(); 338 var areyou = form.find('#edit-areyou').find(":selected").text(); 339 if (areyou == 'Are You a Realtor or a Buyer?*') { checkCommon = false; } 340 if ($(this).val()=='GET ACCESS') precondo = 1; 341 if ($(this).val()=='GIVE ME A CALL') precondo = 2; 342 break; 343 default: 344 } 345 346 var dripgroupF = form.find('input[name="edit[drip_group]"]:checked'); 347 var dripgroupFAll = form.find('input[name="edit[drip_group]"]'); 348 var radioselected = true; 349 350 var mycookie = getCookie(emailF); 351 352 if (phoneF.hasClass('required') && (phoneF.val()=='')){ 353 phoneempty = true; 354 } 355 356 if (dripgroupF.length !== dripgroupFAll.length/4) { 357 radioselected = false; 358 } 359 if ((!invalidF) && (nameF!='') && (emailF!='') && (emailF!=undefined) && (radioselected) && (term) && (dailyselect) && (!phoneempty) && (checkCommon) && (mycookie.length==0)){ 360 event.preventDefault(); 361 $('.emailpin').text(emailF); 362 if (checkphone && (phoneF.val()!='')) { 363 validatePhone(phoneF.val(),emailF,form,checkzip,zip,country,fd); 364 } 365 if ((!checkphone) || ((checkphone) && (phoneF.val()==''))){ 366 checkEmail(emailF,form); 367 } 368 369 $('.wrapper-pin .close').on("click", function(){ 370 $('.wrapper-pin').hide("slow"); 371 }) 372 } 373 374 }); 375} 376 377 $('#pin_form input[type="submit"]').on("click",function(){ 378 var pinF=$('#pin_form #edit-pin').val(); 379 var formE; 380 var pinEmailF=$('#pin_form #edit-pin').attr('data-pin'); 381 382 if (widgetId != ''){ 383 formE = $('#'+widgetId).find('.pin-js'); 384 } else{ 385 formE = $('input[value="'+formId+'"]').parents('.pin-js'); 386 if ((formId == 'pre_Construction_contact_form') && (precondo!='')){ 387 switch (precondo){ 388 case 1: 389 formE = $('#precondo_banner_form #pre_Construction_contact_form'); 390 break; 391 case 2: 392 formE = $('#why-wait #pre_Construction_contact_form'); 393 break; 394 } 395 } 396 } 397 398 if (pinF!=''){ 399 event.preventDefault(); 400 $.ajax({ 401 url: '/verifypin', 402 type: "POST", 403 data: 'pin='+pinF+'&pinemail='+pinEmailF+'&email='+emailF, 404 success: function(result){ 405 if(result){ 406 if (result.indexOf('Incorrect PIN Code entered') == -1){ 407 formE.submit(); 408 } else{ 409 $('#pin_form #error_message span').replaceWith('<span>'+result+'</span>'); 410 } 411 } 412 }, 413 error:function (xhr, ajaxOptions, thrownError){ 414 alert(xhr.status); 415 alert(thrownError); 416 } 417 }); 418 } 419 }); 420 421 422 $('#pin_form .resend').on("click",function(){ 423 var formF; 424 425 if (widgetId != ''){ 426 formF = $('#'+widgetId).find('.pin-js'); 427 } else{ 428 formF=$('input[value="'+formId+'"]').parents('.pin-js'); 429 } 430 431 sendPin(formF, emailF, true); 432 }); 433 434 435});
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.