1/* ----------------------------------------------------------------------------------------- */ 2/* Addresses ------------------------------------------------------------------------------- */ 3/* ----------------------------------------------------------------------------------------- */ 4function initialize() { 5 var input = document.getElementById('address'); 6 var options = {}; 7 var autocomplete = new google.maps.places.Autocomplete(input,options); 8 google.maps.event.addListener(autocomplete, 'place_changed', function() { 9 newInfo = $("#address").val(); 10 json_str = ''; 11 12 error = ''; 13 if(newInfo=='') error += 'You must enter a valid address.'; 14 15 if(error) { 16 showAlert(error,"bad"); 17 } 18 else { 19 var place = autocomplete.getPlace(); 20 21 // Check if place is valid 22 if (!place.geometry || !place.geometry.location) { 23 showAlert('You must enter a valid address.','bad'); 24 25 } else { 26 var address_arr = {}; 27 if(typeof place.name !== 'undefined') address_arr.name = place.name; 28 if(typeof place.geometry !== 'undefined') { 29 address_arr.latitude=new String(place.geometry.location.lat()); 30 address_arr.longitude=new String(place.geometry.location.lng()); 31 } 32 $(place.address_components).each(function() { 33 switch(this.types[0]) { 34 case 'street_number': 35 address_arr.address1=this.short_name; 36 break; 37 case 'route': 38 address_arr.address1=(address_arr.address1?address_arr.address1+' ':'')+this.short_name; 39 break; 40 default: 41 case 'locality': 42 if(!address_arr.city || this.types[0]=='locality') address_arr.city=this.long_name; 43 break; 44 case 'administrative_area_level_1': 45 address_arr.state=(this.short_name?this.short_name:this.long_name); 46 address_arr.longstate=this.long_name; 47 break; 48 case 'country': 49 address_arr.country=(this.short_name?this.short_name:this.long_name); 50 break; 51 case 'postal_code': 52 address_arr.zip=(this.short_name?this.short_name:this.long_name); 53 break; 54 } 55 }); 56 } 57 58 if($('#latitude').length) $('#latitude').val(address_arr.latitude); 59 if($('#longitude').length) $('#longitude').val(address_arr.longitude); 60 61 do_data_update(address_arr,json_str); 62 } 63 }); 64} 65 66function do_data_update(address_arr,json_str) { 67 json_str = JSON.stringify(address_arr).replace(/"/g,"'"); 68 69 $("#hidden_address").val(json_str); 70 $("#hidden_address").trigger("address-updated"); 71 72 var x = 0; 73 $("#address-list .address-info-wrap").each(function() { 74 $(this).find(".address_info").attr("name","addresses["+x+"][addr]"); 75 $(this).find(".primary_address_select").attr("name","addresses["+x+"][primary]").attr("id","primary-address-"+x).prev("label").attr("for","primary-address-"+x); 76 x++; 77 }); 78} 79 80google.maps.event.addDomListener(window, 'load', initialize); 81 82$("#address").keydown(function(e) { 83 if(e.keyCode=='13') { 84 return false; 85 e.preventDefault(); 86 } 87});
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.