document.addEventListener('DOMContentLoaded', function() {
    // 1. Filter Bar Logic
    const filterBtns = document.querySelectorAll('.wcp-filter-btn');
    const cards = document.querySelectorAll('.wcp-card');
    filterBtns.forEach(btn => {
        btn.addEventListener('click', function() {
            filterBtns.forEach(b => b.classList.remove('active'));
            this.classList.add('active');
            const filter = this.getAttribute('data-filter');
            cards.forEach(card => {
                card.style.display = (filter === 'all' || card.getAttribute('data-type') === filter) ? 'flex' : 'none';
            });
        });
    });

    // 2. Terms Modal
    const modal = document.getElementById('wcp-terms-modal');
    const termsBtns = document.querySelectorAll('.wcp-terms-btn');
    const closeBtn = document.querySelector('.wcp-modal-close');
    const modalText = document.getElementById('wcp-modal-terms-text');
    termsBtns.forEach(btn => {
        btn.addEventListener('click', function() {
            modalText.innerText = this.getAttribute('data-terms');
            modal.style.display = 'block';
        });
    });
    if (closeBtn) closeBtn.addEventListener('click', () => { modal.style.display = 'none'; });
    window.addEventListener('click', (e) => { if (e.target === modal) modal.style.display = 'none'; });

    // ==========================================
    // 3. STATISTICS TRACKING & COPY LOGIC
    // ==========================================
    if (typeof wcp_ajax !== 'undefined') {
        // Track Views using Intersection Observer
        const observer = new IntersectionObserver((entries) => {
            entries.forEach(entry => {
                if (entry.isIntersecting) {
                    const couponId = entry.target.dataset.couponId;
                    if (couponId && !entry.target.dataset.viewTracked) {
                        entry.target.dataset.viewTracked = 'true';
                        jQuery.post(wcp_ajax.ajax_url, {
                            action: 'wcp_track_view',
                            coupon_id: couponId,
                            nonce: wcp_ajax.nonce
                        });
                    }
                }
            });
        }, { threshold: 0.3 });

        document.querySelectorAll('.wcp-card, .wcp-list-item').forEach(card => {
            observer.observe(card);
        });

        // Track Clicks & Handle Copy on "Get Deal" or "Copy" buttons
        document.querySelectorAll('.wcp-get-deal-btn, .wcp-copy-btn-inline').forEach(btn => {
            btn.addEventListener('click', function() {
                const card = this.closest('.wcp-card, .wcp-list-item');
                const couponId = card ? card.dataset.couponId : null;
                
                // Track the click
                if (couponId) {
                    jQuery.post(wcp_ajax.ajax_url, {
                        action: 'wcp_track_click',
                        coupon_id: couponId,
                        nonce: wcp_ajax.nonce
                    });
                }
                
                // Handle copy logic if it's the copy button
                if (this.classList.contains('wcp-copy-btn-inline')) {
                    const code = this.getAttribute('data-code');
                    if (navigator.clipboard && navigator.clipboard.writeText) {
                        navigator.clipboard.writeText(code).then(() => showCopiedState(this)).catch(() => fallbackCopy(code, this));
                    } else {
                        fallbackCopy(code, this);
                    }
                }
            });
        });
    }
});

// Fallback copy for older browsers or non-HTTPS sites
function fallbackCopy(text, btn) {
    const textarea = document.createElement('textarea'); 
    textarea.value = text; 
    textarea.style.position = 'fixed'; 
    textarea.style.opacity = 0;
    document.body.appendChild(textarea); 
    textarea.select();
    try { 
        document.execCommand('copy'); 
        showCopiedState(btn); 
    } catch (err) { 
        console.error('Fallback copy failed', err); 
    }
    document.body.removeChild(textarea);
}

function showCopiedState(btn) {
    const originalHTML = btn.innerHTML;
    btn.innerHTML = '<span class="wcp-copy-icon">✅</span> Copied!'; 
    btn.classList.add('copied');
    setTimeout(() => { 
        btn.innerHTML = originalHTML; 
        btn.classList.remove('copied'); 
    }, 2000);
}<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/wp-content/plugins/squirrly-seo/view/assets/css/sitemap.xsl"?>
<!-- generated-on="2026-06-07T12:47:53+00:00" -->
<!-- generator="Squirrly SEO Sitemap" -->
<!-- generator-url="https://wordpress.org/plugins/squirrly-seo/" -->

<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<url>
		<loc>https://www.androidpimp.com/x86-sbcs/</loc>
		<lastmod>2025-08-29T15:59:20+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/wireless-routers/</loc>
		<lastmod>2025-05-08T07:12:48+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/remote-controls/</loc>
		<lastmod>2023-09-29T17:18:00+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/wireless-earbuds-earphones/</loc>
		<lastmod>2023-03-17T03:59:00+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/display-adapter/</loc>
		<lastmod>2021-12-12T18:45:00+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/wearables/</loc>
		<lastmod>2025-02-26T19:47:53+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/uncategorized-he/</loc>
		<lastmod>2025-04-13T06:50:11+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/tablet-pc/</loc>
		<lastmod>2025-09-26T06:42:05+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/streaming-device/</loc>
		<lastmod>2020-06-17T06:32:45+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/speakers/</loc>
		<lastmod>2024-10-01T23:51:00+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/software/</loc>
		<lastmod>2024-11-28T07:24:22+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/smart-home-devices/</loc>
		<lastmod>2021-08-08T03:59:00+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/raspberry-pi/</loc>
		<lastmod>2019-06-24T21:02:08+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/projectors/</loc>
		<lastmod>2024-10-15T19:21:05+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/product-news/</loc>
		<lastmod>2026-02-06T21:23:59+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/phone-news/</loc>
		<lastmod>2025-08-30T08:10:03+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/mobile-phones/</loc>
		<lastmod>2026-02-02T14:53:24+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/mini-pc/</loc>
		<lastmod>2025-09-25T14:15:57+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/led-lamps/</loc>
		<lastmod>2023-01-11T11:52:00+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/fast-charging-power-adapters/</loc>
		<lastmod>2025-11-18T17:55:11+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/embedded/</loc>
		<lastmod>2026-06-04T16:35:12+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/electronic-gadgets/</loc>
		<lastmod>2018-09-29T14:37:34+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/edge-ai-hardware/</loc>
		<lastmod>2026-02-26T15:12:06+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/diy-projects/</loc>
		<lastmod>2021-07-01T00:35:00+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/computer-accessories/</loc>
		<lastmod>2025-10-03T15:33:38+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/cameras/</loc>
		<lastmod>2015-08-27T15:47:21+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/best-deals/</loc>
		<lastmod>2026-03-13T12:56:21+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/backup-security-testing/</loc>
		<lastmod>2026-02-18T09:58:33+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/android-tv-dongles/</loc>
		<lastmod>2025-07-26T15:01:36+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/tv-boxes/</loc>
		<lastmod>2025-12-06T15:09:56+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
	<url>
		<loc>https://www.androidpimp.com/addon-boards/</loc>
		<lastmod>2025-04-14T12:30:59+00:00</lastmod>
		<changefreq>weekly</changefreq>
		<priority>0.5</priority>
	</url>
</urlset>