PageSourceSearch

https://www.bncmc.gov.in/assets/js/script.js

js bncmc.gov.in collected 2026-10-02 13:24:44 UTC 3,684 bytes, 111 lines download raw bytes

1
2// search  button
3
4function searchContent() {
5    // Get the search query
6    const searchQuery = document.getElementById('searchInput').value.toLowerCase();
7    
8    // Select the body content (with 'searchable' class)
9    const bodyElement = document.querySelector('body.searchable');
10    
11    // Create a copy of the original HTML content for restoring later
12    const originalHTML = bodyElement.innerHTML;
13
14    // Remove any previous highlights
15    bodyElement.innerHTML = originalHTML;
16
17    // Check if search query exists in the body text
18    if (searchQuery !== "" && bodyElement.textContent.toLowerCase().includes(searchQuery)) {
19        highlightText(bodyElement, searchQuery);
20    }
21}
22
23function highlightText(element, searchQuery) {
24    // Loop through all child nodes of the element
25    const childNodes = element.childNodes;
26
27    childNodes.forEach(child => {
28        if (child.nodeType === 3) { // If it's a text node
29            const text = child.nodeValue;
30            const regex = new RegExp(`(${searchQuery})`, 'gi');
31            const highlightedText = text.replace(regex, '<span class="highlight">$1</span>');
32            const newElement = document.createElement('span');
33            newElement.innerHTML = highlightedText;
34            child.replaceWith(newElement);
35        } else if (child.nodeType === 1) { // If it's an element node (e.g., <a>, <p>, etc.)
36            highlightText(child, searchQuery); // Recursively call for child elements
37        }
38    });
39}
40
41
42// Function to show the selected slide
43let currentSlide = 0;
44function showSlide(index) {
45    const slides = document.querySelectorAll('.carousel-item');
46    const totalSlides = slides.length;
47
48    // Wrap the index if it exceeds bounds
49    if (index >= totalSlides) {
50        currentSlide = 0;
51    } else if (index < 0) {
52        currentSlide = totalSlides - 1;
53    } else {
54        currentSlide = index;
55    }
56
57    // Slide to the selected slide
58    const carouselInner = document.querySelector('.carousel-inner');
59    carouselInner.style.transform = 'translateX(' + (-currentSlide * 100) + '%)';
60}
61
62// Function to move between slides
63function moveSlide(direction) {
64    showSlide(currentSlide + direction);
65}
66
67// Initialize the first slide on page load
68document.addEventListener('DOMContentLoaded', () => {
69    showSlide(currentSlide);
70});
71
72
73//Visitor count JS
74
75document.addEventListener("DOMContentLoaded", function () {
76    // Retrieve the visit count from localStorage or initialize it to 0 if it doesn't exist
77    let visitCount = localStorage.getItem('page_view_count') || 0;
78
79    // Increment the visit count
80    visitCount++;
81
82    // Save the new count to localStorage
83    localStorage.setItem('page_view_count', visitCount);
84
85    // Update the count in the HTML
86    document.getElementById('visit-count').textContent = visitCount;
87});
88
89       // Function to load footer content dynamically from footer.html
90       function loadFooter() {
91           fetch('footer.html')
92               .then(response => response.text())
93               .then(data => {
94                   document.getElementById('footer-placeholder').innerHTML = data;
95                   // Call the visitor count function after footer is loaded
96                   updateVisitorCount();
97               })
98               .catch(error => {
99                   console.error('Error loading footer:', error);
100               });
101       }
102
103
104// Visitor Count Logic
105function updateVisitorCount() {
106    let visitCount = parseInt(localStorage.getItem('visitCount')) || 0;
107    visitCount += 1;
108    localStorage.setItem('visitCount', visitCount);
109    document.getElementById('visit-count').textContent = visitCount;
110}
111loadFooter();

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.