1/* This file contains helper functions 2 */ 3/* global window document anime */ 4 5// get parameter in url 6function getParameterByName(name, url) { 7 if (!url) { 8 url = window.location.href; 9 } 10 name = name.replace(/[\[\]]/g, '\\$&'); 11 var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), 12 results = regex.exec(url); 13 if (!results) return null; 14 if (!results[2]) return ''; 15 return decodeURIComponent(results[2].replace(/\+/g, ' ')); 16} 17 18// check if element has child 19function hasChild(element, child) { 20 var node = child.parentNode; 21 while (node !== null) { 22 if (node == element) { 23 return true; 24 } 25 node = node.parentNode; 26 } 27 return false; 28} 29 30// get mouse position (http://www.window.org/js/events_properties.html#position) 31function mousePos(event) { 32 var posX = 0, 33 posY = 0; 34 if (!event) event = window.event; 35 if (event.pageX || event.pageY) { 36 posX = event.pageX; 37 posY = event.pageY; 38 } else if (event.clientX || event.clientY) { 39 posX = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; 40 posY = event.clientY + document.body.scrollTop + document.documentElement.scrollTop; 41 } 42 return { 43 x: posX, 44 y: posY 45 }; 46} 47 48// equalling heights function 49/* EXAMPLE 50 equalheight('.floaters .floater'); 51*/ 52function equalheight(elements) { 53 let $this, 54 currentHighest = 0, 55 currentRowStart = 0, 56 currentDiv, 57 rowDivs = [], 58 topPosition = 0; 59 60 function calculateHeight(elements) { 61 const $elements = document.querySelectorAll(elements); 62 63 $elements.forEach(element => { 64 $this = element; 65 $this.style.minHeight = 0; 66 topPosition = $this.getBoundingClientRect().top; 67 68 if (currentRowStart !== topPosition) { 69 for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) { 70 rowDivs[currentDiv].style.minHeight = currentHighest + 'px'; 71 } 72 rowDivs.length = 0; 73 currentRowStart = topPosition; 74 currentHighest = $this.offsetHeight; 75 rowDivs.push($this); 76 } else { 77 rowDivs.push($this); 78 currentHighest = (currentHighest < $this.offsetHeight) ? $this.offsetHeight : currentHighest; 79 } 80 81 for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) { 82 rowDivs[currentDiv].style.minHeight = currentHighest + 'px'; 83 } 84 }); 85 } 86 87 calculateHeight(elements); 88 window.addEventListener('resize', function () { 89 currentHighest = 0; 90 calculateHeight(elements); 91 }); 92}
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.