File size: 1,809 Bytes
ca76193
 
 
 
 
 
 
 
 
 
 
 
 
36002a8
ca76193
36002a8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

// Request notification permission on page load
document.addEventListener('DOMContentLoaded', async () => {
    // Request notification permission
    if ('Notification' in window) {
        try {
            const permission = await Notification.requestPermission();
            console.log('Notification permission:', permission);
        } catch (err) {
            console.error('Notification permission error:', err);
        }
    }

    // Theme toggle
const themeToggle = document.getElementById('theme-toggle');
    themeToggle.addEventListener('click', () => {
        document.documentElement.classList.toggle('dark');
        const icon = themeToggle.querySelector('i');
        if (document.documentElement.classList.contains('dark')) {
            feather.icons['moon'].toSvg().then(svg => icon.innerHTML = svg);
        } else {
            feather.icons['sun'].toSvg().then(svg => icon.innerHTML = svg);
        }
    });

    // Add column button
    const addColumnBtn = document.getElementById('add-column');
    const orderBoard = document.getElementById('order-board');
    
    addColumnBtn.addEventListener('click', () => {
        const columnName = prompt('Enter order type name:');
        if (columnName) {
            const column = document.createElement('order-column');
            column.setAttribute('title', columnName);
            orderBoard.appendChild(column);
        }
    });

    // Initialize with default columns if empty
    if (orderBoard.children.length === 0) {
        const defaultColumns = ['Order', 'Order Completed', 'Order Paid'];
        defaultColumns.forEach(title => {
            const column = document.createElement('order-column');
            column.setAttribute('title', title);
            orderBoard.appendChild(column);
        });
    }
});