PageSourceSearch

https://indianexpress.com/wp-content/themes/indianexpress/js/ie-print-article-script.js?ver=18022025.01

js indianexpress.com collected 2026-09-24 06:04:34 UTC 3,402 bytes, 115 lines download raw bytes

1/**
2 * Print Article Script.
3 *
4 * @package indian-express
5 */
6
7function addFollowScript() {
8  (function (doc, scrt) {
9    function insertFollowButton() {
10      if (
11        0 === jQuery( '.custom_follow_author' ).length
12        && 0 === jQuery( '.author_feed_data' ).length
13        &&  0 === jQuery( '.ieauthor-follow' ).length
14        && !document.getElementById("custom_follow_author_1")
15      ) {
16        var newElement = document.createElement("div"); 
17        newElement.innerHTML = `<div class="sociallogin_popup_content ie-hide"><div class="ieauthor-follow iebg-follow" id="custom_follow_author_1">follow</div></div>`; // phpcs:ignore
18        document.body.appendChild(newElement);
19
20        var js = doc.createElement(scrt);
21        js.src =
22          location.protocol +
23          "//" +
24          location.hostname +
25          "/wp-content/themes/indianexpress/js/min/ie-author-follow.js?ver=19072022.2";
26        js.async = true;
27        document.body.appendChild(js);
28      }
29    }
30
31    if (document.readyState === "loading") {
32      document.addEventListener("DOMContentLoaded", insertFollowButton);
33    } else {
34      insertFollowButton();
35    }
36  })(document, "script");
37}
38
39function loadLazyImages() {
40  return new Promise((resolve) => {
41    var lazyImages = document.querySelectorAll("img.lazyloading[data-src]");
42    var lazyIframes = document.querySelectorAll("iframe[data-src]"); // Select lazy-loaded iframes
43
44    let totalElements = lazyImages.length + lazyIframes.length;
45    let loadedCount = 0;
46
47    if (totalElements === 0) {
48      resolve();
49      return;
50    }
51
52    
53    lazyImages.forEach((img) => {
54      if (img.dataset.src && img.src !== img.dataset.src) {
55        img.src = img.dataset.src;
56        img.onload = img.onerror = () => {
57          loadedCount++;
58          if (loadedCount === totalElements) {
59            resolve();
60          }
61        };
62      } else {
63        loadedCount++;
64      }
65    });
66
67    
68    lazyIframes.forEach((iframe) => {
69      let videoSrc = iframe.getAttribute("data-src") || iframe.getAttribute("src");
70
71      if (videoSrc && videoSrc.includes("youtube.com/embed/")) {
72        let videoId = videoSrc.split("embed/")[1].split("?")[0];
73        let thumbnail = `https://img.youtube.com/vi/${videoId}/hqdefault.jpg`;
74        let existingThumbnail = iframe.parentNode.querySelector(".print-video");
75        if (!existingThumbnail) {
76          
77          let div = document.createElement("div");
78          div.classList.add("print-video");
79          div.innerHTML = `<img src="${thumbnail}" alt="YouTube Video" style="width:100%; max-width:560px;"><p><a href="https://www.youtube.com/watch?v=${videoId}" target="_blank">Watch Video</a></p>`; // phpcs:ignore
80          iframe.insertAdjacentElement("afterend", div);          
81          iframe.classList.add("has-print-thumb");
82        }
83      }
84
85      loadedCount++;
86      if (loadedCount === totalElements) {
87        resolve();
88      }
89    });
90
91    if (loadedCount === totalElements) {
92      resolve();
93    }
94  });
95}
96
97// Check images load before manual print (Ctrl+P)
98window.onbeforeprint = () => {
99  loadLazyImages();
100};
101
102// Check support of modern browsers
103if (window.matchMedia) {
104  window.matchMedia("print").addListener((mql) => {
105    if (mql.matches) {
106      loadLazyImages();
107    }
108  });
109}
110
111jQuery( window ).ready( function () {
112	setTimeout(function(){
113    addFollowScript();
114	},2000);
115});

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.