1/* 2functions and detections specific to the project (keeps from cluttering up hp-shared.js) 3ALL FUNCTIONS MUST BE INSIDE jQuery(document).ready(async function($) {}); 4 5for $current_rel_uri see hp-shared.js 6 7*/ 8// global vars ===== 9// /global vars ===== 10 11jQuery(document).ready(async function($) { 12 /* 13 ===== 14 detections: 15 16 ===== 17 */ 18 19 // elevate functions to window scope ========== 20 // like: window.myfunction = myfunction; 21 // /elevate functions to window scope ========== 22 23 $('.featured-profiles-query .wp-block-query .wp-block-post').each(function () { 24 var link = $(this).find('figure a').attr('href'); 25 $(this).find('figure img').unwrap(); 26 $(this).find('.wp-block-post-terms a').each(function() { 27 var segments = ($(this).attr('href').split('/')); 28 var slug = segments[segments.length - 2]; 29 var cat = $(this).text(); 30 $(this).closest('.wp-block-post-terms').append('<div class="post-term post-term-'+slug+'">' + cat + '</div>'); 31 $(this).closest('.wp-block-post-terms').find('span').remove(); 32 $(this).remove(); 33 }); 34 $(this).find('> *').wrapAll('<a href="' + link + '">'); 35 }); 36 37 $('#invention-spotlight .owl-carousel').owlCarousel({items: 1, loop: true, dots: true, autoplay: true, autoplayTimeout: 5000, animateOut: 'fadeOut', autoplayHoverPause: true}) 38 39 // blog post scripts 40 // remove links from category meta and wrap individual categories in DIVs 41 $('.blog .query-panel .wp-block-post-terms a, .archive .query-panel .wp-block-post-terms a, .search main.wp-block-query .wp-block-post-terms a').each(function () { 42 var segments = ($(this).attr('href').split('/')); 43 var slug = segments[segments.length - 2]; 44 var cat = $(this).text(); 45 $(this).closest('.wp-block-post-terms').append('<div class="post-term post-term-'+slug+'">' + cat + '</div>'); 46 $(this).closest('.wp-block-post-terms').find('span').remove(); 47 $(this).remove(); 48 }); 49 50 $('#submenu-news-recent-news .wp-block-post-terms a').each(function () { 51 var segments = ($(this).attr('href').split('/')); 52 var slug = segments[segments.length - 2]; 53 var cat = $(this).text(); 54 $(this).closest('.wp-block-post-terms').append('<div class="post-term post-term-'+slug+'">' + cat + '</div>'); 55 $(this).closest('.wp-block-post-terms').find('span').remove(); 56 $(this).remove(); 57 }); 58 59 $('#our-impact-links-container .wp-block-post-terms a').each(function () { 60 // find the anchors in the post terms 61 // chop the href into parts 62 var segments = ($(this).attr('href').split('/')); 63 // find the slug for the post category from the URL 64 var slug = segments[segments.length - 2]; 65 // extract the string version of the category 66 var cat = $(this).text();
67 // append the post term with a category identifier and no anchor 68 $(this).closest('.wp-block-post-terms').append('<div class="post-term post-term-'+slug+'">' + cat + '</div>'); 69 // remove the spans between categories 70 $(this).closest('.wp-block-post-terms').find('span').remove(); 71 // remove the link 72 $(this).remove(); 73 }); 74 75 $('.lemelson-related-posts .wp-block-post-terms a').each(function () { 76 var segments = ($(this).attr('href').split('/')); 77 var slug = segments[segments.length - 2]; 78 var cat = $(this).text(); 79 $(this).closest('.wp-block-post-terms').append('<div class="post-term post-term-'+slug+'">' + cat + '</div>'); 80 $(this).closest('.wp-block-post-terms').find('span').remove(); 81 $(this).remove(); 82 }); 83 84 // shave recent news submenu titles 85 $('#submenu-news-recent-news h2').shave(74); 86 87 // shave invention notebook featured 88 $('.invention-notebook-featured .posts-list .notebook-category-post').each(function() { 89 var targetHeight = 500; 90 var titleHeight = $(this).find('.notebook-category-post-title').outerHeight(); 91 var detailsHeight = $(this).find('.notebook-category-details').outerHeight(); 92 93 $(this).find('.notebook-category-post-excerpt').shave(targetHeight - titleHeight - detailsHeight - 48); 94 }); 95 96 // shave invention notebook grid 97 $('.invention-notebook-grid .posts-list .notebook-category-post').each(function() { 98 var targetHeight = 220; 99 var titleHeight = $(this).find('.notebook-category-post-title').outerHeight(); 100 if (titleHeight > targetHeight) { 101 $(this).find('.notebook-category-post-excerpt').css('display','none'); 102 $(this).find('.notebook-category-post-title').shave(targetHeight); 103 } else { 104 $(this).find('.notebook-category-post-excerpt').shave(targetHeight - titleHeight); 105 if ($(this).find('.notebook-category-content').outerHeight() > targetHeight) { 106 $(this).find('.notebook-category-post-excerpt').css('display','none'); 107 } 108 }; 109 }); 110 111 112 // highlight current menu item on the news menu 113 if ($('.menu-news')) { 114 var host = location.host; 115 $('.menu-news a').each(function() { 116 var link = host + $(this).attr('href'); 117 if (location.href.includes(link)) { 118 // console.log(link); 119 $(this).closest('li').addClass('current-menu-item'); 120 } else { 121 // console.log("no match"); 122 } 123 }); 124 } 125 126 if ($('h6.search-query-title')) { 127 var text = $('h6.search-query-title').text(); 128 //console.log("HTML " + $('h6.search-query-title').html()); 129 text = text.substring(21, (text.length - 1)); 130 text = "Here are the results of your search for <strong>
130" + text + "</strong>"; 131 $('h6.search-query-title').html(text); 132 } 133 134 // build scene 135 if ("#parallax-20th-anniversary-image") { 136 console.log('parallax'); 137 var imageHeight = $("#parallax-20th-anniversary-image").height() 138 var controller = new ScrollMagic.Controller(); 139 var scene = new ScrollMagic.Scene({ 140 triggerElement: "#parallax-20th-anniversary-image", 141 duration: imageHeight, 142 triggerHook: "onCenter", 143 offset: imageHeight / 2 144 }) 145 .setPin("#parallax-20th-anniversary-image") 146 .addTo(controller); 147 } 148 149 // toggles for what we fund Q&A 150 $('.quanda .quanda-toggle').click(function(e) { 151 $(e.target).closest('.quanda').toggleClass('quanda-condensed'); 152 }); 153 154 // inserts the current URL for copy icon 155 $('.post-social-container .share-url-container .ctc-inline-copy-textarea').text(document.location.href); 156 157 // inserts reading time for invention notebook 158 $('.invention-notebook-read-time').each(function(e) { 159 var content_container = $(this).closest('.post-content-container')[0]; 160 var content = $(content_container).find('.entry-content')[0]; 161 var text = $(content).text(); 162 // console.log(text); 163 var words = text.split(' ').length; 164 console.log('words: ' + words); 165 var min = Math.round(words / 200); 166 console.log (min + " min read"); 167 $(content_container).find('.invention-notebook-read-time').text(min + " min read"); 168 }); 169 170 // converts audio file text to link 171 $('.invention-notebook-audio').each(function() { 172 var audio_container = $(this); 173 var audio_url = audio_container.text(); 174 audio_container.text(''); 175 if (audio_url.length > 0) { 176 audio_container.html('<i class="fa fa-play-circle-o" aria-hidden="true"></i>'); 177 audio_container.click(function () { 178 var audio = new Audio(audio_url); 179 audio.play(); 180 }); 181 }; 182 }); 183 184});// /jQuery(document).ready(function($) { 185 186function slugify(str) { 187 str = str.replace(/^\s+|\s+$/g, ''); // trim leading/trailing white space 188 str = str.toLowerCase(); // convert string to lowercase 189 str = str.replace(/[^a-z0-9 -]/g, '') // remove any non-alphanumeric characters 190 .replace(/\s+/g, '-') // replace spaces with hyphens 191 .replace(/-+/g, '-'); // remove consecutive hyphens 192 return str; 193}
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.