-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
151 lines (132 loc) · 5 KB
/
script.js
File metadata and controls
151 lines (132 loc) · 5 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
// Filter functionality
document.addEventListener('DOMContentLoaded', function() {
const filterTabs = document.querySelectorAll('.filter-tab');
const mediaCards = document.querySelectorAll('.media-card');
filterTabs.forEach(tab => {
tab.addEventListener('click', function() {
const filter = this.getAttribute('data-filter');
// Update active tab
filterTabs.forEach(t => t.classList.remove('active'));
this.classList.add('active');
// Filter cards with animation
mediaCards.forEach((card, index) => {
const cardType = card.getAttribute('data-type');
if (filter === 'all' || cardType === filter) {
card.style.display = 'block';
card.style.animation = 'none';
setTimeout(() => {
card.style.animation = `scaleIn 0.4s ease-out ${index * 0.05}s both`;
}, 10);
} else {
card.style.display = 'none';
}
});
});
});
// Add smooth scroll behavior
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Add loading animation to form submission
const searchForm = document.querySelector('.search-form');
if (searchForm) {
searchForm.addEventListener('submit', function() {
const submitBtn = this.querySelector('.browse-btn');
if (submitBtn) {
submitBtn.innerHTML = `
<svg class="spinner" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10" opacity="0.25"></circle>
<path d="M12 2a10 10 0 0 1 10 10" opacity="0.75"></path>
</svg>
Loading...
`;
submitBtn.disabled = true;
}
});
}
// Add hover effect to media cards
mediaCards.forEach(card => {
card.addEventListener('mouseenter', function() {
this.style.zIndex = '10';
});
card.addEventListener('mouseleave', function() {
this.style.zIndex = '1';
});
});
// Lazy load images
const images = document.querySelectorAll('.preview-image');
const imageObserver = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const img = entry.target;
// img.style.opacity = '0';
img.style.transition = 'opacity 0.3s ease';
img.addEventListener('load', function() {
this.style.opacity = '1';
});
observer.unobserve(img);
}
});
});
images.forEach(img => imageObserver.observe(img));
// Add keyboard navigation
document.addEventListener('keydown', function(e) {
// Press '/' to focus on search input
if (e.key === '/' && !e.ctrlKey && !e.metaKey) {
e.preventDefault();
const input = document.getElementById('folder_path');
if (input) {
input.focus();
input.select();
}
}
});
// Add copy path functionality (optional enhancement)
const mediaNames = document.querySelectorAll('.media-name');
mediaNames.forEach(name => {
name.style.cursor = 'pointer';
name.title = name.textContent + ' (Click to copy)';
name.addEventListener('click', function() {
const text = this.textContent;
navigator.clipboard.writeText(text).then(() => {
// Show temporary feedback
const originalText = this.textContent;
this.textContent = '✓ Copied!';
this.style.color = '#10b981';
setTimeout(() => {
this.textContent = originalText;
this.style.color = '';
}, 1500);
}).catch(err => {
console.error('Failed to copy:', err);
});
});
});
});
// Add CSS for spinner animation
const style = document.createElement('style');
style.textContent = `
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
.spinner {
animation: spin 1s linear infinite;
width: 20px;
height: 20px;
}
.browse-btn:disabled {
opacity: 0.7;
cursor: not-allowed;
}
`;
document.head.appendChild(style);