File size: 5,580 Bytes
8a68258
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9a1e72b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8a68258
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
document.addEventListener('DOMContentLoaded', function() {
    // Simulate system stats updates
    function updateSystemStats() {
        const stats = [
            { selector: '.cpu-usage', min: 5, max: 40 },
            { selector: '.memory-usage', min: 2, max: 7 },
            { selector: '.network-speed', min: 5, max: 25 }
        ];
        
        stats.forEach(stat => {
            const element = document.querySelector(stat.selector);
            if (element) {
                const value = Math.floor(Math.random() * (stat.max - stat.min + 1)) + stat.min;
                element.textContent = `${value}${stat.selector === '.network-speed' ? 'Mbps' : '%'}`;
            }
        });
    }
    
    // Update stats every 3 seconds
    setInterval(updateSystemStats, 3000);
    updateSystemStats();
    
    // Terminal simulation
    const terminalElement = document.querySelector('.terminal');
    if (terminalElement) {
        const commands = [
            { cmd: 'ls -la', output: 'total 48\ndrwxr-xr-x 5 user user  4096 Dec 10 14:30 .\ndrwxr-xr-x 3 root root  4096 Nov 28 09:15 ..\n-rw------- 1 user user  1352 Dec  9 16:42 .bash_history\n-rw-r--r-- 1 user user   220 Nov 28 09:15 .bash_logout\n-rw-r--r-- 1 user user  3771 Nov 28 09:15 .bashrc\ndrwx------ 3 user user  4096 Dec  1 11:20 .cache\ndrwx------ 3 user user  4096 Dec  1 11:20 .config\n-rw-r--r-- 1 user user   807 Nov 28 09:15 .profile\n-rw-r--r-- 1 user user     0 Dec  3 17:55 .sudo_as_admin_successful' },
            { cmd: 'uname -a', output: 'Linux penguinOS 5.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux' },
            { cmd: 'free -h', output: '              total        used        free      shared  buff/cache   available\nMem:           7.7Gi       3.2Gi       2.1Gi       345Mi       2.4Gi       4.0Gi\nSwap:          2.0Gi       0.0Ki       2.0Gi' }
        ];
        
        let currentCommand = 0;
        
        function typeWriter(text, element, speed, callback) {
            let i = 0;
            function typing() {
                if (i < text.length) {
                    element.innerHTML += text.charAt(i);
                    i++;
                    setTimeout(typing, speed);
                } else if (callback) {
                    callback();
                }
            }
            typing();
        }
        
        function runNextCommand() {
            if (currentCommand < commands.length) {
                const command = commands[currentCommand];
                const commandLine = document.createElement('div');
                commandLine.className = 'command-line';
                commandLine.innerHTML = `<span class="prompt">user@penguinos:~$</span> <span class="command">${command.cmd}</span>`;
                terminalElement.appendChild(commandLine);
                
                setTimeout(() => {
                    const output = document.createElement('div');
                    output.className = 'command-output';
                    terminalElement.appendChild(output);
                    typeWriter(command.output, output, 10, () => {
                        currentCommand++;
                        setTimeout(runNextCommand, 1000);
                    });
                }, 500);
            }
        }
        
        runNextCommand();
    }
    // Toggle sidebar on mobile
    const menuButton = document.querySelector('[data-feather="menu"]');
    if (menuButton) {
        menuButton.addEventListener('click', function() {
            const sidebar = document.querySelector('.w-64');
            sidebar.classList.toggle('hidden');
            sidebar.classList.toggle('block');
        });
    }

    // Notification button functionality
    const notificationsBtn = document.getElementById('notifications-btn');
    if (notificationsBtn) {
        notificationsBtn.addEventListener('click', function() {
            alert('No new notifications');
        });
    }

    // Messages button functionality
    const messagesBtn = document.getElementById('messages-btn');
    if (messagesBtn) {
        messagesBtn.addEventListener('click', function() {
            alert('Message system coming soon!');
        });
    }

    // Power button functionality
    const powerBtn = document.getElementById('power-btn');
    if (powerBtn) {
        powerBtn.addEventListener('click', function() {
            if (confirm('Are you sure you want to shut down PenguinOS?')) {
                alert('System shutting down...');
                // In a real app, this would trigger an actual shutdown
                document.body.innerHTML = '<div class="flex items-center justify-center h-screen bg-black text-white text-2xl">PenguinOS is now shutting down...</div>';
            }
        });
    }

    // Make sidebar links functional
    const sidebarLinks = document.querySelectorAll('.w-64 nav a');
    sidebarLinks.forEach(link => {
        link.addEventListener('click', function(e) {
            e.preventDefault();
            const icon = this.querySelector('i');
            const appName = this.textContent.trim();
            alert(`Launching ${appName}...`);
        });
    });

    // Make quick access links functional
    const quickAccessLinks = document.querySelectorAll('.quick-access a');
    quickAccessLinks.forEach(link => {
        link.addEventListener('click', function(e) {
            e.preventDefault();
            const appName = this.querySelector('span').textContent;
            alert(`Opening ${appName}...`);
        });
    });
});