-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp2.js
57 lines (51 loc) · 2.08 KB
/
app2.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Planet Name and Planet Mean
addEventListener("keydown", function (event) {
if (event.key === "Enter") {
localStorage.setItem("planetName", document.querySelector("#planetName").value);
localStorage.setItem("planetMean", document.querySelector("#planetMean").value);
}
});
// Checkbox
document.querySelectorAll('input[type="checkbox"]').forEach(function(checkbox) {
checkbox.addEventListener("keydown", function(event) {
if (event.key === "Enter") {
const checkboxes = document.querySelectorAll('input[type="checkbox"]');
let checkedValues = [];
checkboxes.forEach(function(checkbox) {
if (checkbox.checked) {
checkedValues.push(checkbox.value);
}
});
localStorage.setItem("checkedFocusAreas", JSON.stringify(checkedValues));
}
});
});
// Habit Blueprint
addEventListener("keydown", function (event) {
if (event.key === "Enter") {
localStorage.setItem("habit1", document.querySelector("#habit1").value);
localStorage.setItem("habit2", document.querySelector("#habit2").value);
localStorage.setItem("habit3", document.querySelector("#habit3").value);
}
});
// Range
document.querySelector("#sched").addEventListener("input", function () {
let rangeValue = document.querySelector("#sched").value;
localStorage.setItem("rangeVal", rangeValue);
});
// Dropdown
document.querySelector("#barrier").addEventListener("change", function () {
let selectedFocus = document.querySelector("#barrier").value;
localStorage.setItem("selectedFocus", selectedFocus);
});
// Radio Button
document.querySelectorAll('input[name="power"]').forEach(function (radioButton) {
radioButton.addEventListener("change", function () {
let selectedPower = document.querySelector('input[name="power"]:checked').id;
localStorage.setItem("selectedPower", selectedPower);
});
});
// Launch Button
document.querySelector("#launchButton").addEventListener("click", function () {
window.location.href = "final.html";
});