Fix: wrap checkSession in DOMContentLoaded to ensure DOM is ready

This commit is contained in:
Kato
2026-09-02 18:10:12 +00:00
parent 949b9812cf
commit 283715a6f3
+16 -6
View File
@@ -285,14 +285,22 @@
<script> <script>
function checkSession() { function checkSession() {
const sessionid = getCookie('sessionid'); const sessionid = getCookie('sessionid');
console.log('checkSession: sessionid =', sessionid);
if (sessionid) { if (sessionid) {
document.getElementById('intro-section').classList.add('hidden'); const intro = document.getElementById('intro-section');
document.getElementById('news-col').classList.add('hidden'); const news = document.getElementById('news-col');
document.getElementById('login-panel').classList.add('hidden'); const login = document.getElementById('login-panel');
document.getElementById('notebook-panel').classList.remove('hidden'); const notebook = document.getElementById('notebook-panel');
console.log('checkSession elements:', { intro, news, login, notebook });
if (intro) intro.classList.add('hidden');
if (news) news.classList.add('hidden');
if (login) login.classList.add('hidden');
if (notebook) notebook.classList.remove('hidden');
} else { } else {
document.getElementById('notebook-panel').classList.add('hidden'); const notebook = document.getElementById('notebook-panel');
document.getElementById('login-panel').classList.remove('hidden'); const login = document.getElementById('login-panel');
if (notebook) notebook.classList.add('hidden');
if (login) login.classList.remove('hidden');
} }
} }
@@ -438,7 +446,9 @@
} }
document.addEventListener('DOMContentLoaded', () => {
checkSession(); checkSession();
});
</script> </script>
</body> </body>
</html> </html>