-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
47 lines (41 loc) · 1.71 KB
/
Copy pathscript.js
File metadata and controls
47 lines (41 loc) · 1.71 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
document.addEventListener('DOMContentLoaded', () => {
// Tab switching logic
const tabBtns = document.querySelectorAll('.tab-btn');
const tabContents = document.querySelectorAll('.tab-content');
tabBtns.forEach(btn => {
btn.addEventListener('click', () => {
// Remove active class from all buttons and contents
tabBtns.forEach(b => b.classList.remove('active'));
tabContents.forEach(c => c.classList.remove('active'));
// Add active class to clicked button and its target content
btn.classList.add('active');
const targetId = btn.getAttribute('data-target');
document.getElementById(targetId).classList.add('active');
});
});
});
// Language Switcher Logic
function setLang(lang) {
// Hide all language elements
document.querySelectorAll('.lang-en, .lang-ru, .lang-zh').forEach(el => {
el.style.display = 'none';
});
// Show selected language elements
document.querySelectorAll('.lang-' + lang).forEach(el => {
// Use inline-block for buttons and spans, block for others
if (el.tagName === 'A' || el.tagName === 'SPAN' || el.tagName === 'B') {
el.style.display = 'inline-block';
} else {
el.style.display = 'block';
}
});
// Update active button
document.querySelectorAll('.lang-btn').forEach(btn => {
btn.classList.remove('active');
});
// Find the button that called this
const btns = document.querySelectorAll('.lang-btn');
if (lang === 'en') btns[0].classList.add('active');
if (lang === 'ru') btns[1].classList.add('active');
if (lang === 'zh') btns[2].classList.add('active');
}