1document.addEventListener('DOMContentLoaded', function() { 2 var postalCode1Field = document.getElementById('address_zip1'); 3 var postalCode2Field = document.getElementById('address_zip2'); 4 var searchButton = document.getElementById('search-address-button'); 5 var prefectureField = document.getElementById('address_prefectures'); 6 var addressField = document.getElementById('address'); 7 8 if (postalCode1Field && postalCode2Field && searchButton) { 9 searchButton.addEventListener('click', function() { 10 var postalCode1 = postalCode1Field.value.replace(/[^0-9]/g, ''); 11 var postalCode2 = postalCode2Field.value.replace(/[^0-9]/g, ''); 12 if (postalCode1.length === 3 && postalCode2.length === 4) { 13 var postalCode = postalCode1 + postalCode2; 14 fetch('https://zipcloud.ibsnet.co.jp/api/search?zipcode=' + postalCode) 15 .then(response => response.json()) 16 .then(data => { 17 if (data.results) { 18 var result = data.results[0]; 19 prefectureField.value = result.address1; 20 addressField.value = result.address2 + result.address3; 21 } else { 22 alert('使ãè¦ã¤ããã¾ããã§ããã'); 23 } 24 }) 25 .catch(error => { 26 console.error('Error:', error); 27 alert('使æ¤ç´¢ã«å¤±æãã¾ããã'); 28 }); 29 } else { 30 alert('æ£ããéµä¾¿çªå·ãå ¥åãã¦ãã ããã'); 31 } 32 }); 33 } 34});
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.