1(function() { 2 'use strict'; 3 4 var reStyle = /background: #[a-f0-9]{6};/; 5 6 var check = function () { 7 var images = document.getElementsByClassName( 'dcll-placeholder' ); 8 var viewport = document.documentElement.clientHeight || window.innerHeight; 9 var updated = false; 10 11 [].forEach.call( images, function ( image ) { 12 13 var rect = image.getBoundingClientRect(); 14 15 if ( viewport - rect.top > 0 ) { 16 show( image ); 17 updated = true; 18 } 19 20 } ); 21 22 if (updated) { 23 check(); 24 } 25 }; 26 27 var show = function ( image ) { 28 if ( image.hasAttribute( 'style' ) ) { 29 image.addEventListener( 'load', function () { 30 image.setAttribute( 'style', image.getAttribute( 'style' ).replace( reStyle, '' ) ); 31 } ); 32 } 33 34 image.src = image.getAttribute( 'data-src' ); 35 image.removeAttribute( 'data-src' ); 36 37 if ( image.hasAttribute( 'data-srcset' ) ) { 38 image.srcset = image.getAttribute( 'data-srcset' ); 39 image.removeAttribute( 'data-srcset' ); 40 } 41 42 image.classList.remove( 'dcll-placeholder' ); 43 }; 44 45 var firstUserInteraction = function () { 46 check(); 47 document.body.removeEventListener( 'mousemove', firstUserInteraction, false ); 48 document.body.removeEventListener( 'keydown', firstUserInteraction, false ); 49 document.body.removeEventListener( 'mousedown', firstUserInteraction, false ); 50 document.body.removeEventListener( 'touchstart', firstUserInteraction, false ); 51 }; 52 53 window.addEventListener( 'load', check, false ); 54 window.addEventListener( 'scroll', check, false ); 55 window.addEventListener( 'resize', check, false ); 56 document.body.addEventListener( 'post-load', check, false ); 57 document.body.addEventListener( 'mousemove', firstUserInteraction, false ); 58 document.body.addEventListener( 'keydown', firstUserInteraction, false ); 59 document.body.addEventListener( 'mousedown', firstUserInteraction, false ); 60 document.body.addEventListener( 'touchstart', firstUserInteraction, false ); 61})();
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.