1var postcodeChecker = {}; 2 3(function () { 4 5 $(document).ready(function () { 6 postcodeChecker.loadPostCodeChecker(); 7 }); 8 9 this.loadPostCodeChecker = function () { 10 11 $(".pcc-result-loading").hide(100); 12 13 var button = $("#postcode-checker-component .pcc-button"); 14 15 // FIXED: button check (button alone is always truthy) 16 if (button.length > 0) { 17 $(button).on("click", function (event) { 18 event.preventDefault(); 19 postcodeChecker.validatePostCode(this); 20 }); 21 } 22 }; 23 24 this.validatePostCode = function (btnCtl) { 25 26 var component = $("#postcode-checker-component"); 27 28 $(".pcc-result span").hide(100); 29 $(".pcc-result-loading").show(100); 30 $(".pcc-result span").html(""); 31 $(".pcc-result-error span").css("display", "none"); 32 33 var dataId = component.attr("pcc-data-id"); 34 var fromId = component.attr("pcc-fr-id"); 35 var postCode = $("#pcc-input-box").val(); 36 37 if (dataId) { 38 39 var token = $('input[name="__RequestVerificationToken"]', $('#' + fromId)).val(); 40 var formsApiUrl = "/api/v1/postcodechecker/validate"; 41 42 $.ajax({
43 type: "POST", 44 headers: { 45 'Content-Type': 'application/x-www-form-urlencoded', 46 __RequestVerificationToken: token 47 }, 48 contentType: 'application/json', 49 data: JSON.parse( 50 '{"ContextId":"' + encodeURIComponent(dataId) + '","PostCode":"' + encodeURIComponent(postCode) + '"}' 51 ), 52 url: formsApiUrl, 53 54 success: function (data) { 55 56 if (data && data.data && data.data.success === true) { 57 58 $(".pcc-result span").html(data.data.data.ResultDescriptionText); 59 $(".pcc-result-loading").hide(100); 60 $(".pcc-result span").show(100); 61 62 window.setTimeout(function () { 63 footerPush(); 64 }, 1000); 65 66 } else { 67 68 $(".pcc-result-loading").hide(100); 69 $(".pcc-result span").html(data.data.message); 70 } 71 }, 72 73 error: function () { 74 $(".pcc-result-error span").html(""); 75 $(".pcc-result-error span").css("display", "block"); 76 $(".pcc-result-error span").html("Unexpected error"); 77 } 78 }); 79 } 80 }; 81 82}).apply(postcodeChecker);
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.