1// START lazy load for elements 2 3function loadImage(element, src) { 4 element.src = src; 5 element.classList.add("ms-loaded"); 6} 7 8function loadVideo(element, videoId, params) { 9 const videoWrapper = document.createElement("div"); 10 const iframe = document.createElement("iframe"); 11 12 const query = new URLSearchParams(params).toString(); 13 const src = `https://www.youtube.com/embed/${videoId}?${query}`; 14 15 videoWrapper.classList.add("video-wrapper"); 16 iframe.src = src; 17 iframe.setAttribute("frameborder", "0"); 18 iframe.setAttribute("allowfullscreen", ""); 19 iframe.setAttribute("allow", "autoplay"); 20 21 videoWrapper.appendChild(iframe); 22 element.parentNode.replaceChild(videoWrapper, element); 23} 24 25 26function getYoutubeVideoId(url) { 27 const match = url.match(/(?:\/|%3D|v=)([0-9A-Za-z_-]{11}).*/); 28 return match ? match[1] : null; 29} 30 31function initializeLazyLoading() { 32 let lazyItems = document.querySelectorAll(".lazy"); 33 34 if (lazyItems.length) { 35 if ("IntersectionObserver" in window) { 36 const intersectionObserver = new IntersectionObserver((entries) => { 37 entries.forEach((entry) => { 38 if (entry.isIntersecting) { 39 const { type, src } = entry.target.dataset; 40 const params = Object.assign({}, entry.target.dataset); 41 delete params.type; 42 delete params.src; 43 44 switch (type) { 45 case "image": 46 loadImage(entry.target, src); 47 break; 48 case "video": 49 loadVideo(entry.target, src, params); 50 break; 51 } 52 entry.target.classList.remove("lazy"); 53 intersectionObserver.unobserve(entry.target); 54 } 55 }); 56 }); 57 58 lazyItems.forEach((item) => { 59 intersectionObserver.observe(item); 60 }); 61 } 62 } 63} 64initializeLazyLoading(); 65 66// END lazy load for elements 67 68(function ($) { 69 $(".tooltip").tooltip({ 70 position: { 71 my: "center bottom-20", 72 at: "center top", 73 using: function (position, feedback) { 74 $(this).css(position); 75 $("<div>") 76 .addClass("arrow") 77 .addClass(feedback.vertical) 78 .addClass(feedback.horizontal) 79 .appendTo(this); 80 }, 81 }, 82 }); 83})(jQuery);
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.