/*------------------------------------------------------- ADDTHIS SOCIAL SHARING -------------------------------------------------------*/ $(function() { let myScript = document.createElement("script"); myScript.setAttribute("src", "https://s7.addthis.com/js/300/addthis_widget.js#pubid=webkellogg"); document.body.appendChild(myScript); // myScript.addEventListener("load", scriptLoaded, false); }); /*------------------------------------------------------- READING TIME To use, add the following HTML to a page: read ( words) Pass the getReadingTime function the unique class of the HTML element that contains the text you want to estimate a reading time for. -------------------------------------------------------*/ function getReadingTime(articleContainer) { let myScript = document.createElement("script"); myScript.setAttribute("src", "https://cdnjs.cloudflare.com/ajax/libs/reading-time/2.0.0/readingTime.min.js"); document.body.appendChild(myScript); //myScript.addEventListener("load", scriptLoaded, false); $("" + articleContainer + "").readingTime({ wordCountTarget: $('.word-count'), }); } /*------------------------------------------------------- SCROLL TO TOP To use, add a the following HTML to a page: -------------------------------------------------------*/ function scrollFunction() { if (document.body.scrollTop > 400 || document.documentElement.scrollTop > 400) { topbutton.style.display = "block"; } else { topbutton.style.display = "none"; } } // When the user clicks on the button, scroll to the top of the document function topFunction() { document.body.scrollTop = 0; // For Safari document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera } $(function() { // wait for document ready //Get the button: topbutton = $("footer #topBtn")[0]; if (topbutton) { // When the user scrolls down 20px from the top of the document, show the button window.onscroll = function() { scrollFunction() } } });