-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
193 lines (160 loc) · 6.4 KB
/
script.js
File metadata and controls
193 lines (160 loc) · 6.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
document.addEventListener('DOMContentLoaded', function() {
const tabBtns = document.querySelectorAll('.tab-btn');
const tabContents = document.querySelectorAll('.tab-content');
const searchInput = document.getElementById('searchInput');
const notification = document.getElementById('notification');
tabBtns.forEach(btn => {
btn.addEventListener('click', () => {
const targetTab = btn.getAttribute('data-tab');
tabBtns.forEach(b => b.classList.remove('active'));
btn.classList.add('active');
tabContents.forEach(content => {
content.classList.remove('active');
if (content.id === targetTab) {
content.classList.add('active');
}
});
window.scrollTo({ top: 0, behavior: 'smooth' });
});
});
searchInput.addEventListener('input', function(e) {
const searchTerm = e.target.value.toLowerCase();
if (searchTerm === '') {
document.querySelectorAll('.tool-card, .step-card').forEach(card => {
card.style.display = '';
});
return;
}
document.querySelectorAll('.tool-card').forEach(card => {
const toolName = card.querySelector('h3') ? card.querySelector('h3').textContent.toLowerCase() : '';
const toolDesc = card.querySelector('.tool-desc') ? card.querySelector('.tool-desc').textContent.toLowerCase() : '';
const commands = Array.from(card.querySelectorAll('code'))
.map(code => code.textContent.toLowerCase())
.join(' ');
const notes = Array.from(card.querySelectorAll('.note-box'))
.map(note => note.textContent.toLowerCase())
.join(' ');
const matches = toolName.includes(searchTerm) ||
toolDesc.includes(searchTerm) ||
commands.includes(searchTerm) ||
notes.includes(searchTerm);
card.style.display = matches ? '' : 'none';
});
});
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -100px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
document.querySelectorAll('.tool-card, .step-card').forEach(card => {
card.style.opacity = '0';
card.style.transform = 'translateY(30px)';
card.style.transition = 'all 0.6s ease';
observer.observe(card);
});
document.querySelectorAll('.stat-item').forEach((item, index) => {
setTimeout(() => {
item.style.animation = 'fadeIn 0.6s ease forwards';
}, index * 100);
});
const searchForm = searchInput.parentElement;
searchInput.addEventListener('keydown', function(e) {
if (e.key === 'Enter') {
e.preventDefault();
}
});
});
function copyCommand(button) {
const commandBox = button.parentElement;
const code = commandBox.querySelector('code');
const textToCopy = code.textContent.trim();
navigator.clipboard.writeText(textToCopy).then(() => {
showNotification('Command copied successfully!');
const originalIcon = button.innerHTML;
button.innerHTML = '<i class="fas fa-check"></i>';
button.style.background = 'var(--neon-green)';
button.style.color = 'var(--dark-bg)';
setTimeout(() => {
button.innerHTML = originalIcon;
button.style.background = '';
button.style.color = '';
}, 2000);
}).catch(err => {
console.error('Copy failed:', err);
showNotification('Failed to copy command', true);
});
}
function showNotification(message, isError = false) {
const notification = document.getElementById('notification');
const messageSpan = notification.querySelector('span');
messageSpan.textContent = message;
if (isError) {
notification.style.background = 'linear-gradient(135deg, #ff4444 0%, #ff6b6b 100%)';
} else {
notification.style.background = 'linear-gradient(135deg, var(--neon-green) 0%, var(--neon-green-bright) 100%)';
}
notification.classList.add('show');
setTimeout(() => {
notification.classList.remove('show');
}, 3000);
}
document.addEventListener('keydown', function(e) {
if ((e.key === '/' || e.key === 'k') && e.ctrlKey) {
e.preventDefault();
document.getElementById('searchInput').focus();
}
if (e.key === 'Escape') {
document.getElementById('searchInput').blur();
document.getElementById('searchInput').value = '';
const event = new Event('input', { bubbles: true });
document.getElementById('searchInput').dispatchEvent(event);
}
});
document.querySelectorAll('.tool-card').forEach(card => {
card.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-8px) scale(1.01)';
});
card.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0) scale(1)';
});
});
let lastScrollTop = 0;
const navbar = document.querySelector('.tabs-container');
window.addEventListener('scroll', () => {
let scrollTop = window.pageYOffset || document.documentElement.scrollTop;
if (scrollTop > lastScrollTop && scrollTop > 100) {
navbar.style.transform = 'translateY(-100%)';
navbar.style.opacity = '0.9';
} else {
navbar.style.transform = 'translateY(0)';
navbar.style.opacity = '1';
}
lastScrollTop = scrollTop;
});
document.querySelectorAll('.command-box').forEach(box => {
box.addEventListener('click', function(e) {
if (e.target.tagName !== 'BUTTON' && e.target.tagName !== 'I') {
const copyBtn = this.querySelector('.copy-btn');
if (copyBtn) {
copyBtn.click();
}
}
});
});
const style = document.createElement('style');
style.textContent = `
.command-box {
cursor: pointer;
}
.command-box:active {
transform: scale(0.99);
}
`;
document.head.appendChild(style);