-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
40 lines (33 loc) · 1.34 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
import { loadCertificates } from "./js/certificates.js";
window.onload = function () {
window.parent.postMessage(
{ type: "size", height: document.body.scrollHeight, width: document.body.scrollWidth },
"*"
);
};
document.addEventListener("DOMContentLoaded", () => {
const switchLangButton = document.getElementById("switch-lang");
// Function to toggle language elements based on the current language
const toggleLanguageElements = (lang) => {
document.querySelectorAll("[data-lang]").forEach((el) => {
el.hidden = el.getAttribute("data-lang") !== lang;
});
};
// Initialize the button text based on the current language
const updateButtonText = (lang) => {
switchLangButton.textContent = lang === "en" ? "Przełącz na PL" : "Switch to EN";
};
// Set the initial button text and get the current language
let currentLang = switchLangButton.getAttribute("data-current-lang");
updateButtonText(currentLang);
toggleLanguageElements(currentLang);
// Add click event listener to toggle language and update button text
switchLangButton.addEventListener("click", () => {
currentLang = currentLang === "en" ? "pl" : "en";
switchLangButton.setAttribute("data-current-lang", currentLang);
updateButtonText(currentLang);
toggleLanguageElements(currentLang);
});
});
// Load each section
loadCertificates();