1(function () { 2 // Make sure we only load the script once. 3 if (window.OC && window.OC.buttons) { 4 return; 5 } 6 7 window.OC = window.OC || {}; 8 window.OC.buttons = []; 9 10 function OpenCollectiveButton(anchor) { 11 this.anchor = anchor; 12 this.styles = window.getComputedStyle(anchor.parentNode, null); 13 14 this.getContainerWidth = () => { 15 return ( 16 this.anchor.parentNode.getBoundingClientRect().width - 17 parseInt(this.styles.paddingLeft, 10) - 18 parseInt(this.styles.paddingRight, 10) 19 ); 20 }; 21 22 this.getAttributes = () => { 23 const attributes = {}; 24 [].slice.call(this.anchor.attributes).forEach(attr => { 25 attributes[attr.name] = attr.value; 26 }); 27 return attributes; 28 }; 29 30 this.inject = e => { 31 this.anchor.parentNode.insertBefore(e, this.anchor); 32 }; 33 34 const attributes = this.getAttributes(); 35 const color = attributes.color || 'white'; 36 const tokens = attributes.src.match(/([a-z]+)\/button\.js/); 37 const verb = tokens[1]; 38 const width = verb === 'donate' ? 300 : 338; 39 const html = `<center><iframe src="https://opencollective.com/webpack/${verb}/button?color=${color}" width="${width}" height=50 frameborder=0></iframe></center>`; 40 41 this.el = document.createElement('div'); 42 this.el.className = 'opencollective-contribute-button'; 43 this.el.innerHTML = html; 44 45 this.inject(this.el); 46 } 47 48 const init = () => { 49 const scriptsNodesArray = [].slice.call(document.querySelectorAll('script')); 50 const regex = new RegExp('https://opencollective.com'.replace(/^https?:\/\//, ''), 'i'); 51 scriptsNodesArray.map(s => { 52 const src = s.getAttribute('src'); 53 if (src && src.match(regex) && src.match(/button\.js/)) { 54 window.OC.buttons.push(new OpenCollectiveButton(s)); 55 } 56 }); 57 }; 58 59 if (document.readyState !== 'loading') { 60 init(); 61 } else { 62 document.addEventListener('DOMContentLoaded', init); 63 } 64})();
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.