forked from spacebar/SplatNet
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
d65c8d2a73 |
|||
|
8abb9c3fd1 |
1 changed files with 15 additions and 3 deletions
|
|
@ -125,8 +125,11 @@ window.initDropdown = function() {
|
||||||
|
|
||||||
$optionsList.off('click').on('click', 'li', function() {
|
$optionsList.off('click').on('click', 'li', function() {
|
||||||
var newSrc = $(this).attr('data-src');
|
var newSrc = $(this).attr('data-src');
|
||||||
$selectedImg.attr('src', newSrc);
|
var langValue = $(this).attr('data-value');
|
||||||
$optionsList.removeClass('show');
|
var headerFile = (langValue === 'jp') ? "../header-jp.html" : "../header.html";
|
||||||
|
localStorage.setItem('selected_header', headerFile);
|
||||||
|
localStorage.setItem('selected_lang_src', newSrc);
|
||||||
|
window.location.reload();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).off('click.dropdown').on('click.dropdown', function() {
|
$(document).off('click.dropdown').on('click.dropdown', function() {
|
||||||
|
|
@ -144,12 +147,21 @@ window.loadHeader = function(callback) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fetch("../header.html")
|
const targetHeader = localStorage.getItem('selected_header') || "../header.html";
|
||||||
|
|
||||||
|
fetch(targetHeader)
|
||||||
.then(res => res.text())
|
.then(res => res.text())
|
||||||
.then(html => {
|
.then(html => {
|
||||||
const container = document.getElementById("header-container");
|
const container = document.getElementById("header-container");
|
||||||
if (container) {
|
if (container) {
|
||||||
container.innerHTML = html;
|
container.innerHTML = html;
|
||||||
|
|
||||||
|
const savedLangSrc = localStorage.getItem('selected_lang_src');
|
||||||
|
const selectedImg = container.querySelector('#selected-img');
|
||||||
|
if (savedLangSrc && selectedImg) {
|
||||||
|
selectedImg.src = savedLangSrc;
|
||||||
|
}
|
||||||
|
|
||||||
window.headerLoaded = true;
|
window.headerLoaded = true;
|
||||||
window.loadHeaderCallbacks.forEach(cb => cb(container));
|
window.loadHeaderCallbacks.forEach(cb => cb(container));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue