1var dsidx_w = {}; 2 3dsidx_w.searchWidget = (function () { 4 var $ = jQuery; 5 6 $('.dsidx-resp-search-form').submit(function () { 7 var searchBox = $(this).find('.dsidx-search-omnibox-autocomplete'); 8 9 if (searchBox.length > 0) { 10 var searchValue = searchBox.val(); 11 12 // Removing wildcards in search keyword coming from consumer, if found 13 searchValue = searchValue.replace(/%/g, ''); 14 15 searchValue = $.trim(searchValue); 16 17 if(searchValue) { 18 // Adding standard wildcards with search keyword to find possible matches 19 searchValue = '%' + searchValue + '%'; 20 21 // The search keyword is modified and the updated value is passed via hidden field 22 // Otherwise the wildcards will be shown on location input field, although the consumer has not provided 23 var input = $('<input>', {type: 'hidden', name: searchBox.attr('name'), value: searchValue}); 24 input.appendTo(this) 25 26 // Removing name attribute from location input field to avoid duplicate input values 27 searchBox.removeAttr('name'); 28 } 29 30 // Removing name attribute from location input fields which are somehow empty 31 $(this).find('input[name*="idx-q-Locations"]').filter(function() { 32 return !this.value; 33 }).removeAttr('name'); 34 } 35 }); 36
37 $('.dsidx-resp-search-box .dsidx-resp-search-form #dsidx-resp-search-box-type').select2({ placeholder: "Any" }); 38 39 $('.dsidx-resp-search-box .dsidx-resp-search-form #dsidx-resp-search-box-type').change(function () { 40 var input_html = ''; 41 $.each($(this).val(), function (i, val) { 42 input_html += '<input type="hidden" name="idx-q-PropertyTypes<' + i + '>" value="' + val + '" />'; 43 }); 44 $(this).parents('.dsidx-resp-search-form').find('.dsidx-search-type-hidden-inputs').html(input_html); 45 }); 46 47 $('.dsidx-resp-search-box .dsidx-resp-search-form #dsidx-resp-search-box-type').change(); 48 49 $('.dsidx-resp-search-box .dsidx-resp-search-form #idx-q-Cities').select2({ placeholder: "Any" }); 50 51 $('.dsidx-resp-search-box .dsidx-resp-search-form #idx-q-Cities').change(function () { 52 var input_html = ''; 53 $.each($(this).val(), function (i, val) { 54 input_html += '<input type="hidden" name="idx-q-Cities<' + i + '>" value="' + val + '" />'; 55 }); 56 $(this).parents('.dsidx-resp-search-form').find('.dsidx-search-city-hidden-inputs').html(input_html); 57 }); 58 59 $('.dsidx-resp-search-box .dsidx-resp-search-form #idx-q-Cities').change(); 60 61 $('.dsidx-resp-search-box .dsidx-resp-search-form #idx-q-Communities').select2({ placeholder: "Any" }); 62
63 $('.dsidx-resp-search-box .dsidx-resp-search-form #idx-q-Communities').change(function () { 64 var input_html = ''; 65 $.each($(this).val(), function (i, val) { 66 input_html += '<input type="hidden" name="idx-q-Communities<' + i + '>" value="' + val + '" />'; 67 }); 68 $(this).parents('.dsidx-resp-search-form').find('.dsidx-search-community-hidden-inputs').html(input_html); 69 }); 70 71 $('.dsidx-resp-search-box .dsidx-resp-search-form #idx-q-Communities').change(); 72 73 $('.dsidx-resp-search-box .dsidx-resp-search-form #idx-q-TractIdentifiers').select2({ placeholder: "Any" }); 74 75 $('.dsidx-resp-search-box .dsidx-resp-search-form #idx-q-TractIdentifiers').change(function () { 76 var input_html = ''; 77 $.each($(this).val(), function (i, val) { 78 input_html += '<input type="hidden" name="idx-q-TractIdentifiers<' + i + '>" value="' + val + '" />'; 79 }); 80 $(this).parents('.dsidx-resp-search-form').find('.dsidx-search-tract-hidden-inputs').html(input_html); 81 }); 82 83 $('.dsidx-resp-search-box .dsidx-resp-search-form #idx-q-TractIdentifiers').change(); 84 85 $('.dsidx-resp-search-box .dsidx-resp-search-form #idx-q-ZipCodes').select2({ placeholder: "Any" }); 86
87 $('.dsidx-resp-search-box .dsidx-resp-search-form #idx-q-ZipCodes').change(function () { 88 var input_html = ''; 89 $.each($(this).val(), function (i, val) { 90 input_html += '<input type="hidden" name="idx-q-ZipCodes<' + i + '>" value="' + val + '" />'; 91 }); 92 $(this).parents('.dsidx-resp-search-form').find('.dsidx-search-zip-hidden-inputs').html(input_html); 93 }); 94 95 $('.dsidx-resp-search-box .dsidx-resp-search-form #idx-q-ZipCodes').change(); 96 97 $('.dsidx-resp-search-box .dsidx-resp-search-form #dsidx-resp-quick-search-box-type').select2({ placeholder: "Any" }); 98 $('.dsidx-resp-search-box .dsidx-resp-search-form #dsidx-resp-quick-search-box-type').change(function () { 99 var input_html = ''; 100 $.each($(this).val(), function (i, val) { 101 input_html += '<input type="hidden" name="idx-q-PropertyTypes<' + i + '>" value="' + val + '" />'; 102 }); 103 $(this).parents('.dsidx-resp-search-form').find('.dsidx-quick-search-type-hidden-inputs').html(input_html); 104 }); 105 $('.dsidx-resp-search-box .dsidx-resp-search-form #dsidx-resp-quick-search-box-type').change(); 106
107 $('.dsidx-resp-search-box-modern-view .dsidx-resp-search-form #dsidx-resp-quick-search-box-type').select2({ placeholder: "All Types" }); 108 $('.dsidx-resp-search-box-modern-view .dsidx-resp-search-form #dsidx-resp-quick-search-box-type').change(function () { 109 var input_html = ''; 110 $.each($(this).val(), function (i, val) { 111 input_html += '<input type="hidden" name="idx-q-PropertyTypes<' + i + '>" value="' + val + '" />'; 112 }); 113 $(this).parents('.dsidx-resp-search-form').find('.dsidx-quick-search-type-hidden-inputs').html(input_html); 114 }); 115 $('.dsidx-resp-search-box-modern-view .dsidx-resp-search-form #dsidx-resp-quick-search-box-type').change(); 116 117 $('.dsidx-resp-search-box-modern-view .dsidx-resp-search-form #dsidx-resp-quick-search-box-status').select2({ placeholder: "All Statuses" }); 118 $('.dsidx-resp-search-box-modern-view .dsidx-resp-search-form #dsidx-resp-quick-search-box-status').change(function () { 119 var statusEnumHash = 0; 120 $(this).find('option:selected').each(function () { 121 statusEnumHash += parseInt($(this).val()); 122 }); 123 $(this).siblings('#dsidx-quick-search-status-hidden').val(statusEnumHash); 124 }); 125 $('.dsidx-resp-search-box-modern-view .dsidx-resp-search-form #dsidx-resp-quick-search-box-status').change(); 126
127 $('.dsidx-resp-search-box-simple-view .dsidx-resp-search-form #dsidx-resp-quick-search-box-type').select2({ placeholder: "All Types" }); 128 $('.dsidx-resp-search-box-simple-view .dsidx-resp-search-form .custom-control-input').change(function () { 129 if($(this).prop("checked") == true){ 130 $(this).closest('.dsidx-resp-search-form').find('.dsidx-simple-search-expanded').show(); 131 } 132 else if($(this).prop("checked") == false){ 133 $(this).closest('.dsidx-resp-search-form').find('.dsidx-simple-search-expanded').hide(); 134 } 135 }); 136 $('.dsidx-resp-search-box-simple-view .dsidx-resp-search-form .custom-control-input').change(); 137 138 $('.dsidx-shortcode-registration-main #dsidx-shortcode-register-consent').click(function () { 139 var registrationPanel = $($(this).closest('.dsidx-shortcode-registration-main')[0]); 140 if (registrationPanel.find('#dsidx-shortcode-register-consent').is(":checked")) { 141 registrationPanel.find('.dsidx-shortcode-registration-dialog-message').hide().html(''); 142 registrationPanel.find('.dsidx-loginBtn').attr("disabled", false); 143 registrationPanel.find('#dsidx-shortcode-registration-submit').attr("disabled", false); 144 } else { 145 registrationPanel.find('.dsidx-shortcode-registration-dialog-message').show().html('Please check the \'Data Privacy Policy\' box if you consent and wish to continue'); 146 registrationPanel.find('.dsidx-loginBtn').attr("disabled", true); 147 registrationPanel.find('#dsidx-shortcode-registration-submit').attr("disabled", true); 148 } 149 }); 150 151 $('#dsidx-shortcode-registration form').submit(function () { 152 var formId = this.id; 153 function throwError(validationMessage) { 154 if (validationMessage) { 155 $("#"+formId).find('.dsidx-shortcode-registration-dialog-message').show().html(validationMessage); 156 return false; 157 } 158 } 159 var emailPattern = new RegExp(/^(("[\w-+\s]+")|([\w-+]+(?:\.[\w-+]+)*)|("[\w-+\s]+")([\w-+]+(?:\.[\w-+]+)*))(@((?:[\w-+]+\.)*\w[\w-+]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][\d]\.|1[\d]{2}\.|[\d]{1,2}\.))((25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\.){2}(25[0-5]|2[0-4][\d]|1[\d]{2}|[\d]{1,2})\]?$)/i); 160 var validationMessage = ""; 161 var redirectTo = $("#"+formId).find("#dsidx-shortcode-registration-redirectURL").val(); 162 var dialogMessage = $("#"+formId).find('.dsidx-shortcode-registration-dialog-message'); 163 164 if (!$("#"+formId).find('#dsidx-shortcode-registration-first-name').val() || !$("#"+formId).find('#dsidx-shortcode-registration-last-name').val()) 165 return throwError("First and last name are required."); 166 167 if (!emailPattern.test($("#"+formId).find('#dsidx-shortcode-registration-email').val())) 168 return throwError("You must use a valid email."); 169 170 var phoneVal = $("#"+formId).find('#dsidx-shortcode-registration-phone-number').val().replace(/\D/g, ''); 171 if (phoneVal[0] == 1) phoneVal = phoneVal.substr(1); 172 if (phoneVal.length >= 10 && phoneVal.length <= 15) { 173 if (phoneVal[0] == '0' || phoneVal[0] == '1' || phoneVal[1] == '9' || phoneVal.substr(0, 3) == '555' || phoneVal[3] == '0' || phoneVal[3] == '1') { 174 return throwError("Phone number is not valid"); 175 } 176 } else { 177 if (typeof (dsIdxRequirePhone) != 'undefined') { 178 return throwError("Phone number is not valid"); 179 } 180 } 181 182 if (!$("#"+formId).find('#dsidx-shortcode-registration-password').val() || !$("#"+formId).find('#dsidx-shortcode-registration-confirm-password').val()) 183 return throwError("Password is required."); 184 185 if (!$("#"+formId).find('#dsidx-shortcode-registration-password').val() || $("#"+formId).find('#dsidx-shortcode-registration-password').val() != $("#"+formId).find('#dsidx-shortcode-registration-confirm-password').val()) 186 return throwError("Passwords do not match."); 187 188 $("#"+formId).find('.dsidx-shortcode-registration-dialog-message').hide(); 189 190 var ajaxUrl = dsidx.pluginUrl + 'client-assist.php?action=Register'; 191 if (dsidx.useWPAjax) { 192 ajaxUrl = dsidxAjaxHandler.ajaxurl + '?action=dsidx_client_assist&dsidx_action=Register'; 193 } 194 $("#"+formId).find('#dsidx-shortcode-registration-submit').prop('disabled', true); 195 $.ajax({
196 type: 'POST', 197 url: ajaxUrl, 198 data: $("#"+formId).serialize(), 199 dataType: 'json', 200 success: function (response) { 201 if (response.Success) { 202 dialogMessage.addClass("dsidx-shortcode-registration-dialog-message-success") 203 dialogMessage.removeClass("dsidx-shortcode-registration-dialog-message") 204 dialogMessage.show().html("Success"); 205 if(redirectTo.startsWith("http") || redirectTo.startsWith("//")) 206 redirectTo = redirectTo; 207 else 208 redirectTo ="http://"+redirectTo; 209 210 var regURL = /^(http[s]?:\/\/){0,1}(www\.){0,1}[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,5}[\.]{0,1}/; 211 if(redirectTo && regURL.test(redirectTo)) { 212 window.location.href = redirectTo; 213 } 214 else { 215 window.location.reload(); 216 } 217 } else { 218 dialogMessage.show().html(response.Message); 219 } 220 }, 221 error: function(response){ 222 dialogMessage.show().html(response.Message); 223 }, 224 complete: function(){ 225 $("#"+formId).find('#dsidx-shortcode-registration-submit').val('Register'); 226 $("#"+formId).find('#dsidx-shortcode-registration-submit').prop('disabled', false); 227 } 228 }); 229 $("#"+formId).find('#dsidx-shortcode-registration-submit').val('Sending...'); 230 return false; 231 }); 232 function isLocationValid() { 233 // Deactivating the location validation for case 9360 234 // We will now accept no location fields and the - Any - value 235 // This file doesn't do anything now. 236 var valid = true; 237 $('.idx-q-Location-Filter :selected').each(function(index) { 238 if($(this).val().length) 239 valid = true; 240 }); 241 return valid; 242 } 243 244 function isFieldShown() { 245 var returnStr = ""; 246 $('.idx-q-Location-Filter').each( function() { 247 returnStr += $("label[for=" + $(this).attr('id') + "]").text() + ", "; 248 }); 249 return returnStr.substring(0, returnStr.length - 2); 250 } 251 252 function MLSExists() { 253 if ($('#idx-q-MlsNumbers').length > 0 && $('#idx-q-MlsNumbers').val().length > 0) 254 return true; 255 else 256 return false; 257 } 258 259 var returnObj = { 260 validate: function () { 261 if (!isLocationValid() && !MLSExists()) 262 { 263 $("#idx-search-invalid-msg").text("Please select at least one of the following fields: " + isFieldShown()).show(); 264 return false; 265 } 266 else 267 return true; 268 } 269 }; 270 271 return returnObj; 272})();
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.