-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgoals.html
More file actions
84 lines (74 loc) · 3.33 KB
/
goals.html
File metadata and controls
84 lines (74 loc) · 3.33 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Future Goals</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body { display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background: darkblue; color:black; background-image: url('https://getwallpapers.com/wallpaper/full/c/a/8/924819-sunny-day-background-1920x1080-meizu.jpg'); }
.goals { width: 80%; padding: 20px; background: rgba(255, 255, 255, 0.2); border-radius: 10px; }
ul { list-style: none; padding: 0; }
li { margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.remove-btn { color: red; cursor: pointer; }
</style>
</head>
<body>
<div class="goals">
<h1>Future Goals for <span id="name"></span></h1>
<p>As a passionate <span id="course"></span> student, prepare your goal list wisely and do follow</p>
<h3>Your Goals:</h3>
<ul id="goalList">
<!-- Dynamic goal list goes here -->
</ul>
<div class="input-group mb-3">
<input type="text" id="goalInput" class="form-control" placeholder="Enter a new goal">
<button onclick="addGoal()" class="btn btn-success">Add Goal</button>
</div>
<a href="registered.html" class="btn btn-primary">Back to Dashboard</a>
</div>
<script>
const studentData = JSON.parse(localStorage.getItem('studentData'));
if (studentData) {
document.getElementById('name').textContent = studentData.name;
document.getElementById('course').textContent = studentData.course;
} else {
document.body.innerHTML = "<h2>No student data available.</h2>";
}
// Retrieve goals from localStorage or set up an empty array if none exist
let goals = JSON.parse(localStorage.getItem('goals')) || [];
// Function to display goals in the list
function displayGoals() {
const goalList = document.getElementById('goalList');
goalList.innerHTML = '';
goals.forEach((goal, index) => {
const li = document.createElement('li');
li.innerHTML = `
${goal}
<span class="remove-btn" onclick="removeGoal(${index})">×</span>
`;
goalList.appendChild(li);
});
}
// Function to add a new goal
function addGoal() {
const goalInput = document.getElementById('goalInput');
const newGoal = goalInput.value.trim();
if (newGoal) {
goals.push(newGoal);
localStorage.setItem('goals', JSON.stringify(goals));
goalInput.value = '';
displayGoals();
}
}
// Function to remove a goal
function removeGoal(index) {
goals.splice(index, 1);
localStorage.setItem('goals', JSON.stringify(goals));
displayGoals();
}
// Display goals on page load
displayGoals();
</script>
</body>
</html>