Added the hacker space section
This commit is contained in:
parent
876cc5b5cd
commit
9681466082
5 changed files with 248 additions and 0 deletions
52
js/main.js
52
js/main.js
|
|
@ -331,4 +331,56 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
);
|
||||
}
|
||||
|
||||
// ── 18. HACKER SPACE COPY FUNCTIONALITY ────────────────────────────
|
||||
const copyBtns = document.querySelectorAll('.copy-btn');
|
||||
|
||||
copyBtns.forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
// Find the pre or code element within the same card
|
||||
const card = btn.closest('.space-card');
|
||||
const codeElement = card.querySelector('pre, code');
|
||||
|
||||
if (codeElement) {
|
||||
const textToCopy = codeElement.innerText;
|
||||
|
||||
navigator.clipboard.writeText(textToCopy).then(() => {
|
||||
const originalIcon = btn.innerHTML;
|
||||
|
||||
// Show success feedback
|
||||
btn.innerHTML = '<i class="fas fa-check"></i>';
|
||||
btn.classList.add('text-green-400');
|
||||
|
||||
setTimeout(() => {
|
||||
btn.innerHTML = originalIcon;
|
||||
btn.classList.remove('text-green-400');
|
||||
}, 2000);
|
||||
}).catch(err => {
|
||||
console.error('Failed to copy: ', err);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// ── 19. HACKER SPACE EXPAND FUNCTIONALITY ──────────────────────────
|
||||
const toggleBtns = document.querySelectorAll('.toggle-btn');
|
||||
|
||||
toggleBtns.forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
const card = btn.closest('.space-card');
|
||||
const wrapper = card.querySelector('.key-wrapper');
|
||||
const icon = btn.querySelector('i');
|
||||
const textSpan = btn.querySelector('span');
|
||||
|
||||
wrapper.classList.toggle('expanded');
|
||||
btn.classList.toggle('active');
|
||||
|
||||
if (wrapper.classList.contains('expanded')) {
|
||||
textSpan.textContent = 'Show Less';
|
||||
} else {
|
||||
textSpan.textContent = 'Show More';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue