Spaces:
Running
Running
| // Copy script functionality | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Initialize tooltips | |
| const tooltipTriggers = document.querySelectorAll('[data-tooltip]'); | |
| tooltipTriggers.forEach(trigger => { | |
| trigger.addEventListener('mouseenter', function() { | |
| const tooltip = document.createElement('div'); | |
| tooltip.className = 'absolute z-10 bg-gray-800 text-white text-xs px-2 py-1 rounded shadow-lg'; | |
| tooltip.textContent = this.getAttribute('data-tooltip'); | |
| this.appendChild(tooltip); | |
| this.addEventListener('mouseleave', function() { | |
| tooltip.remove(); | |
| }); | |
| }); | |
| }); | |
| // Copy script button | |
| const copyButtons = document.querySelectorAll('[data-copy-script]'); | |
| copyButtons.forEach(button => { | |
| button.addEventListener('click', function() { | |
| const scriptCode = this.previousElementSibling.textContent; | |
| navigator.clipboard.writeText(scriptCode).then(() => { | |
| const originalText = this.innerHTML; | |
| this.innerHTML = '<i data-feather="check"></i> Copied!'; | |
| feather.replace(); | |
| setTimeout(() => { | |
| this.innerHTML = originalText; | |
| feather.replace(); | |
| }, 2000); | |
| }); | |
| }); | |
| }); | |
| // Theme toggle functionality | |
| const themeToggle = document.getElementById('theme-toggle'); | |
| if (themeToggle) { | |
| themeToggle.addEventListener('click', function() { | |
| const html = document.documentElement; | |
| if (html.classList.contains('dark')) { | |
| html.classList.remove('dark'); | |
| localStorage.setItem('theme', 'light'); | |
| } else { | |
| html.classList.add('dark'); | |
| localStorage.setItem('theme', 'dark'); | |
| } | |
| }); | |
| } | |
| // Check for saved theme preference | |
| if (localStorage.getItem('theme') === 'light') { | |
| document.documentElement.classList.remove('dark'); | |
| } | |
| }); |