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 = `user@penguinos:~$ ${command.cmd}`; 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 = '
PenguinOS is now shutting down...
'; } }); } // 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}...`); }); }); });