1(function (w,d){ 2 var api = function () { 3 return api.dispatch(arguments); 4 }; 5 6 api.dispatch = function dispatch_(cmd) { 7 var method = cmd[0]; 8 var params = Array.prototype.slice.call(cmd, 1); 9 var fn = (typeof method === "function") ? method : this[method]; 10 fn.apply(this, params); 11 }; 12 13 // Set the config value for `k` to be `v`. 14 api.config = Object.assign(function config_(k, v) { 15 this.config[k] = v; // because functions are objects too :) 16 }, { 17 baseuri: '//otherpeoplespixels.com/log/locke', 18 filename: 'clear.gif' 19 }); 20 21 // init params 22 api.params = {}; 23 24 // Set the param value for `k` to be `v`. 25 api.set = function set_(k, v) { 26 this.params[k] = v; 27 }; 28 29 // Set the value of `k` to be `top,right,bottom,left,width,height` of `child` 30 // relative to `parent` or viewport if not provided`api.getRect(id)` 31 api.rect = function rect_(k, child, parent) { 32 this.set(k, this.getRect(child, parent) || 'not-found'); 33 }; 34 35 function geometry(w, h, x, y) { 36 return [ 37 /* size */ 38 Math.round(w), 'x', 39 Math.round(h), 40 /* offset */ 41 (x < 0 ? '' : '+'), 42 Math.round(x), 43 (y < 0 ? '' : '+'), 44 Math.round(y) 45 ].join(''); 46 } 47 48 // Return the size and offset of the element matching `id` relative to the 49 // viewport or the element matching the provided opt_id. In either case the 50 // returned offsets are adjusted to accomodate the current scroll position. 51 api.getRect = function getRect_(id, opt_id) { 52 var el = d.getElementById(id); 53 // get css bounding box for element to be measured 54 var rect = el && el.getBoundingClientRect(); 55 // get scroll offset for viewport or opt_id element 56 var scroll = rect && opt_id ? (function () { 57 var el = d.getElementById(opt_id); 58 return el && { x: el.scrollLeft, y: el.scrollTop }; 59 }()) : { x: w.pageXOffset, y: w.pageYOffset }; 60 61 if (rect && scroll) { 62 return geometry( 63 rect.width || el.offsetWidth, 64 rect.height || el.offsetHeight, 65 rect.left + scroll.x, 66 rect.top + scroll.y 67 ); 68 } 69 }; 70 71 api.uri = function uri_() { 72 var config = this.config; 73 var params = this.params 74 var uri = [config.baseuri, config.pathname, config.filename] 75 .filter(Boolean).join('/'); 76 return Object.keys(params).reduce(function (uri, k) { 77 return uri + '&' + k + '=' + encodeURIComponent(params[k]); 78 }, uri + '?'); 79 }; 80 81 api.send = function send_() { 82 var img = d.createElement('img'); 83 img.onload = img.onerror = function () { img.parentNode.removeChild(img) }; 84 img.src = this.uri(); 85 img.width = img.height = 1; 86 img.style.display = 'none'; 87 d.body.appendChild(img); 88 }; 89 90 function viewportSize() { 91 var el = d.documentElement || d.body; 92 return el.clientWidth + 'x' + el.clientHeight; 93 } 94 95 (function () { 96 // get command queue from oppa global 97 var q = (w.oppa && w.oppa.q) || []; 98 // override global 99 w.oppa = api; 100 101 // run after a short delay 102 setTimeout(function () { 103 var params = api.params; 104 params.x = window.devicePixelRatio || 1; 105 params.v = viewportSize(); 106 !!q && q.forEach(function (cmd) { 107 api.dispatch(cmd); 108 }); 109 }, 10); 110 })(); 111}(window,document));
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.