-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.js
35 lines (28 loc) · 1.17 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// We get references to the buttons on the page.
const ccnaBtn = document.querySelector("#ccna");
const ccnaBardBtn = document.querySelector("#ccnabard");
const secPlusBtn = document.querySelector("#secplus");
const hallucBtn = document.querySelector("#halluci");
// We add event listeners to the buttons.
// Depending on the button clicked we create a session variable called quiz and set it to the JSON file we want to load in hte quiz.html. The sessions variable allows us to share
// data between pages. We then redirect the user to the quiz.html page.
ccnaBtn.addEventListener("click", (e) => {
e.preventDefault();
sessionStorage.setItem("quiz", "./ccna.json");
location.href="quiz.html";
});
ccnaBardBtn.addEventListener("click", (e) => {
e.preventDefault();
sessionStorage.setItem("quiz", "./ccna_bard.json");
location.href="quiz.html";
});
secPlusBtn.addEventListener("click", (e) => {
e.preventDefault();
sessionStorage.setItem("quiz", "./secplus.json");
location.href="quiz.html";
});
hallucBtn.addEventListener("click", (e) => {
e.preventDefault();
sessionStorage.setItem("quiz", "./hallucinations.json");
location.href="quiz.html";
});