1(function ($) { 2 let notDeliverPrompts = ''; //ä¸é éæç¤ºè¯,æç¤ºè¯å卿¶ä¸è½ä¸å 3 $('body').on('input keyup', '[name="phone4"], [name="phone2"]', debounce(function () { 4 let phone = $(this).val().trim(); 5 if (phone.length > 20) { 6 phone = phone.slice(0, 20); 7 } 8 if( phone.startsWith('48')) { 9 $('input[name="phone"]').val('+' + phone).trigger('blur').trigger('change'); 10 } else if (phone.startsWith('+48')) { 11 $('input[name="phone"]').val(phone).trigger('blur').trigger('change'); 12 } else { 13 $('input[name="phone"]').val('+48' + phone).trigger('blur').trigger('change'); 14 } 15 $('[name="phone4"], [name="phone2"]').val(phone); 16 }, 300)); 17 $('body').on('keyup', 'input[name="zip_code"]', function (e) { 18 if (e.keyCode == 8) { 19 $("input[name='city']").removeAttr('readonly'); 20 $("input[name='city']").val(''); 21 $('.address-linkage').hide(); 22 citySearch.val(''); // æ¸ ç©ºæç´¢æ¡ 23 return; 24 } 25 codeChange(); 26 }); 27 $('body').on('change', 'input[name="zip_code"]', function (e) { 28 codeChange(); 29 }); 30 $('body').on('change', 'input[name="city"]', async function (e) { 31 let city = $(this).val().trim(); 32 if (!city) { 33 notDeliverPrompts = ''; 34 return; 35 } 36 notDeliverPrompts = await checkNonDeliverableAddress(); 37 }); 38 39 var citySearch = $(`<input name="keywords" type="text" placeholder="${typeof keyWordsHint !== 'undefined' ? keyWordsHint : 'ProszÄ wprowadziÄ sÅowa kluczowe' }" class="city-search" style="height: 44px;border: 1px solid #eee; width: calc(100% - 20px);padding: 0 10px;margin: 10px;border-radius: 4px;"/>`); 40 var zipCode = null; 41 //é®ç¼æ ¼å¼å 42 function codeChange() { 43 let elem = $('input[name="zip_code"]'); 44 let code = elem.val().trim(); 45 if (code.length >= 2) { 46 code = code.replace(/\D/g, ''); 47 code = code.slice(0, 2) + '-' + code.slice(2, 5); 48 elem.val(code); 49 } 50 if ($("input[name='zip_code']").val().length == 6 && code !== zipCode) { 51 zipCode = code; 52 citySearch.val(''); 53 zipGetCity(code); 54 } 55 } 56 57 58 var isRender = false;
59 var addressLinkage = $('<ul class="address-linkage select-list" style="max-height:none;"/>'); 60 var searchBox = $('<div class="search-content" style="max-height: 240px;overflow-y: auto; width: 100%;"/>'); 61 addressLinkage.append(citySearch).append(searchBox); 62 var cityList = []; 63 64 $('body').on('click', '.city-box', function (e) { 65 if (cityList.length && !$(e.target).is('.address-linkage') && $(e.target).parents('.address-linkage').length <= 0) { 66 $('.address-linkage').show(); 67 } 68 }) 69 $('body').on('click', function (e) { 70 if (!$(e.target).is('.address-linkage,.city-box') && $(e.target).parents('.address-linkage, .city-box').length <= 0) { 71 $('.address-linkage').hide(); 72 } 73 }); 74 $('body').on('click', '.address-linkage li', function (e) { 75 var city = $(this).attr('data-name'); 76 $('input[name="city"]') 77 .val(city) 78 .trigger('blur') 79 .trigger('change') 80 81 if ($('input[name="city"]').closest('.form-group').length) { 82 $('input[name="city"]').closest('.form-group') 83 .addClass('form-group-label'); 84 } else { 85 $('input[name="city"]').closest('.field').addClass('field-label'); 86 } 87 $('.address-linkage').hide(); 88 citySearch.val(''); // æ¸ ç©ºæç´¢æ¡ 89 renderList(cityList); 90 }) 91 92 $('body').on('input', '.city-search', debounce(function(){ 93 var value = $(this).val().toLowerCase(); 94 var data = cityList.filter(c_item => c_item.toLowerCase().includes(value)); 95 renderList(data); 96 }, 300)) 97 var addressDetails = store.get('adddress_detail'); 98 99 // é®ç¼èå¨å¸ 100 function zipGetCity() { 101 $("input[name='city']").removeAttr('readonly'); 102 let param = { countryCode: 'PL', zip: $("input[name='zip_code']").val() }; 103 customerApi 104 .getMEXDistrictInfo(param) 105 .then(res => { 106 searchBox.html(''); 107 cityList = []; 108 if (res.city && res.city.length) { 109 if (res.city.length > 1) { 110 cityList = res.city; 111 renderList(cityList); 112 if (!isRender && typeof addressEcho !== 'undefined' && Number(addressEcho) && addressDetails && addressDetails.currencyId == currencyId && addressDetails.marketId == marketId && $("input[name='city']").val() === addressDetails.data.city) { 113 return; 114 } else { 115 $('input[name="city"]') 116 .val('') 117 .closest('.form-group') 118 .addClass('form-group-label'); 119 $('input[name="city"]').closest('.field').addClass('field-label'); 120 $('.address-linkage').show(); 121 } 122 123 } else { 124 $('input[name="city"]') 125 .val(res.city[0]) 126 .trigger('blur') 127 .trigger('change') 128 .closest('.form-group') 129 .addClass('form-group-label'); 130 $('input[name="city"]').closest('.field').addClass('field-label'); 131 } 132 $('input[name="city"]').attr('readonly', 'readonly').css('pointer-events', 'none') 133 } else { 134 $('input[name="city"]') 135 .val('') 136 .trigger('blur') 137 .trigger('change') 138 .removeAttr('readonly') 139 .css('pointer-events', 'auto') 140 .closest('.form-group') 141 .removeClass('form-group-label'); 142 $('input[name="city"]').closest('.field').removeClass('field-label'); 143 } 144 isRender = true; 145 }) 146 .catch(err => { 147 console.log(err); 148 notDeliverPrompts = ''; 149 $('input[name="city"]') 150 .val('') 151 .trigger('blur') 152 .trigger('change') 153 .removeAttr('readonly') 154 .css('pointer-events', 'auto') 155 .closest('.form-group') 156 .removeClass('form-group-label'); 157 $('input[name="city"]').closest('.field').removeClass('field-label'); 158 }); 159 } 160 function renderList(data) { 161 var tepl = ''; 162 data.forEach(c_item => { 163 tepl += `<li data-name="${c_item}">${c_item}</li>`; 164 }) 165 searchBox.html(tepl); 166 if (!$('.address-linkage.select-list').length) { 167 if ($('input[name="city"]').parents('.form-group').length) { 168 $('input[name="city"]').closest('.address-wrap').append(addressLinkage).css('position', 'relative').addClass('city-box'); 169 } else { 170 $('input[name="city"]').closest('.field').append(addressLinkage).css('position', 'relative').addClass('city-box') 171 } 172 } 173 174 } 175 // æ ¡éªä¸å¯æ´¾éå°å 176 window.checkNonDeliverableAddress = function () { 177 return new Promise(resolve => { 178 let zipCode = $("input[name='zip_code']").val(); 179 if (!zipCode) { 180 resolve(''); 181 return; 182 } 183 let param = { 184 countryCode: 'PL', 185 zip: zipCode, 186 city: $("input[name='city']").val() 187 }; 188 customerApi 189 .checkAddress(param) 190 .then(res => { 191 if (res) { 192 toast(res); 193 resolve(res); 194 } else { 195 resolve(''); 196 } 197 }) 198 .catch(err => { 199 console.log(err); 200 resolve(''); 201 }); 202 }); 203 }; 204 205 // åè¿å°åºä¸é ééªè¯ 206 window.blackTw = function () { 207 var phone = $("input[name='phone4']").val(); 208 var address = $("input[name='address']").val(); 209 var building = $("input[name='building']").val(); 210 var zipCode = $("input[name='zip_code']").val(); 211 if(!phone) { 212 toast(typeof nullPhone !== 'undefined' ? nullPhone : 'The phone number cannot be empty'); 213 return false;
214 } 215 if(!(/^(?=.*\d)(?!^\d+$).+$/.test(address))) { 216 toast(typeof errorAddress !== 'undefined' ? errorAddress : 'The street information format is incorrect'); 217 return false; 218 } 219 if(!$('input[name="street"]').length && !(/.*[0-9]{1,}.*/i.test(building))) { 220 toast(typeof errorBuilding !== 'undefined' ? errorAddress : 'The door number cannot be empty'); 221 return false; 222 } 223 if(!(/^[0-9]{2}-[0-9]{3}$/.test(zipCode))) { 224 toast(typeof errorCode !== 'undefined' ? errorCode : 'The postal code format is incorrect'); 225 return false; 226 } 227 228 if (notDeliverPrompts) { 229 toast(notDeliverPrompts); 230 $('[name="city"]').focus(); 231 } 232 return notDeliverPrompts === ''; 233 }; 234 if($('input[name="street"]').length) { 235 $('input[name="street"], input[name="building"]').on('input', debounce(function(){ 236 var street = $("input[name='street']").val(); 237 var building = $("input[name='building']").val(); 238 $("[name='address']").val(`${street}${building ? '/' + building : ''}`).trigger('blur').trigger('change'); 239 }, 300)) 240 } 241 function debounce(fn, delay) { 242 let timer = null; 243 return function () { 244 let that = this; 245 let args = arguments; 246 clearTimeout(timer); 247 timer = setTimeout(function () { 248 fn.apply(that, args) 249 }, delay) 250 } 251 } 252})(jQuery); 253 254// æäº¤è®¢ååå°åçç¹æ®å¤ç 255function beforeSubmitAddFn() { 256 if ($('input[name="building"]').length && !$('input[name="street"]').length) { 257 var building = $('[name="building"]').val(); 258 var address = $('[name="address"]').val(); 259 $('[name="address"]').val(address + building); 260 } 261}
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.