File size: 2,799 Bytes
c9326cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Shared JavaScript across all pages
console.log('Rusty Fortune Casino loaded');

// Real-time jackpot counter animation
function animateJackpotCounter() {
    const jackpotElement = document.querySelector('.jackpot-amount');
    if (jackpotElement) {
        let currentValue = 148.14;
        const targetValue = 200.00;
        const duration = 5000;
        const steps = 60;
        const stepValue = (targetValue - currentValue) / steps;
        let step = 0;
        
        const counter = setInterval(() => {
            if (step >= steps) {
                clearInterval(counter);
                return;
            }
            currentValue += stepValue;
            jackpotElement.textContent = `$${currentValue.toFixed(2)}`;
            step++;
        }, duration / steps);
    }
}

// Chat auto-scroll
function scrollChatToBottom() {
    const chatContainer = document.querySelector('.custom-scrollbar');
    if (chatContainer) {
        chatContainer.scrollTop = chatContainer.scrollHeight;
}

// Flash giveaway countdown
function startFlashGiveawayCountdown() {
    const giveawayElement = document.querySelector('.flash-giveaway-timer');
    if (giveawayElement) {
        let seconds = 30;
        const timer = setInterval(() => {
            if (seconds <= 0) {
                clearInterval(timer);
                giveawayElement.textContent = 'Starting now!';
            } else {
                giveawayElement.textContent = `Starting in ${seconds} seconds...`;
            seconds--;
        }, 1000);
    }
}

// Initialize when DOM is loaded
document.addEventListener('DOMContentLoaded', function() {
    animateJackpotCounter();
    scrollChatToBottom();
    startFlashGiveawayCountdown();
    
    // Add hover effects to game cards
    const gameCards = document.querySelectorAll('.game-card');
    gameCards.forEach(card => {
        card.addEventListener('mouseenter', () => {
            card.classList.add('hover-glow');
        });
        card.addEventListener('mouseleave', () => {
            card.classList.remove('hover-glow');
        });
    });
});

// API integration for live data (placeholder)
async function fetchJackpotData() {
    try {
        // In a real implementation, this would fetch from RustyPot API
        const mockData = {
            currentPot: 148.14,
            participants: 16,
            maxParticipants: 200,
            timeRemaining: 120
        };
        
        // Update UI with real data
        console.log('Jackpot data fetched:', mockData);
    } catch (error) {
        console.error('Error fetching jackpot data:', error);
    }
}

// Export functions for use in other modules
window.RustyFortune = {
    animateJackpotCounter,
    scrollChatToBottom,
    startFlashGiveawayCountdown,
    fetchJackpotData
};