// Include the CSS // document.write(" \ // \ //
\ // Signup to receive automatic listing alerts click here to get started \ //
"); document.write(" \ \ \ "); function openCloseFyeoOverlay() { el = document.getElementById("fyeo_overlay"); el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible"; } function fyeoSubmitForm() { var thank_you_message = "
\ Thank you for signing up to our automatic listing alerts. You will shortly receive a confirmation email. Please click the link inside this email to confirm your alert subscription. \
\ "; document.getElementById("fyeo_form_body").innerHTML = thank_you_message; } function activateMultiSelect() { jQuery('#property_type_4yio').multiselect({ columns: 1, placeholder: 'Select Property Type(s)', search: true, selectAll: true }); jQuery('#location_4yio').multiselect({ columns: 1, placeholder: 'Select Location(s)', search: true, selectAll: true }); jQuery('#property_type_rentals_4yio').multiselect({ columns: 1, placeholder: 'Select Property Type(s)', search: true, selectAll: true }); jQuery('#location_rentals_4yio').multiselect({ columns: 1, placeholder: 'Select Location(s)', search: true, selectAll: true }); } function switchInputs() { jQuery('.tab-content select').prop("disabled", true); jQuery('.tab-content.current select').prop("disabled", false); activateMultiSelect(); } function formToJson(form, token) { const formData = new FormData(form); const formValue = Object.fromEntries(formData); formValue.location = formData.getAll("location[]"); formValue.property_type = formData.getAll("property_type[]"); delete formValue["location[]"]; delete formValue["property_type[]"]; formValue.recaptchaToken = token; return JSON.stringify(formValue); } const errorMessageMap = new Map([ ["invalid-email", `Invalid email address.`], ["empty-email", `Email address cannot be empty.`], ["empty-phone", `Phone cannot be empty.`], ]); const combineValidationMessages = (validationMessages) => `Validation failed: ${validationMessages.join(" ")}`; function setupForm(formId) { jQuery(formId).off("submit"); // TODO: remove this once the double load of this file has been removed jQuery(formId).submit(function(event) { /* stop form from submitting normally */ event.preventDefault(); grecaptcha.ready(function() { grecaptcha.execute("6LepYCMqAAAAADz4QWAU_aBqxQk8xpmz1YaySVu1", { action: "submit" }).then(function(token) { jQuery.ajax({ url: "https://api.cbislands.com:3000/crm/3/listing-alerts/sign-up", type: "POST", crossDomain: true, cache: false, data: formToJson(event.target, token), dataType: "json", success: function (response) { console.log(response); if (response.status !== 'success') { if (response.errors == undefined || response.errors.length === 0) { return; } alert(combineValidationMessages(response.errors.map((error) => errorMessageMap.get(error)))); return; } const thank_you_message = "
\ Thank you for signing up to our automatic listing alerts. You will shortly receive a confirmation email. Please click the link inside this email to confirm your alert subscription. \
\ "; document.getElementById("fyeo_form_body").innerHTML = thank_you_message; }, error: function (xhr, status) { alert("error"); } }); }); }); }); } jQuery(document).ready(function(){ activateMultiSelect(); jQuery('.fyeo_form_body ul.tabs li').click(function(){ var tab_id = jQuery(this).attr('data-tab'); jQuery('ul.tabs li').removeClass('current'); jQuery('.tab-content').removeClass('current'); jQuery(this).addClass('current'); jQuery("#"+tab_id).addClass('current'); switchInputs(jQuery(this)); console.log(jQuery(this)); var listingTypeVal = jQuery("#"+tab_id).attr("data-listingtype"); jQuery("input[name='listing_type']").val(listingTypeVal); }); setupForm("#form_4yio_sales"); setupForm("#form_4yio_rentals"); }); function closeFyeoOverlay() { el = document.getElementById("fyeo_overlay"); el.style.visibility = 'hidden'; } function validatePhone(inputtxt) { var phoneno = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/; if(inputtxt.value.match(phoneno)) { return true; } else { alert("Not a valid Phone Number"); return false; } } var popup_html = "
\ \
×
\
\
\
\

Signup below to get up to the minute property alerts.

\

Gain valuable market insight by being among the first to know when your perfect home comes onto the market or prices change.

\
\ \
\
\

Signup below to receive our latest sales listings.

\
\ Name \
\
\ \
\
\ Email* \
\
\ \
\
\ Phone \
\
\ \
\
\ Property Type \
\
\ \
\
\ Location \
\
\ \
\
\ Min. Price \
\
\ \
\
\ Max. Price \
\
\ \
\
\ Min. Beds \
\
\ \
\
\ Min. Baths \
\
\ \
\
\ \
\ \ \ \ \ \
\
\ \ \ \ \
\
\

Signup below to receive our latest rental listings.

\
\ Name \
\
\ \
\
\ Email* \
\
\ \
\
\ Phone \
\
\ \
\
\ Property Type \
\
\ \
\
\ Location \
\
\ \
\
\ Min. Price \
\
\ \
\
\ Max. Price \
\
\ \
\
\ Min. Beds \
\
\ \
\
\ Min. Baths \
\
\ \
\ \ \ \ \ \
\
\
\ "; document.getElementById("fyeo_popup").innerHTML = popup_html; document.getElementById("fyeo_overlay").addEventListener("click", closeFyeoOverlay());