File size: 1,448 Bytes
abc8a56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
document.addEventListener('DOMContentLoaded', () => {
    // Initialize tool data
    const tools = [
        { icon: 'code', title: 'HTML Formatter', category: 'Developer' },
        { icon: 'image', title: 'Image Compressor', category: 'Media' },
        { icon: 'file-text', title: 'PDF to Word', category: 'Documents' },
        { icon: 'link', title: 'URL Shortener', category: 'Web' },
        { icon: 'lock', title: 'Password Generator', category: 'Security' },
        { icon: 'hash', title: 'Base64 Encoder', category: 'Developer' },
        { icon: 'calendar', title: 'Date Calculator', category: 'Utilities' },
        { icon: 'dollar-sign', title: 'Currency Converter', category: 'Finance' },
        // Add more tools as needed
    ];

    // Theme toggle functionality
    const themeToggle = document.getElementById('theme-toggle');
    if (themeToggle) {
        themeToggle.addEventListener('click', () => {
            document.documentElement.classList.toggle('dark');
            localStorage.setItem('theme', document.documentElement.classList.contains('dark') ? 'dark' : 'light');
        });
    }

    // Check for saved theme preference
    if (localStorage.getItem('theme') === 'dark' || (!localStorage.getItem('theme') && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
        document.documentElement.classList.add('dark');
    } else {
        document.documentElement.classList.remove('dark');
    }
});