Skip to content

Commit ac7b5ed

Browse files
Fix strikes page JavaScript errors
Fixed issues with the strikes page (my-strikes.html): 1. Corrected HTML structure with properly closed tags 2. Fixed JavaScript errors in parameter handling 3. Moved jQuery script to proper location 4. Fixed incorrect content references in dynamic section logic 5. Improved code formatting and fixed typos Closes # 69
1 parent fcca06f commit ac7b5ed

File tree

1 file changed

+73
-74
lines changed

1 file changed

+73
-74
lines changed

src/Strikes/my-strikes.html

Lines changed: 73 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@
99
font-family: Sans-Serif;
1010
margin: 0;
1111
}
12-
<link href='https://fonts.googleapis.com/css?family=Comfortaa' rel='stylesheet'>
13-
<style>
14-
body {
15-
font-family: 'Comfortaa';font-size: 22px;
16-
}
17-
18-
.dynamic-content {
19-
display:none;
20-
}
21-
12+
</style>
13+
<link href='https://fonts.googleapis.com/css?family=Comfortaa' rel='stylesheet'>
14+
<style>
15+
body {
16+
font-family: 'Comfortaa';font-size: 22px;
17+
}
18+
19+
.dynamic-content {
20+
display:none;
21+
}
22+
2223
.menu-container {
2324
position: relative;
2425
display: flex;
@@ -107,6 +108,7 @@
107108
}
108109
}
109110
</style>
111+
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
110112
</head>
111113
<body>
112114
<nav class="menu-container">
@@ -133,75 +135,72 @@
133135
</div>
134136
</nav>
135137

136-
<!-- This is the staff profile system -->
137-
<h1>Staff Profile</h1>
138-
139-
<!-- Default Dynamic Section -->
140-
<div id="default-content" class="dynamic-content">
141-
<h2>No Strike ID</h2>
142-
Make sure you got a vaild link and come back. You may also not have any strikes at this time. If that's true, keep up the good work!
143-
</div>
144-
<!-- Dynamic Section 1 -->
145-
<div id="username1" class="dynamic-content">
146-
<h2>Username 1</h2>
147-
<h3>1 Strike</h3>
148-
<br>
149-
Oops! You currently have 1 Strike at Coding Hut. Look below to see your strikes.
150-
</div>
151-
<!-- Dynamic Section 2 -->
152-
<div id="staff2" class="dynamic-content">
153-
<h2>Staff2</h2>
154-
<br>
155-
DESCRIPTION HERE
156-
</div>
157-
<!-- Dynamic Section 3 -->
158-
<div id="staff3" class="dynamic-content">
159-
<h2>Staff3</h2>
160-
<br>
161-
DESCRIPTION HERE
162-
</div>
163-
138+
<!-- This is the strikes information system -->
139+
<h1>My Strikes</h1>
140+
141+
<!-- Default Dynamic Section -->
142+
<div id="default-content" class="dynamic-content">
143+
<h2>No Strike ID</h2>
144+
Make sure you got a valid link and come back. You may also not have any strikes at this time. If that's true, keep up the good work!
145+
</div>
146+
<!-- Dynamic Section 1 -->
147+
<div id="username1" class="dynamic-content">
148+
<h2>Username 1</h2>
149+
<h3>1 Strike</h3>
150+
<br>
151+
Oops! You currently have 1 Strike at Coding Hut. Look below to see your strikes.
152+
</div>
153+
<!-- Dynamic Section 2 -->
154+
<div id="staff2" class="dynamic-content">
155+
<h2>Staff2</h2>
156+
<br>
157+
DESCRIPTION HERE
158+
</div>
159+
<!-- Dynamic Section 3 -->
160+
<div id="staff3" class="dynamic-content">
161+
<h2>Staff3</h2>
162+
<br>
163+
DESCRIPTION HERE
164+
</div>
165+
164166
<script>
165167
function toggleMenu() {
166168
var menu = document.querySelector('.menu');
167169
menu.style.display = menu.style.display === 'flex' ? 'none' : 'flex';
168170
}
171+
172+
// Parse the URL parameter
173+
function getParameterByName(name, url) {
174+
if (!url) url = window.location.href;
175+
name = name.replace(/[\[\]]/g, "\\$&");
176+
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
177+
results = regex.exec(url);
178+
if (!results) return null;
179+
if (!results[2]) return '';
180+
return decodeURIComponent(results[2].replace(/\+/g, " "));
181+
}
182+
183+
$(document).ready(function() {
184+
// Give the parameter a variable name
185+
var dynamicContent = getParameterByName('strikeid');
186+
187+
// Check if the URL parameter matches any of our dynamic sections
188+
if (dynamicContent == 'username1') {
189+
$('#username1').show();
190+
}
191+
// Check if the URL parameter is staff2
192+
else if (dynamicContent == 'staff2') {
193+
$('#staff2').show();
194+
}
195+
// Check if the URL parameter is staff3
196+
else if (dynamicContent == 'staff3') {
197+
$('#staff3').show();
198+
}
199+
// Check if the URL parameter is empty or not defined, display default content
200+
else {
201+
$('#default-content').show();
202+
}
203+
});
169204
</script>
170205
</body>
171206
</html>
172-
173-
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
174-
<script type="text/javascript">
175-
// Parse the URL parameter
176-
function getParameterByName(name, url) {
177-
if (!url) url = window.location.href;
178-
name = name.replace(/[\[\]]/g, "\\$&");
179-
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
180-
results = regex.exec(url);
181-
if (!results) return null;
182-
if (!results[2]) return '';
183-
return decodeURIComponent(results[2].replace(/\+/g, " "));
184-
}
185-
// Give the parameter a variable name
186-
var dynamicContent = getParameterByName('strikeid');
187-
188-
$(document).ready(function() {
189-
190-
// Check if the URL parameter is apples
191-
if (dynamicContent == 'myscratchedaccount') {
192-
$('#myscratchedaccount').show();
193-
}
194-
// Check if the URL parameter is oranges
195-
else if (dynamicContent == 'staff2') {
196-
$('#staff2').show();
197-
}
198-
// Check if the URL parameter is bananas
199-
else if (dynamicContent == 'staff3') {
200-
$('#staff3').show();
201-
}
202-
// Check if the URL parmeter is empty or not defined, display default content
203-
else {
204-
$('#default-content').show();
205-
}
206-
});
207-
</script>

0 commit comments

Comments
 (0)