-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
78 lines (71 loc) · 2.8 KB
/
script.js
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
document.addEventListener('DOMContentLoaded', function() {
// Work item toggle functionality
const workItems = document.querySelectorAll('.work-list .work-item');
workItems.forEach(item => {
const header = item.querySelector('.work-item-header');
header.addEventListener('click', () => {
item.classList.toggle('active');
});
});
// Command menu functionality
const commandMenu = document.getElementById('command-menu');
const searchInput = commandMenu.querySelector('input');
// Toggle command menu on Cmd+J or Ctrl+J
document.addEventListener('keydown', function(event) {
if (event.key === 'j' && (event.metaKey || event.ctrlKey)) {
event.preventDefault();
commandMenu.classList.toggle('hidden');
if (!commandMenu.classList.contains('hidden')) {
searchInput.focus();
}
}
});
// Close menu when clicking the close button
const closeButton = commandMenu.querySelector('.close-button');
closeButton.addEventListener('click', function() {
commandMenu.classList.add('hidden');
});
// Close menu when clicking outside
document.addEventListener('click', function(event) {
if (!commandMenu.contains(event.target) && !commandMenu.classList.contains('hidden')) {
commandMenu.classList.add('hidden');
}
});
// Handle menu item clicks
const menuItems = commandMenu.querySelectorAll('.menu-item');
menuItems.forEach(item => {
item.addEventListener('click', function(e) {
if (this.dataset.action === 'print') {
e.preventDefault();
window.print();
}
commandMenu.classList.add('hidden');
});
});
// Search functionality
searchInput.addEventListener('input', function() {
const filter = this.value.toLowerCase();
menuItems.forEach(item => {
const text = item.textContent.toLowerCase();
const section = item.closest('.section');
if (text.includes(filter)) {
item.style.display = '';
section.style.display = '';
} else {
item.style.display = 'none';
if ([...section.querySelectorAll('.menu-item')].every(i => i.style.display === 'none')) {
section.style.display = 'none';
}
}
});
});
// Email functionality
const emailLink = document.querySelector('a[aria-label="Email"]');
if (emailLink) {
emailLink.addEventListener('click', function(e) {
e.preventDefault();
const email = 'your.email' + '@' + 'example.com'; // Replace with your actual email
window.location.href = 'mailto:' + email;
});
}
});