Skip to content

Commit

Permalink
added debugging code
Browse files Browse the repository at this point in the history
  • Loading branch information
JGHartel committed Oct 17, 2024
1 parent 4835894 commit 52fecbc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions assets/js/script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
alert("Script is loaded!");

// Element toggle function
const elementToggleFunc = function (elem) {
Expand All @@ -20,10 +21,13 @@ if (sidebarBtn) {
const navigationLinks = document.querySelectorAll("[data-nav-link]");
const pages = document.querySelectorAll("[data-page]");

console.log("Number of navigation links:", navigationLinks.length);

// Add event to all nav links
navigationLinks.forEach(function (link) {
link.addEventListener("click", function () {
const targetPage = this.textContent.trim().toLowerCase();
alert("Clicked on " + this.dataset.page);
const targetPage = this.textContent.trim().toLowerCase(); // Convert button text to match the section's data-page value

// Remove 'active' class from all navigation links
navigationLinks.forEach(function (navLink) {
Expand All @@ -37,7 +41,7 @@ navigationLinks.forEach(function (link) {
pages.forEach(function (page) {
if (page.dataset.page === targetPage) {
page.classList.add("active");
window.scrollTo(0, 0);
window.scrollTo(0, 0); // Scroll to top of the page when switching
} else {
page.classList.remove("active");
}
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -452,4 +452,4 @@ <h2 class="h2 article-title">Contact</h2>

</body>

</html>
</html>

0 comments on commit 52fecbc

Please sign in to comment.