PageSourceSearch

https://cug.ac.in/js/popup.js

js cug.ac.in collected 2026-10-02 07:24:06 UTC 2,075 bytes, 61 lines download raw bytes

1/**
2 * Latest Updates Popup Script
3 * Displays the rotating announcements/events/admission/tender/recruitment
4 * popup when the website loads. popup.php only renders the #popup element
5 * when at least one active (non-expired) item exists, so no date check is
6 * needed here beyond guarding against the element being absent.
7 */
8
9document.addEventListener('DOMContentLoaded', function() {
10    const popup = document.getElementById('popup');
11    if (!popup) return;
12
13    const closeBtn = document.querySelector('.popup-close');
14    const itemLinks = document.querySelectorAll('.popup-item-link');
15
16    // Check if popup has been shown in this session
17    const popupShown = sessionStorage.getItem('popupShown');
18
19    // Show popup after a short delay if not shown in this session
20    if (!popupShown) {
21        setTimeout(function() {
22            popup.classList.add('active');
23            document.body.style.overflow = 'hidden'; // Prevent scrolling
24        }, 500);
25    }
26
27    // Close popup function
28    function closePopup() {
29        popup.classList.remove('active');
30        document.body.style.overflow = ''; // Restore scrolling
31        sessionStorage.setItem('popupShown', 'true');
32    }
33
34    // Close popup when clicking the close button
35    if (closeBtn) {
36        closeBtn.addEventListener('click', closePopup);
37    }
38
39    // Mark popup as shown when clicking on any item link
40    if (itemLinks.length > 0) {
41        itemLinks.forEach(function(link) {
42            link.addEventListener('click', function() {
43                sessionStorage.setItem('popupShown', 'true');
44            });
45        });
46    }
47
48    // Close popup when clicking outside the content area
49    popup.addEventListener('click', function(e) {
50        if (e.target === popup) {
51            closePopup();
52        }
53    });
54
55    // Close popup with Escape key
56    document.addEventListener('keydown', function(e) {
57        if (e.key === 'Escape' && popup.classList.contains('active')) {
58            closePopup();
59        }
60    });
61});

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.