1 2jQuery(function ($) { 3 /* 4 localized variables passed through params object: 5 salesforce_nfpluginsettings.clearLogRestUrl 6 salesforce_nfpluginsettings.clearLogButtonId 7 salesforce_nfpluginsettings.downloadLogRestUrl 8 salesforce_nfpluginsettings.downloadLogButtonId 9 salesforce_nfpluginsettings.authCodeFieldId 10 11 */ 12 13 /** 14 * Authorization Code Field Handler - Issue #125 15 * 16 * Processes pasted/entered authorization codes to: 17 * 1. Strip the Salesforce OAuth redirect URL if present 18 * 2. Decode %3D to = so it survives sanitize_text_field() 19 * 20 * This runs client-side before form submission to preserve the 21 * trailing == characters that would otherwise be stripped. 22 */ 23 const authCodeFieldSelector = '[name="' + salesforce_nfpluginsettings.authCodeFieldId + '"]'; 24 25 $(authCodeFieldSelector).on("paste input", function(e) { 26 const $field = $(this); 27 28 // Use setTimeout to allow paste to complete before processing 29 setTimeout(function() { 30 let value = $field.val(); 31 32 if (!value) return; 33 34 // Strip Salesforce OAuth redirect URL patterns (login or test) 35 // Matches: https://login.salesforce.com/services/oauth2/success?code= 36 // Matches: https://test.salesforce.com/services/oauth2/success?code= 37 value = value.replace(/https:\/\/(login|test)\.salesforce\.com\/services\/oauth2\/success\?code=/gi, ''); 38 39 // Decode percent-encoded equals signs (%3D -> =) 40 // This preserves the trailing == that sanitize_text_field would strip 41 value = value.replace(/%3D/gi, '='); 42 43 // Update the field with the processed value 44 $field.val(value); 45 }, 0); 46 }); 47 48 $("#"+salesforce_nfpluginsettings.clearLogButtonId).on("click", () => { 49 50 $.post( 51 salesforce_nfpluginsettings.clearLogRestUrl, 52 { }, 53 function (json) { 54 console.log(json); 55 } 56 ); 57 }); 58 59 $("#"+salesforce_nfpluginsettings.downloadLogButtonId).on("click", () => { 60 $.post( 61 salesforce_nfpluginsettings.downloadLogRestUrl, 62 {}, 63 function (json) { 64 let download = json.data; 65 66 var blob = new Blob([download], { type: "json" }); 67 68 var a = document.createElement("a"); 69 a.download = "nf-salesforce-debug-log.json"; 70 a.href = URL.createObjectURL(blob); 71 a.dataset.downloadurl = ["json", a.download, a.href].join(":"); 72 a.style.display = "none"; 73 document.body.appendChild(a); 74 a.click(); 75 document.body.removeChild(a); 76 setTimeout(function () { 77 URL.revokeObjectURL(a.href); 78 }, 15000); 79 } 80 ); 81 }); 82 83return; 84 85});
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.