1 2var jcbfPostcodeLookupLib = function () { 3 4 var myInput; 5 var myOutput; 6 var txtCompany; 7 var txtAddress1; 8 var txtAddress2; 9 var txtAddress3; 10 var txtAddress4; 11 var panAddress; 12 13 function populateFields(id) { 14 PopulateAddressFields(id); 15 } 16 17 function doLookup(list, postcode, company, add1, add2, add3, add4, pan) { 18 myInput = postcode; 19 myOutput = document.getElementById(list); 20 txtCompany = company; 21 txtAddress1 = add1; 22 txtAddress2 = add2; 23 txtAddress3 = add3; 24 txtAddress4 = add4; 25 panAddress = document.getElementById(pan); 26 27 GetAddressesFromPostcode(myInput.value); 28 } 29 30 function GetAddressesFromPostcode(postcode) { 31 32 //var postcode = ""; 33 //postcode = myInput.value; 34 35 //var surl = @Microsoft.AspNet.FriendlyUrls.FriendlyUrl.Resolve(" / SiteService.aspx / getpostcodeaddress"); 36 var surl = "/SiteService.aspx/getpostcodeaddress"; 37 38 if (postcode !== "") { 39 40 $.ajax({
41 type: 'POST', 42 url: surl, 43 data: "{'postcode':'" + postcode + "'}", 44 contentType: "application/json; charset=utf-8", 45 dataType: "json", 46 success: OnPostcodeSuccess, 47 failure: function (response) { 48 console.log(response.d); 49 }, 50 //call on ajax call failure 51 error: function (xhr, textStatus, error) { 52 console.log(error); 53 console.log(textStatus); 54 console.log(xhr); 55 } 56 57 }); 58 59 function OnPostcodeSuccess(data) { 60 var d = JSON.parse(data.d); 61 var HTML = "" 62 var Count = 0 63 var TempAddressID = 0 64 65 d.forEach(function (d) { 66 TempAddressID = d.AddressIDNewAPI; 67 HTML += "<p class='p-0 m-0'><a class='btn jcbfPostAdd' id='" + d.AddressIDNewAPI + "'>" + d.Description + "<a/></p>" 68 Count += 1; 69 70 }); 71 72 if (Count == 0) { 73 $(myOutput).html("<p class='p-0 m-0'><i class='small black'>No addresses found for this postcode. Please enter a full postcode and try again.</i></p>"); 74 $(myOutput).attr("style", "display:block;max-height:200px;overflow-y:scroll;border:1px dashed gray;background-color:white;"); 75 } 76 else { 77 $(myOutput).html(HTML); 78 $(myOutput).attr("style", "display:block;max-height:200px;overflow-y:scroll;border:1px dashed gray;background-color:white;"); 79 } 80 81 var elAddress = document.getElementsByClassName('jcbfPostAdd') 82 Array.from(elAddress).forEach(function (element) { 83 element.addEventListener('click', function (e) { 84 jcbfPostcodeLookupLib.populateFields(element.i
84d) 85 }) 86 }); 87 }; 88 } 89 } 90 91 function PopulateAddressFields(addID) { 92 93 var surl = "/SiteService.aspx/getdetailedaddress"; 94 95 $.ajax({ 96 type: "POST", 97 url: surl, 98 data: "{'AddressID':'" + addID + "'}", 99 contentType: "application/json; charset=utf-8", 100 dataType: "json", 101 success: OnSuccess, 102 failure: function (response) { 103 console.log(response.d); 104 }, 105 error: function (xhr, textStatus, error) { 106 console.log(error); 107 console.log(textStatus); 108 console.log(xhr); 109 } 110 }); 111 112 function OnSuccess(data) { 113 PopulateAddressValues(data); 114 }; 115 116 $(myOutput).html(""); 117 $(myOutput).attr("style", "display:none"); 118 } 119 120 function PopulateAddressValues(data) { 121 var d = JSON.parse(data.d); 122 123 if (d.OrganisationName != "") { 124 txtCompany.value = checknull(d.OrganisationName); 125 } 126 txtAddress1.value = checknull(d.Add1); 127 txtAddress2.value = checknull(d.Add2); 128 txtAddress3.value = checknull(d.Town); 129 txtAddress4.value = checknull(d.County); 130 131 $(panAddress).attr("style", "display:block"); 132 133 } 134 135 function checknull(value) { 136 return (value === null) ? " " : value; 137 }; 138 139 return { 140 doLookup: doLookup, 141 populateFields: populateFields 142 }; 143}(); 144 145 146 147var jcbfPostcodeSalesPerson = function () { 148 var x = document.getElementById("form-content"); 149 var testlat; 150 var testlng; 151 152 function getLocation() { 153 if (navigator.geolocation) { 154 navigator.geolocation.getCurrentPosition(showPosition, showError); 155 } 156 else { 157 x.innerHTML = "Geolocation is not supported by this browser."; 158 } 159 } 160 161 function showError(error) { 162 switch (error.code) { 163 case error.PERMISSION_DENIED: 164 x.innerHTML = "Please enable geolocation services from your browser." 165 break; 166 case error.POSITION_UNAVAILABLE: 167 x.innerHTML = "Location information is unavailable." 168 break; 169 case error.TIMEOUT: 170 x.innerHTML = "The request to get user location timed out." 171 break; 172 case error.UNKNOWN_ERROR: 173 x.innerHTML = "An unknown error occurred." 174 break; 175 } 176 } 177 178 function showPosition(position) { 179 testlat = position.coords.latitude; 180 testlng = position.coords.longitude; 181 182 submitForm(); 183 } 184 185 function submitForm() { 186 var model = new Object(); 187 model.mylat = testlat; 188 model.mylng = testlng; 189 190 var myUrl = '@Url.Action("UseMyLocation", "Home")'; 191 192 jQuery.ajax({ 193 type: "POST", 194 url: myUrl, 195 dataType: "html", 196 contentType: "application/json; charset=utf-8", 197 data: JSON.stringify({ coords: model }), 198 success: function (data) { 199 x.innerHTML = data; 200 }, 201 failure: function (errMsg) { 202 } 203 }); 204 } 205 206 return { 207 getLocation: getLocation 208 }; 209}(); 210
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.