1// Initialize Tracker once per page visit 2window.adWizardTracker = window.adWizardTracker || { viewed: {} }; 3 4// Ad Wizard JS 5var adWizard = { 6 click: function (id, url) { 7 8 // Set data 9 var data = {'id':id}; 10 data[window.csrfTokenName] = window.csrfTokenValue; // Append CSRF Token 11 12 // Open link in new window 13 window.open(url); 14 15 // Tally click 16 window.superagent 17 .post('/actions/ad-wizard/tracking/click') 18 .send(data) 19 .type('form') 20 .set('X-Requested-With','XMLHttpRequest') 21 .end(function (response) { 22 var message = JSON.parse(response.text); 23 console.log(message); 24 }) 25 ; 26 }, 27 28 view: function(id, options) { 29 const defaultOptions = { 30 oncePerPage: true, 31 debug: false, 32 }; 33 const opts = Object.assign(defaultOptions, options); 34 35 // Set data 36 var data = { 'id': id }; 37 data[window.csrfTokenName] = window.csrfTokenValue; // Append CSRF Token 38 39 // If not yet tracking views, begin tracking 40 if (!(id in window.adWizardTracker.viewed)) { 41 window.adWizardTracker.viewed[id] = 0; 42 } 43 44 // If already viewed and limited to once per page, bail 45 if (window.adWizardTracker.viewed[id] && opts.oncePerPage) { 46 return; 47 } 48 49 // Increment tracker 50 window.adWizardTracker.viewed[id] += 1; 51 52 // Tally view 53 window.superagent 54 .post('/actions/ad-wizard/tracking/view') 55 .send(data) 56 .type('form') 57 .set('X-Requested-With', 'XMLHttpRequest') 58 .end(function(response) { 59 if (opts.debug) { 60 var message = JSON.parse(response.text); 61 console.log(message); 62 } 63 }) 64 ; 65 66 // If debugging, show console message 67 if (opts.debug) { 68 console.log(`[Ad Wizard] Ad ${id} viewed ${window.adWizardTracker.viewed[id]}.`) 69 } 70 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.