/* 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)); }