diff --git a/scripts_js/table.js b/scripts_js/table.js index 955dabb..2afd977 100644 --- a/scripts_js/table.js +++ b/scripts_js/table.js @@ -1,35 +1,40 @@ -document.addEventListener("DOMContentLoaded", function() { +document.addEventListener("DOMContentLoaded", function () { showProject('born2beRoot'); }); function showProject(projectId) { var tables = document.querySelectorAll('table'); - + tables.forEach(function (table) { table.classList.remove('table-visible'); table.classList.add('table-hidden'); }); - + var selectedTable = document.getElementById(projectId); selectedTable.classList.remove('table-hidden'); selectedTable.classList.add('table-visible'); - + setTimeout(function () { tables.forEach(function (table) { if (table.id !== projectId) { table.style.display = 'none'; } }); - + selectedTable.style.display = 'table'; }, 500); - + history.pushState(null, null, `#${projectId}`); } +window.addEventListener('popstate', function () { + var currentFragment = window.location.hash.substring(1); + showProject(currentFragment); +}); + window.onload = function () { - var initialFragment = window.location.hash.substring(1); - if (initialFragment) { - showProject(initialFragment); - } + var initialFragment = window.location.hash.substring(1); + if (initialFragment) { + showProject(initialFragment); + } };