Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
157 lines (138 loc) · 5.23 KB
/
Copy pathscript.js
File metadata and controls
157 lines (138 loc) · 5.23 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
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const href = this.getAttribute('href');
if (href === '#top' || href === '#') {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
} else {
const target = document.querySelector(href);
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
}
// Close mobile menu after clicking a link
const navMenu = document.querySelector('.nav-menu');
const menuToggle = document.querySelector('.mobile-menu-toggle');
if (navMenu && menuToggle) {
navMenu.classList.remove('active');
menuToggle.classList.remove('active');
}
});
});
// Mobile menu toggle
document.addEventListener('DOMContentLoaded', () => {
const menuToggle = document.querySelector('.mobile-menu-toggle');
const navMenu = document.querySelector('.nav-menu');
if (menuToggle && navMenu) {
menuToggle.addEventListener('click', () => {
menuToggle.classList.toggle('active');
navMenu.classList.toggle('active');
});
// Close menu when clicking outside
document.addEventListener('click', (e) => {
if (!menuToggle.contains(e.target) && !navMenu.contains(e.target)) {
navMenu.classList.remove('active');
menuToggle.classList.remove('active');
}
});
}
});
// Navbar background on scroll
const navbar = document.querySelector('.navbar');
let lastScroll = 0;
window.addEventListener('scroll', () => {
const currentScroll = window.pageYOffset;
if (currentScroll > 50) {
navbar.style.boxShadow = '0 2px 8px rgba(0, 0, 0, 0.1)';
} else {
navbar.style.boxShadow = 'none';
}
lastScroll = currentScroll;
});
// Add animation on scroll for feature cards
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
// Observe all cards
document.addEventListener('DOMContentLoaded', () => {
const cards = document.querySelectorAll('.feature-card, .download-card, .why-card');
cards.forEach((card, index) => {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
card.style.transition = `all 0.6s ease ${index * 0.1}s`;
observer.observe(card);
});
});
// Download tracking (optional - for analytics)
document.querySelectorAll('.btn-download').forEach(button => {
button.addEventListener('click', (e) => {
const version = button.textContent.includes('CAT') ? 'CAT Edition' : 'Classic Edition';
console.log(`Download initiated: ${version}`);
// You can add Google Analytics or other tracking here
// Example: gtag('event', 'download', { version: version });
});
});
// Mobile menu toggle (for future implementation)
function toggleMobileMenu() {
const menu = document.querySelector('.nav-menu');
menu.classList.toggle('active');
}
// GitHub dropdown
document.addEventListener('DOMContentLoaded', () => {
const btn = document.getElementById('github-btn');
const menu = document.getElementById('github-menu');
const chevron = document.getElementById('github-chevron');
if (!btn || !menu) return;
btn.addEventListener('click', (e) => {
e.stopPropagation();
const open = menu.classList.toggle('open');
btn.setAttribute('aria-expanded', open);
if (chevron) chevron.style.transform = open ? 'rotate(180deg)' : '';
});
document.addEventListener('click', () => {
menu.classList.remove('open');
btn.setAttribute('aria-expanded', 'false');
if (chevron) chevron.style.transform = '';
});
});
// Console message for developers
console.log('%c🌐 Supervertaler Website', 'font-size: 20px; font-weight: bold; color: #3b82f6;');
console.log('%cBuilt with ❤️ for translators', 'font-size: 14px; color: #6b7280;');
console.log('%cRepository: https://github.com/Supervertaler/Supervertaler-Workbench', 'font-size: 12px; color: #8b5cf6;');
// Back to Top Button
document.addEventListener('DOMContentLoaded', () => {
const backToTopButton = document.getElementById('backToTop');
if (backToTopButton) {
// Show/hide button based on scroll position
window.addEventListener('scroll', () => {
if (window.pageYOffset > 300) {
backToTopButton.classList.add('show');
} else {
backToTopButton.classList.remove('show');
}
});
// Scroll to top when button is clicked
backToTopButton.addEventListener('click', () => {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
});
}
});