Skip to content

Commit

Permalink
Added textbook
Browse files Browse the repository at this point in the history
  • Loading branch information
LukePng committed Mar 14, 2024
1 parent 8b8b687 commit c3d069d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
49 changes: 49 additions & 0 deletions static/js/textbook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const pages = [
["<h1>Content page</h1>", "Here is a list of content"],
["10.1: Introduction"],
["10.2: Principle of Superposition"],
["10.3: Interference"],
["<h1>10.4: Interference of Two Wave Sources</h1>"],
["10.5.1: Diffraction of water waves"],
["10.5.2: Single Slit Diffraction Pattern"],
["10.5.3: Resolving Power"],
["10.6: Interference of Light Waves - Young's Double Slit Experiment"],
["10.7: Diffraction Grating"],
["10.8.1: Characteristics of Stationary Wave"],
["10.8.2: Stationary Waves in Strings"],
["10.8.3: Standing Waves in Air Columns"],
["10.8.4: What about the pressure?"]
];

let counter = 0;
content = document.querySelector(".content");
next = document.getElementById("next");
back = document.getElementById("back");

function updateContent() {
let htmlContent = '';
pages[counter].forEach(element => {
htmlContent += element;
});
content.innerHTML = htmlContent;
}


updateContent();

next.addEventListener("click", () => {
if (counter < pages.length - 1) {
counter++;
updateContent();
}
}
);

back.addEventListener("click", () => {
if (counter > 0) {
counter--;
updateContent();
} else {
window.location.href = "index.html";
}
});
17 changes: 17 additions & 0 deletions textbook.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Superposition</title>
</head>
<body>
<div class="content">

</div>
<button id="next">Next</button>
<button id="back">Back</button>
<button id="sim" onclick="location.href='sim2.html'">Simulations</button>
<script src="static/js/textbook.js"></script>
</body>
</html>

0 comments on commit c3d069d

Please sign in to comment.