document.addEventListener('DOMContentLoaded', function () { // Check URL parameters for custom views const urlParams = new URLSearchParams(window.location.search); const searchTags = urlParams.get('searchtags'); const linkList = document.getElementById('links-list'); const container = document.querySelector('.content-container'); // Always init Pinned Items logic (sorting and listeners) // This function is defined at the end of the file if (typeof initPinnedItems === 'function') { initPinnedItems(); } if (!linkList || !container) return; if (searchTags === 'todo') { initTodoView(linkList, container); } else if (searchTags === 'note') { initNoteView(linkList, container); } }); /** * Initialize the Google Tasks-like view */ function initTodoView(linkList, container) { document.body.classList.add('view-todo'); // Extract task data from existing DOM const rawLinks = Array.from(linkList.querySelectorAll('.link-outer')); const tasks = rawLinks.map(link => parseTaskFromLink(link)).filter(t => t !== null); // Create new Layout const wrapper = document.createElement('div'); wrapper.className = 'special-view-wrapper'; // 1. Sidebar const sidebar = document.createElement('div'); sidebar.className = 'todo-sidebar'; // Extract unique groups for the sidebar const groups = new Set(); tasks.forEach(t => { if (t.group) groups.add(t.group); }); const groupsList = Array.from(groups).map(g => `