1var Essex_Florist_Frontend = {Models: {}, Collections: {}, Views: {}} 2jQuery(function() { 3 4 Essex_Florist_Frontend.Views.App = Backbone.View.extend({ 5 el: "body", 6 initialize: function() { 7 _.bindAll(this,'render'); 8 jQuery('#wc_checkout_add_ons_5').datepicker({}) 9 }, 10 render: function(e){ 11 }, 12 events: { 13 'change.select2 #wc_checkout_add_ons select' : 'populate_shipping_address', 14 15 }, 16 populate_shipping_address: function(e){ 17 var _this = this; 18 var target = jQuery(e.currentTarget); 19 var storable_location = {address_name: '', address: '', city: '', state: '', zipcode: ''}; 20 21 if(jQuery('option:selected', jQuery(target)).text() != ''){ 22 23 24 var address_info = jQuery('option:selected', jQuery(target)).text().split(',') 25 26 //console.log(address_info); 27 if(address_info.length > 0){ 28 29 storable_location.address_name = address_info[0].trim(); 30 storable_location.address = address_info[1].trim(); 31 storable_location.zipcode = (address_info[2]) ? address_info[2].trim() : address_info[1].trim() ; 32 //empty out other selects 33 jQuery('#wc_checkout_add_ons select').each(function(e){ 34 35 if(jQuery(this).attr('id') != jQuery(target).attr('id')){ 36 jQuery(this).val(''); 37 } 38 }) 39 // 40 //get full address info 41 jQuery.ajax({ 42 cache: true, 43 type: 'POST', 44 async: false, 45 url: 'https://maps.googleapis.com/maps/api/geocode/json?address=' + storable_location.address + ' ' + storable_location.zipcode + '&key=AIzaSyAcjNuhvmebdqLF8I5xsmRRjDvdfDV5Sqg', 46 dataType: 'json', 47 error: function(msg) {}, 48 success: function(data) { 49 if(data.status == 'OK'){ 50 //console.log(data); 51 var results = data.results; 52 53 for (var ac = 0; ac < results[0].address_components.length; ac++) { 54 var component = results[0].address_components[ac]; 55 56 switch(component.types[0]) { 57 case 'locality': 58 storable_location.city = component.long_name; 59 break; 60 case 'administrative_area_level_1': 61 storable_location.state = component.short_name; 62 break; 63 case 'country': 64 storable_location.country = component.long_name; 65 storable_location.registered_country_iso_code = component.short_name; 66 break; 67 } 68 }; 69 //console.log(storable_location); 70 var full_address = data.results[0].formatted_address.split(','); 71 //console.log(full_address) 72 _this.update_shipping_address(storable_location); 73 } 74 } 75 }) 76 77 } 78 }else{ 79 _this.update_shipping_address(storable_location); 80 } 81 }, 82 update_shipping_address: function(full_address){ 83 //console.log(full_address); 84 jQuery('#shipping_company').val(full_address.address_name); 85 jQuery('#shipping_address_1').val(full_address.address); 86 jQuery('#shipping_city').val(full_address.city); 87 jQuery('#shipping_state').select2('val', full_address.state); 88 jQuery('#shipping_postcode').val(full_address.zipcode); 89 90 } 91 92 93 }); 94 95 var App = new Essex_Florist_Frontend.Views.App(); 96});
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.