cleaned up JS
This commit is contained in:
parent
186026fa6d
commit
cdd0c13cdc
7 changed files with 82 additions and 75 deletions
31
static/js/sidemenu.js
Normal file
31
static/js/sidemenu.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
This script is responsible for opening and closing the menu from the side.
|
||||
*/
|
||||
function openNav() {
|
||||
document.getElementById("mySidenav").style.width = "250px";
|
||||
document.body.classList.add('menu-open');
|
||||
}
|
||||
|
||||
function closeNav() {
|
||||
document.getElementById("mySidenav").style.width = "0";
|
||||
document.body.classList.remove('menu-open');
|
||||
}
|
||||
|
||||
function setTheme(theme) {
|
||||
window.location.href = '/search?theme=' + theme;
|
||||
}
|
||||
|
||||
function updateLanguage(langCode) {
|
||||
// Send AJAX request to update language settings
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', '/updateSettings', true);
|
||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
xhr.onload = function () {
|
||||
if (this.status >= 200 && this.status < 300) {
|
||||
location.reload();
|
||||
} else {
|
||||
console.error('Failed to update language.');
|
||||
}
|
||||
};
|
||||
xhr.send(encodeURI('site_lang=' + langCode));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue