Repository navigation
Expand file tree
/
Copy pathChallenges.html
More file actions
249 lines (221 loc) · 8.68 KB
/
Copy pathChallenges.html
File metadata and controls
249 lines (221 loc) · 8.68 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=1440" />
<title>Challenges Teenagers</title>
<link rel="stylesheet" href="style.css" />
<style>
#popupBox {
position: fixed;
top: 50%;
left: 33.3%;
transform: translate(-50%, -50%);
background-color: rgba(0, 0, 0, 0.85);
color: white;
padding: 30px;
border-radius: 10px;
display: none;
z-index: 999;
justify-content: center;
align-items: center;
font-size: 20px;
max-width: 200px;
text-align: center;
}
#popupBox-1 {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: rgba(0, 0, 0, 0.85);
color: white;
padding: 30px;
border-radius: 10px;
display: none;
z-index: 999;
justify-content: center;
align-items: center;
font-size: 20px;
max-width: 200px;
text-align: center;
}
#popupBox-2 {
position: fixed;
top: 50%;
left: 66.6%;
transform: translate(-50%, -50%);
background-color: rgba(0, 0, 0, 0.85);
color: white;
padding: 30px;
border-radius: 10px;
display: none;
z-index: 999;
justify-content: center;
align-items: center;
font-size: 20px;
max-width: 200px;
text-align: center;
}
</style>
</head>
<body>
<div id="header" class="fixed-top">
<a href="Main.html"><img id="logo" src="anos_prev_ui.png"></a>
<a href="Main.html"><t id="head">Eco-Switch</t></a>
<div class="container">
<a href="main.html"><button id="webitem">About us</button></a> <span style="color: white; font-weight: bold;">|</span>
<a href="newcalc.html"><button id="webitem">Calculator</button></a> <span style="color: white; font-weight: bold;">|</span>
<button id="webitem" onclick="navigateToChallenges()">Challenges</button> <span style="color: white; font-weight: bold;">|</span>
<a href="marketplace.html"><button id="webitem">Market place</button></a>
</div>
<div id="authButtons" style="position: absolute; right: 100px;">
<a href="Login.html"><button id="webitem">Login</button></a> <span style="color: white; font-weight: bold;">|</span>
<a href="Register.html"><button id="webitem">Register</button></a>
</div>
<div id="userProfile" style="display: none; position: absolute; left: 1130px; align-items: center; justify-content: center;">
<span id="userName" style="color: white; font-weight: bold; margin-right: 10px;"></span>
<img id="userIcon" src="icon.jpeg" style="width: 50px; height: 50px; cursor: pointer; border-radius: 40px;" >
<button id="logoutBtn" style="display: none; position: absolute; top: 40px;">Logout</button>
</div>
</div>
<main>
<section class="hero-section" id="hero-section">
<h1 class="title">Teenagers Challenges</h1>
</section>
<section class="cards" id="cards">
<div class="card" id="card">
<div class="card-img" id="card-img">
<img src="challenge1.jpg" alt="image">
</div>
<div class="text">Pick-up To Change!</div>
<div class="card-points">200 points</div>
</div>
<div class="card" id="card-1">
<div class="card-img" id="card-img">
<img src="challenge2.jpg" alt="image">
</div>
<div class="text">Be an Influencer!</div>
<div class="card-points">150 points</div>
</div>
<div class="card" id="card-2">
<div class="card-img" id="card-img">
<img src="challenge3.jpg" alt="image">
</div>
<div class="text">A Clean Week!</div>
<div class="card-points">500 points</div>
</div>
</section>
</main>
<div id="popupBox">Organize a local <span>trash pick-up event</span> in your neighborhood
<button onclick="window.location.href='https://docs.google.com/forms/d/1lMBe-ULjNU9R6-Lp_WkhITAm4Yhh8s6db-FGHmkkYJ4/edit'">upload a photo</button>
</div>
<div id="popupBox-1">Write a blog or make a short video on how to reduce plastic use
<button onclick="window.location.href='https://docs.google.com/forms/d/1lMBe-ULjNU9R6-Lp_WkhITAm4Yhh8s6db-FGHmkkYJ4/edit'">upload a photo</button>
</div>
<div id="popupBox-2"> Trying to go a week without using disposable plastic
<button onclick="window.location.href='https://docs.google.com/forms/d/1lMBe-ULjNU9R6-Lp_WkhITAm4Yhh8s6db-FGHmkkYJ4/edit'">upload a photo</button>
</div>
<script>
const hoverBox = document.getElementById("card");
const popupBox = document.getElementById("popupBox");
hoverBox.addEventListener("mouseenter", () => {
popupBox.style.display = "block";
});
popupBox.addEventListener("mouseenter", () => {
popupBox.style.display = "block";
});
hoverBox.addEventListener("mouseleave", () => {
popupBox.style.display = "none";
});
const hoverBox1 = document.getElementById("card-1");
const popupBox1 = document.getElementById("popupBox-1");
hoverBox1.addEventListener("mouseenter", () => {
popupBox1.style.display = "block";
});
popupBox1.addEventListener("mouseenter", () => {
popupBox1.style.display = "block";
});
hoverBox1.addEventListener("mouseleave", () => {
popupBox1.style.display = "none";
});
const hoverBox2 = document.getElementById("card-2");
const popupBox2 = document.getElementById("popupBox-2");
hoverBox2.addEventListener("mouseenter", () => {
popupBox2.style.display = "block";
});
popupBox2.addEventListener("mouseenter", () => {
popupBox2.style.display = "block";
});
hoverBox2.addEventListener("mouseleave", () => {
popupBox2.style.display = "none";
});
// Check login status on page load
document.addEventListener('DOMContentLoaded', function() {
const user = JSON.parse(localStorage.getItem('user'));
const authButtons = document.getElementById('authButtons');
const userProfile = document.getElementById('userProfile');
const userName = document.getElementById('userName');
const logoutBtn = document.getElementById('logoutBtn');
if (user) {
// Show user profile
authButtons.style.display = 'none';
userProfile.style.display = 'flex';
userName.textContent = `${user.first_name} ${user.second_name}`;
// Show logout button on hover
userProfile.addEventListener('mouseenter', () => {
logoutBtn.style.display = 'block';
});
userProfile.addEventListener('mouseleave', () => {
logoutBtn.style.display = 'none';
});
// Logout functionality
logoutBtn.addEventListener('click', () => {
localStorage.clear();
window.location.href = 'Login.html';
});
}
});
</script>
<script>
function navigateToChallenges() {
const user = JSON.parse(localStorage.getItem('user'));
if (!user) {
window.location.href = 'Challenges.html';
return;
}
const age = user.age;
if (age <= 12) {
window.location.href = 'challenges-childern.html';
} else if (age <= 19) {
window.location.href = 'Challenges.html';
} else {
window.location.href = 'challenge-adults.html';
}
}
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
const user = JSON.parse(localStorage.getItem('user'));
if (!user) return;
const age = user.age;
const currentPage = window.location.pathname.split('/').pop();
// Define allowed pages for each age group
const allowedPages = {
'child': 'challenges-childern.html',
'teen': 'Challenges.html',
'adult': 'challenge-adults.html'
};
// Determine correct page
let correctPage;
if (age <= 12) correctPage = allowedPages.child;
else if (age <= 19) correctPage = allowedPages.teen;
else correctPage = allowedPages.adult;
// Redirect if not on correct page
if (currentPage !== correctPage) {
window.location.href = correctPage;
}
});
</script>
</body>
</html>