1function CapturePlus_Interactive_Find_v2_10Begin(search_postcode,type) { 2 3 var script = document.createElement("script"), 4 head = document.getElementsByTagName("head")[0], 5 url = "https://services.postcodeanywhere.co.uk/CapturePlus/Interactive/Find/v2.10/json3.ws?"; 6 7 // Build the query string 8 url += "&Key=" + encodeURIComponent("ZM86-FD72-XX89-UM26"); 9 url += "&SearchTerm=" + encodeURIComponent(search_postcode); 10 url += "&LastId=" + encodeURIComponent(''); 11 url += "&SearchFor=" + encodeURIComponent('PostalCodes'); 12 url += "&Country=" + encodeURIComponent('GBR'); 13 url += "&LanguagePreference=" + encodeURIComponent('EN'); 14 url += "&MaxSuggestions=" + encodeURIComponent(''); 15 url += "&MaxResults=" + encodeURIComponent(''); 16 17 if(type == 'CreditCard'){ 18 url += "&callback=displaycreditCardAddress"; 19 }else{ 20 url += "&callback=displayDeliveryAddress"; 21 } 22 23 script.src = url; 24 25 // Make the request 26 script.onload = script.onreadystatechange = function () { 27 if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") { 28 script.onload = script.onreadystatechange = null; 29 if (head && script.parentNode) 30 head.removeChild(script); 31 } 32 } 33 34 head.insertBefore(script, head.firstChild); 35} 36 37function displayDeliveryAddress(response) { 38 39 var b = document.getElementById("search_postcode").value; 40 var a = document.getElementById("del_address_select"); 41 var e = "del_address_select"; 42 var d = "deladdress_list_display"; 43 44 CapturePlus_Interactive_Find_v2_10End(response,a, b, d,e); 45}; 46 47function displaycreditCardAddress(response) { 48 49 var b = document.getElementById("search_postcode_cardholder").value; 50 var a = document.getElementById("cardholder_address_select"); 51 var e = "cardholder_address_select"; 52 var d = "cardholderaddress_list_display"; 53 54 CapturePlus_Interactive_Find_v2_10End(response,a, b, d,e); 55}; 56 57function CapturePlus_Interactive_Find_v2_10End(response,a,b,d,e) { 58 if (validPostCode(b) == false) { 59 confirmModal("The postcode you have entered does not appear to be a valid postcode. Would you like to continue with the search anyway?", function() { 60 CapturePlus_proceed(); 61 }); 62 } else { 63 CapturePlus_proceed(); 64 } 65 66 function CapturePlus_proceed() { 67 document.getElementById(e).disabled = true; 68 $("#" + d).show(); 69 70 for (var c = a.length; c >= 0; c--) { 71 if(a.options[c] && !a.options[c].dataset.persist) { 72 a.options[c] = null; 73 } 74 } 75 76 a.options.add(new Option("Searching for addresses...", "")); 77 78 if (response.Items.length == 1 && typeof(response.Items[0].Error) != "undefined") { 79 // Show the error message 80 } else { 81 // Check if there were any items found 82 for (var h = a.length; h >= 0; h--) { 83 if(a.options[h]) { 84 if(a.options[h].dataset.persist) { 85 a.options[h].selected = true; 86 } else { 87 a.options[h] = null; 88 } 89 } 90 } 91 92 if (response.Items.length == 0){ 93 a.options.add(new Option("Sorry, there were no results", "")) 94 alertModal("Sorry, there were no results"); 95 } else { 96 for (var h = 0; h < response.Items.length; h++) { 97 var result = response.Items[h].Text ; 98 99 a.options.add(new Option(result, response.Items[h].Id)) 100 document.getElementById(e).disabled = false 101 } 102 } 103 } 104 } 105}; 106 107function CapturePlus_Interactive_Retrieve_v2_10Begin(response,a,type) { 108 109 var script = document.createElement("script"), 110 head = document.getElementsByTagName("head")[0], 111 url = "https://services.postcodeanywhere.co.uk/CapturePlus/Interactive/Retrieve/v2.10/json3.ws?"; 112 113 // // Build the query string 114 url += "&Key=" + encodeURIComponent("ZM86-FD72-XX89-UM26"); 115 116 var h = a.selectedIndex; 117 var j = a.options[h].value; 118 119 url += "&Id=" + encodeURIComponent(j); 120 121 if(type == 'CreditCard'){ 122 url += "&callback=creditCardAddress"; 123 }else{ 124 url += "&callback=deliveryAddress"; 125 } 126 127 script.src = url; 128 129 // Make the request 130 script.onload = script.onreadystatechange = function () { 131 if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete") { 132 script.onload = script.onreadystatechange = null; 133 if (head && script.parentNode) 134 head.removeChild(script); 135 } 136 } 137 138 head.insertBefore(script, head.firstChild); 139}; 140 141/// used to display selected delivery address 142function deliveryAddress(response) { 143 144 var fields = ['delivery_address1','delivery_address2','delivery_address3','delivery_address4','delivery_postcode']; 145 var list = "deladdress_list_display"; 146 CapturePlus_Interactive_Retrieve_v2_10End(response, fields, list); 147}; 148 149/// used to display selected credit card address
150function creditCardAddress(response) { 151 152 var fields = ['cardholder_address1', 'cardholder_address2','cardholder_address3','cardholder_address4','cardholder_postcode']; 153 var list = "cardholderaddress_list_display"; 154 CapturePlus_Interactive_Retrieve_v2_10End(response, fields, list); 155}; 156 157function CapturePlus_Interactive_Retrieve_v2_10End(response, fields, list) { 158 if (response.Items.length == 1 && typeof(response.Items[0].Error) != "undefined") { 159 // Show the error message 160 } 161 else { 162 // Check if there were any items found 163 if (response.Items.length == 0) 164 alertModal("Sorry, there were no results"); 165 else { 166 167 //split the label returned. 168 var b = response.Items[0].Label.split("\n"); 169 170 // remove last two elements of array as its not required(postcode and country) 171 var country = b.pop(); 172 var postode = b.pop(); 173 174 for (i = 0; i < 3; i++){ 175 document.getElementById(fields[i]).value = ""; 176 if(typeof b[i] != "undefined"){ 177 document.getElementById(fields[i]).value = b[i].toUpperCase(), " "; 178 } 179 } 180 181 182 183 var counter = 0; //required to determine when i can add , to end of string. 184 document.getElementById(fields[3]).value = ""; 185 186 for (var i = 3; i <= b.length; i++) { 187 counter++; 188 if(typeof b[i] != "undefined"){ 189 if(counter > 1){ 190 document.getElementById(fields[3]).value += ", " + b[i].toUpperCase(); 191 }else{ 192 document.getElementById(fields[3]).value += b[i].toUpperCase(); 193 } 194 } 195 } 196 197 var postcode_text_box = fields.pop(); 198 document.getElementById(postcode_text_box).value = response.Items[0].PostalCode 199 200 201 $("#" + list).hide(); 202 } 203 } 204};
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.