1/** 2 * Marketo Master Prefill Receiver 3 * Version: 1.1 4 * Deploy on: www.esri.ca, resources.esri.ca, events.esri.ca, learn.esri.ca 5 * 6 * Dependencies (load BEFORE this script): 7 * 1. teknkl-formsplus-core-1.0.8.js 8 * 2. teknkl-simpledto-2.0.4.js 9 * 3. forms2.min.js (Marketo Forms 2.0) 10 */ 11(function() { 12 'use strict'; 13 14 var DTP_URL = 'https://pages.esri.ca/prefill-dtp.html'; 15 var MESSAGE_SOURCE = 'https://pages.esri.ca'; 16 var DEBUG = false; // Set false after testing 17 18 if (typeof FormsPlus === 'undefined') { 19 if (DEBUG) console.error('Prefill: FormsPlus Core library not loaded'); 20 return; 21 } 22 23 if (typeof SimpleDTO === 'undefined') { 24 if (DEBUG) console.error('Prefill: SimpleDTO library not loaded'); 25 return; 26 } 27 28 if (DEBUG) { 29 console.log('Prefill: Initializing receiver'); 30 console.log('Prefill: DTP URL:', DTP_URL); 31 console.log('Prefill: Current origin:', window.location.origin); 32 } 33 34 var DTO = new SimpleDTO({ 35 mode: "receive", 36 transport: "message", 37 messageSource: MESSAGE_SOURCE, 38 messageTarget: [window.location.origin], 39 dataSrc: DTP_URL, 40 debug: DEBUG, 41 cb: function(instance, mktoFields) { 42 if (DEBUG) { 43 console.log('Prefill: Received fields from DTP:', mktoFields); 44 } 45 46 var hasData = mktoFields && Object.keys(mktoFields).some(function(key) { 47 var val = mktoFields[key]; 48 return val && String(val).trim() !== ''; 49 }); 50 51 if (!hasData) { 52 if (DEBUG) console.log('Prefill: No data received (visitor may be unknown)'); 53 DTO.cleanup(); 54 return; 55 } 56 57 if (typeof MktoForms2 !== 'undefined') { 58 MktoForms2.whenReady(function(form) { 59 form.setValuesCoerced(mktoFields); 60 61 if (DEBUG) { 62 console.log('Prefill: Applied to form ID:', form.getId()); 63 console.log('Prefill: Form values after apply:', form.getValues()); 64 } 65 }); 66 } else { 67 if (DEBUG) console.warn('Prefill: MktoForms2 not available'); 68 } 69 70 DTO.cleanup(); 71 } 72 }); 73})();
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.