From c3d069d31b9a455c01e32075fa3c98658327481c Mon Sep 17 00:00:00 2001 From: lukef Date: Thu, 14 Mar 2024 09:55:39 +0800 Subject: [PATCH] Added textbook --- static/js/textbook.js | 49 +++++++++++++++++++++++++++++++++++++++++++ textbook.html | 17 +++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 static/js/textbook.js create mode 100644 textbook.html diff --git a/static/js/textbook.js b/static/js/textbook.js new file mode 100644 index 0000000..fb18b33 --- /dev/null +++ b/static/js/textbook.js @@ -0,0 +1,49 @@ +const pages = [ + ["

Content page

", "Here is a list of content"], + ["10.1: Introduction"], + ["10.2: Principle of Superposition"], + ["10.3: Interference"], + ["

10.4: Interference of Two Wave Sources

"], + ["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"; + } +}); diff --git a/textbook.html b/textbook.html new file mode 100644 index 0000000..977b4e5 --- /dev/null +++ b/textbook.html @@ -0,0 +1,17 @@ + + + + + + Superposition + + +
+ +
+ + + + + + \ No newline at end of file