Spaces:
Running
Running
File size: 1,235 Bytes
43b6a47 f33e4d0 43b6a47 f33e4d0 43b6a47 |
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 |
const langNavMap = {
"langBtnEng": "info_eng.html",
"langBtnJp": "info_jp.html"
};
function load_info(path) {
fetch(path /*, options */)
.then((response) => {
return response.text();
}
)
.then((html) => {
document.getElementById("infoBox").innerHTML = html;
})
.catch((error) => {
console.warn(error);
});
}
var langNavigator = document.getElementById('langNavigator');
for (let ele of langNavigator.children) {
if (ele.tagName == "BUTTON") {
ele.addEventListener(
'mouseup',
(e) => {
for (let btn of document.getElementsByClassName('activeLangBtn')) {
btn.className = 'nonactiveLangBtn';
}
let path = langNavMap[ele.id];
console.log("Loading " + path);
load_info(path);
ele.className = 'activeLangBtn';
}
);
}
}
for (let ele of langNavigator.children) {
if (ele.tagName == "BUTTON" && ele.className == "activeLangBtn") {
let path = langNavMap[ele.id];
console.log("Loading " + path);
load_info(path);
break;
}
} |