From 7da034e08b1f27220609f0b5ff45a2cba2090ea7 Mon Sep 17 00:00:00 2001 From: Logen <79722764+btcforplebs@users.noreply.github.com> Date: Fri, 26 Sep 2025 21:29:41 -0400 Subject: [PATCH] tweaks --- public/assets/js/scripts.js | 115 ++++++++++-------------------- public/index.html | 29 ++++++-- public/learn-bitcoin/index.html | 16 +++-- public/learn-bitcoin/nodes.html | 13 +++- public/learn-bitcoin/wallets.html | 13 +++- public/learn-cashu/index.html | 12 ++++ public/learn-nostr/index.html | 12 +++- public/parts/footer.html | 57 ++++++++++++++- 8 files changed, 174 insertions(+), 93 deletions(-) diff --git a/public/assets/js/scripts.js b/public/assets/js/scripts.js index e9a7a58..ea95647 100644 --- a/public/assets/js/scripts.js +++ b/public/assets/js/scripts.js @@ -1,105 +1,64 @@ -// Folder Toggle Function -document.addEventListener('DOMContentLoaded', () => { - function toggleFolder(folderId, buttonId) { - const folder = document.getElementById(folderId); - const button = document.getElementById(buttonId); +// public/assets/js/scripts.js +// --------------------------------------------- +// 1. Global toggle function – now accessible from the HTML onclick +// 2. Properly closed DOMContentLoaded +// 3. Minor style helper (display toggling) +// --------------------------------------------- - // Close other folders and deactivate buttons - document.querySelectorAll('.links').forEach(link => { - if (link.id !== folderId) { - link.style.display = 'none'; - } - }); - document.querySelectorAll('.button').forEach(btn => { - if (btn.id !== buttonId) { - btn.classList.remove('active'); - } - }); - // Toggle the selected folder - if (folder.style.display === 'block') { - folder.style.display = 'none'; - button.classList.remove('active'); - } else { - folder.style.display = 'block'; - button.classList.add('active'); - } -} -function navigateToSection(select) { - const sectionId = select.value; - if (sectionId) { - document.getElementById(sectionId).scrollIntoView({ behavior: 'smooth' }); - } -} - - // Function to prefetch a URL - function prefetch(url) { - const link = document.createElement('link'); - link.rel = 'prefetch'; - link.href = url; - document.head.appendChild(link); -} - - // Add event listeners to your links - const links = document.querySelectorAll('a.prefetch'); - -links.forEach(link => { - link.addEventListener('mouseenter', () => { - const url = link.href; // Get the link URL - prefetch(url); // Call prefetch function - }); -}); - - // Footer Loader and Event Listeners + // --- 4. Load Footer and QR Code Toggle Logic ---------------------------- fetch('/parts/footer.html') .then(response => response.text()) .then(data => { - document.getElementById('footer').innerHTML = data; + const footer = document.getElementById('footer'); + if (!footer) return; + + footer.innerHTML = data; - // Attach event listeners after footer is loaded const onChainButton = document.getElementById('onChainButton'); const lightningButton = document.getElementById('lightningButton'); const qrCodes = document.getElementById('qrCodes'); const onChainQRCode = document.getElementById('onChainQRCode'); const lightningQRCode = document.getElementById('lightningQRCode'); - // Initially hide the QR codes section - qrCodes.style.display = 'none'; + if (qrCodes) qrCodes.style.display = 'none'; - onChainButton.addEventListener('click', function () { - // Toggle visibility of On-Chain QR Code - const isOnChainVisible = onChainQRCode.style.display === 'block'; - qrCodes.style.display = 'block'; // Show QR codes section - onChainQRCode.style.display = isOnChainVisible ? 'none' : 'block'; // Toggle On-Chain - lightningQRCode.style.display = 'none'; // Hide Lightning QR code - }); + if (onChainButton && lightningButton && qrCodes && onChainQRCode && lightningQRCode) { + onChainButton.addEventListener('click', function () { + const isOnChainVisible = onChainQRCode.style.display === 'block'; + qrCodes.style.display = 'block'; + onChainQRCode.style.display = isOnChainVisible ? 'none' : 'block'; + lightningQRCode.style.display = 'none'; + }); - lightningButton.addEventListener('click', function () { - // Toggle visibility of Lightning QR Code - const isLightningVisible = lightningQRCode.style.display === 'block'; - qrCodes.style.display = 'block'; // Show QR codes section - lightningQRCode.style.display = isLightningVisible ? 'none' : 'block'; // Toggle Lightning - onChainQRCode.style.display = 'none'; // Hide On-Chain QR code - }); + lightningButton.addEventListener('click', function () { + const isLightningVisible = lightningQRCode.style.display === 'block'; + qrCodes.style.display = 'block'; + lightningQRCode.style.display = isLightningVisible ? 'none' : 'block'; + onChainQRCode.style.display = 'none'; + }); + } }) .catch(error => console.error('Error loading footer:', error)); + // --- 5. Fetch and Display Last Update from GitHub ----------------------- fetch('https://api.github.com/repos/btcforplebs/BTCforPlebs.com/commits/main') .then(response => response.json()) .then(data => { - const lastUpdate = new Date(data.commit.author.date); // Commit date + const lastUpdate = new Date(data.commit.author.date); const formattedDate = lastUpdate.toLocaleDateString(); const formattedTime = lastUpdate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); - // Update the text content of the last-updated-text element - document.getElementById('last-updated-text').textContent = `Website last updated: ${formattedDate} ${formattedTime}`; + const updateText = document.getElementById('last-updated-text'); + if (updateText) { + updateText.textContent = `Website last updated: ${formattedDate} ${formattedTime}`; + } }) .catch(error => { console.error('Error fetching last update:', error); - document.getElementById('last-updated-text').textContent = 'Last update: Error fetching data.'; - }); - - -}); - + const updateText = document.getElementById('last-updated-text'); + if (updateText) { + updateText.textContent = 'Last update: Error fetching data.'; + } + }); \ No newline at end of file diff --git a/public/index.html b/public/index.html index 34baaf5..02a81fe 100644 --- a/public/index.html +++ b/public/index.html @@ -17,8 +17,8 @@ - + @@ -40,32 +40,47 @@ BTCforPlebs Live

- + + + diff --git a/public/learn-bitcoin/index.html b/public/learn-bitcoin/index.html index bf5a12d..bb12fac 100644 --- a/public/learn-bitcoin/index.html +++ b/public/learn-bitcoin/index.html @@ -190,11 +190,19 @@ + -
🔝 - - - + \ No newline at end of file diff --git a/public/learn-bitcoin/nodes.html b/public/learn-bitcoin/nodes.html index 7f33e58..acbf3e3 100644 --- a/public/learn-bitcoin/nodes.html +++ b/public/learn-bitcoin/nodes.html @@ -51,5 +51,16 @@ 🔝
- + + diff --git a/public/learn-bitcoin/wallets.html b/public/learn-bitcoin/wallets.html index 820c8ac..b737561 100644 --- a/public/learn-bitcoin/wallets.html +++ b/public/learn-bitcoin/wallets.html @@ -45,5 +45,16 @@ 🔝 - + + \ No newline at end of file diff --git a/public/learn-cashu/index.html b/public/learn-cashu/index.html index 70749a1..6fa7e02 100644 --- a/public/learn-cashu/index.html +++ b/public/learn-cashu/index.html @@ -107,5 +107,17 @@ 🔝 + + diff --git a/public/learn-nostr/index.html b/public/learn-nostr/index.html index 8e8c7ca..df5f29b 100644 --- a/public/learn-nostr/index.html +++ b/public/learn-nostr/index.html @@ -48,7 +48,17 @@ 🔝 - + diff --git a/public/parts/footer.html b/public/parts/footer.html index 91f6dcf..6a7cbf5 100644 --- a/public/parts/footer.html +++ b/public/parts/footer.html @@ -1,6 +1,61 @@