Skip to content

Commit

Permalink
Update table.js
Browse files Browse the repository at this point in the history
  • Loading branch information
AGolz authored Jan 17, 2024
1 parent 59599a6 commit 367ba2e
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions scripts_js/table.js
Original file line number Diff line number Diff line change
@@ -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);
}
};

0 comments on commit 367ba2e

Please sign in to comment.