• File: script-20260713064010.js
  • Full Path: /home/paksaaibaan/itdashboard.paksaaibaan.com/pages/pages-20260713095501/script-20260713064010.js
  • Date Modified: 07/08/2026 1:14 PM
  • File size: 5.84 KB
  • MIME-type: text/html; charset=us-ascii
  • Charset: utf-8
/* Filename: script.js */
// ====== VERSION: 2.0 ======

// --- THEME TOGGLE LOGIC ---
const htmlEl = document.documentElement;
const themeIcon = document.getElementById('theme-icon');
const savedTheme = localStorage.getItem('theme') || 'dark';

htmlEl.setAttribute('data-theme', savedTheme);

document.addEventListener('DOMContentLoaded', function() {
    updateIcon(savedTheme);
});

function toggleTheme() {
    const currentTheme = htmlEl.getAttribute('data-theme');
    const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
    htmlEl.setAttribute('data-theme', newTheme);
    localStorage.setItem('theme', newTheme);
    updateIcon(newTheme);
}

function updateIcon(theme) {
    const icon = document.getElementById('theme-icon');
    if (!icon) return;
    if (theme === 'light') {
        icon.classList.remove('fa-sun');
        icon.classList.add('fa-moon'); 
    } else {
        icon.classList.remove('fa-moon');
        icon.classList.add('fa-sun'); 
    }
}

// --- SIDEBAR TOGGLE ---
function toggleSidebar() {
    const sidebar = document.getElementById('sidebar');
    const overlay = document.querySelector('.overlay');
    if (sidebar && overlay) {
        sidebar.classList.toggle('active');
        overlay.classList.toggle('active');
    }
}

// Close sidebar with Escape key
document.addEventListener('keydown', function(e) {
    if (e.key === 'Escape') {
        const sidebar = document.getElementById('sidebar');
        const overlay = document.querySelector('.overlay');
        if (sidebar && sidebar.classList.contains('active')) {
            sidebar.classList.remove('active');
            overlay.classList.remove('active');
        }
    }
});

// --- LOAD BLOG FEED ---
const RSS_URL = 'https://blog.6ickzone.site/feed'; 
const API_ENDPOINT = `https://api.rss2json.com/v1/api.json?rss_url=${encodeURIComponent(RSS_URL)}`;

async function loadBlogFeed() {
    const container = document.getElementById('blog-feed-container');
    if (!container) return;

    try {
        const response = await fetch(API_ENDPOINT);
        const data = await response.json();
        
        if (data.status === 'ok' && data.items && data.items.length > 0) {
            container.innerHTML = ''; 
            data.items.slice(0, 6).forEach(item => {
                let cleanDesc = item.description.replace(/<[^>]*>?/gm, '');
                let excerpt = cleanDesc.substring(0, 90) + '...';
                let pubDate = item.pubDate ? item.pubDate.split(' ')[0] : 'Recent';

                const card = `
                    <div class="feed-card">
                        <div class="card-body">
                            <div class="card-meta mono">${pubDate}</div>
                            <h3 class="card-title">${item.title}</h3>
                            <p class="card-excerpt">${excerpt}</p>
                            <a href="${item.link}" target="_blank" class="read-more-btn">Read Investigation <i class="fa-solid fa-arrow-right-long"></i></a>
                        </div>
                    </div>
                `;
                container.innerHTML += card;
            });
        } else {
            container.innerHTML = '<p style="color:var(--text-muted); text-align:center; padding:20px;">No intelligence data available.</p>';
        }
    } catch (error) {
        console.error('Feed Error:', error);
        container.innerHTML = `
            <div class="feed-card" style="padding:20px; border-color:rgba(248, 81, 73, 0.4)">
                <h3 class="card-title" style="color:#ff7b72">Connection Failed</h3>
                <p class="card-excerpt">Could not retrieve secure feed.</p>
                <a href="https://blog.6ickzone.site" class="read-more-btn">Manual Access</a>
            </div>
        `;
    }
}

// --- ROCKET LOADER (External Links) ---
document.addEventListener('click', function(e) {
    const link = e.target.closest('a');

    if (link && link.href) {
        const targetUrl = link.href;
        
        if (targetUrl.startsWith('#') || 
            targetUrl.startsWith('javascript:') || 
            targetUrl.startsWith('mailto:')) {
            return;
        }

        const isExternal = targetUrl.startsWith('http') && 
                          !targetUrl.includes(window.location.host);

        if (e.ctrlKey || e.metaKey) return;

        if (isExternal) {
            e.preventDefault();
            startLaunchSequence(targetUrl);
        }
    }
});

function startLaunchSequence(url) {
    const overlay = document.getElementById('loader-overlay');
    const countdownEl = document.getElementById('countdown');
    const urlDisplay = document.getElementById('dest-url');
    const rocketWrapper = document.querySelector('.rocket-wrapper');
    
    try {
        const parsedUrl = new URL(url);
        urlDisplay.innerText = parsedUrl.hostname;
    } catch(err) {
        urlDisplay.innerText = "External Link";
    }
    
    overlay.classList.add('active');
    rocketWrapper.classList.remove('rocket-launching');
    
    let timeLeft = 3;
    countdownEl.innerText = timeLeft;

    const timer = setInterval(() => {
        timeLeft--;
        
        if (timeLeft > 0) {
            countdownEl.innerText = timeLeft;
        } else if (timeLeft === 0) {
            countdownEl.innerText = "LAUNCH!";
            rocketWrapper.classList.add('rocket-launching');
        } else {
            clearInterval(timer);
            
            window.open(url, '_blank');

            setTimeout(() => {
                overlay.classList.remove('active');
                setTimeout(() => {
                    rocketWrapper.classList.remove('rocket-launching');
                    countdownEl.innerText = "3";
                }, 300);
            }, 1000);
        }
    }, 800);
}

// --- INIT ---
document.addEventListener('DOMContentLoaded', function() {
    loadBlogFeed();
    
    document.querySelector('.overlay')?.addEventListener('click', toggleSidebar);
});