-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs.js
More file actions
62 lines (57 loc) · 2.03 KB
/
Copy pathdocs.js
File metadata and controls
62 lines (57 loc) · 2.03 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
// docs.js - Funcionalidad de idioma y scroll para TabCost docs
(function() {
// Get elements
const enContent = document.getElementById('content-en');
const esContent = document.getElementById('content-es');
const footnoteSpan = document.getElementById('footnote')?.querySelector('span');
const langBtns = document.querySelectorAll('.lang-btn');
// Default language: English
let currentLang = localStorage.getItem('tabcost_docs_lang') || 'en';
function setLanguage(lang) {
if (!enContent || !esContent) return;
if (lang === 'en') {
enContent.style.display = 'block';
esContent.style.display = 'none';
if (footnoteSpan) {
footnoteSpan.innerHTML = 'Version 1.5.3 · Last update: May 2026 · TabCost does not store or transmit any personal data. Everything is local.';
}
document.documentElement.lang = 'en';
} else {
enContent.style.display = 'none';
esContent.style.display = 'block';
if (footnoteSpan) {
footnoteSpan.innerHTML = 'Versión 1.5.3 · Última actualización: mayo 2026 · TabCost no almacena ni transmite ningún dato personal. Todo es local.';
}
document.documentElement.lang = 'es';
}
// Update active class on buttons
langBtns.forEach(btn => {
if (btn.getAttribute('data-lang') === lang) {
btn.classList.add('active');
} else {
btn.classList.remove('active');
}
});
localStorage.setItem('tabcost_docs_lang', lang);
currentLang = lang;
}
// Add click handlers
langBtns.forEach(btn => {
btn.addEventListener('click', (e) => {
const lang = btn.getAttribute('data-lang');
if (lang !== currentLang) {
setLanguage(lang);
}
});
});
// Initialize with saved language
setLanguage(currentLang);
// Smooth scroll to top
const backToTop = document.querySelector('.back-to-top');
if (backToTop) {
backToTop.addEventListener('click', (e) => {
e.preventDefault();
window.scrollTo({ top: 0, behavior: 'smooth' });
});
}
})();