mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-10-27 16:02:05 +00:00
106 lines
3.5 KiB
JavaScript
106 lines
3.5 KiB
JavaScript
// Dark Mode Toggle with Persistence
|
|
const toggleCheckbox = document.getElementById('dark-mode-checkbox');
|
|
|
|
// Check for saved user preference
|
|
if (localStorage.getItem('dark-mode') === 'enabled') {
|
|
toggleCheckbox.checked = true;
|
|
document.body.classList.add('dark-mode');
|
|
}
|
|
|
|
toggleCheckbox.addEventListener('change', function() {
|
|
if (this.checked) {
|
|
document.body.classList.add('dark-mode');
|
|
localStorage.setItem('dark-mode', 'enabled');
|
|
} else {
|
|
document.body.classList.remove('dark-mode');
|
|
localStorage.setItem('dark-mode', 'disabled');
|
|
}
|
|
});
|
|
|
|
// Responsive Navbar Toggle
|
|
const menuToggle = document.querySelector('.menu-toggle');
|
|
const navLinks = document.querySelector('.nav-links');
|
|
|
|
if (menuToggle) {
|
|
menuToggle.addEventListener('click', () => {
|
|
navLinks.classList.toggle('active');
|
|
});
|
|
}
|
|
|
|
// Active Link Highlighting Based on Scroll
|
|
const sections = document.querySelectorAll('section');
|
|
const navLinksArray = document.querySelectorAll('.nav-links a');
|
|
|
|
window.addEventListener('scroll', () => {
|
|
let current = '';
|
|
|
|
sections.forEach(section => {
|
|
const sectionTop = section.offsetTop - 70;
|
|
if (pageYOffset >= sectionTop) {
|
|
current = section.getAttribute('id');
|
|
}
|
|
});
|
|
|
|
navLinksArray.forEach(link => {
|
|
link.classList.remove('active');
|
|
if (link.getAttribute('href') === `#${current}`) {
|
|
link.classList.add('active');
|
|
}
|
|
});
|
|
});
|
|
|
|
// Smooth Scroll for Older Browsers
|
|
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
|
|
anchor.addEventListener('click', function(e) {
|
|
e.preventDefault();
|
|
const target = document.querySelector(this.getAttribute('href'));
|
|
if (target) {
|
|
window.scrollTo({
|
|
top: target.offsetTop - 60, // Adjust for navbar height
|
|
behavior: 'smooth'
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
// Log when the page is loaded
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
document.querySelectorAll('[data-copy-target]').forEach((button) => {
|
|
const buttonText = button.querySelector('.copy-button-text');
|
|
const buttonIcon = button.querySelector('i');
|
|
const status = button.closest('.install-command-shell')?.querySelector('.install-copy-status');
|
|
|
|
button.addEventListener('click', async () => {
|
|
const targetId = button.getAttribute('data-copy-target');
|
|
const target = document.getElementById(targetId);
|
|
if (!target) return;
|
|
|
|
const text = target.textContent.trim();
|
|
|
|
try {
|
|
await navigator.clipboard.writeText(text);
|
|
} catch (_err) {
|
|
const temp = document.createElement('textarea');
|
|
temp.value = text;
|
|
document.body.appendChild(temp);
|
|
temp.select();
|
|
document.execCommand('copy');
|
|
document.body.removeChild(temp);
|
|
}
|
|
|
|
button.classList.add('copied');
|
|
if (buttonText) buttonText.textContent = 'Copied';
|
|
if (buttonIcon) buttonIcon.className = 'fas fa-check';
|
|
if (status) status.textContent = 'Install command copied to clipboard.';
|
|
setTimeout(() => {
|
|
button.classList.remove('copied');
|
|
if (buttonText) buttonText.textContent = 'Copy';
|
|
if (buttonIcon) buttonIcon.className = 'fas fa-copy';
|
|
if (status) status.textContent = '';
|
|
}, 1800);
|
|
});
|
|
});
|
|
|
|
console.log('SeedPass landing page loaded');
|
|
});
|