-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create finalProfilepage.html #24
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Book Management</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
background-color:#e5e5f3; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
#profile-container { | ||
background-color: rgb(207, 222, 191); | ||
border-radius: 8px; | ||
width: 400px; | ||
padding: 20px; | ||
position: relative; | ||
} | ||
|
||
.profile-header { | ||
text-align: center; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.profile-info { | ||
text-align: center; | ||
} | ||
|
||
.profile-avatar { | ||
width: 100px; | ||
height: 100px; | ||
border-radius: 50%; | ||
margin-bottom: 10px; | ||
} | ||
|
||
.book-management { | ||
margin-top: 20px; | ||
} | ||
|
||
.book-management ul { | ||
list-style-type: none; | ||
padding: 0; | ||
} | ||
|
||
.book-management li { | ||
background-color: #f9f9f9; | ||
margin: 5px 0; | ||
padding: 10px; | ||
border-radius: 5px; | ||
display: none; | ||
Comment on lines
+52
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (performance): Consider showing list items by default and using CSS to handle completed state Setting display:none by default can cause content flashing before JavaScript loads. Consider showing items by default and using CSS classes to handle visibility states. Suggested implementation:
The JavaScript code will need to be updated to:
|
||
} | ||
|
||
.close { | ||
position: absolute; | ||
top: 10px; | ||
right: 10px; | ||
font-size: 28px; | ||
cursor: pointer; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<div id="profile-container"> | ||
<span class="close" id="close-profile">✖️</span> | ||
<div class="profile-header"> | ||
<h1>🎟️User Profile🎟️</h1><hr> | ||
</div> | ||
<div class="profile-info"> | ||
<img src="https://img.freepik.com/premium-vector/school-boy-vector-illustration_38694-902.jpg" style="height:200px;width:200px" class="profile-avatar"> | ||
<h2>John Doe</h2><hr> | ||
<p>Email: [email protected]</p><hr> | ||
</div> | ||
<div class="book-management"> | ||
<h2>Book Management</h2> | ||
<ul> | ||
<li><input type="checkbox" class="book-completed"> Book 1: "The Great Gatsby" - Status: Reading</li> | ||
<li><input type="checkbox" class="book-completed"> Book 2: "1984" - Status: Completed</li> | ||
<li><input type="checkbox" class="book-completed"> Book 3: "To Kill a Mockingbird" - Status: Want to Read</li> | ||
</ul> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
document.addEventListener("DOMContentLoaded", function() { | ||
var profileContainer = document.getElementById("profile-container"); | ||
var closeProfile = document.getElementById("close-profile"); | ||
var bookCompletedCheckboxes = document.getElementsByClassName("book-completed"); | ||
|
||
for (var i = 0; i < bookCompletedCheckboxes.length; i++) { | ||
bookCompletedCheckboxes[i].onclick = function() { | ||
if (this.checked) { | ||
this.parentElement.style.display = "list-item"; | ||
} else { | ||
this.parentElement.style.display = "none"; | ||
} | ||
} | ||
} | ||
closeProfile.onclick = function() { window.location.href = "Management.html"; } | ||
|
||
|
||
for (var i = 0; i < bookCompletedCheckboxes.length; i++) { | ||
if (bookCompletedCheckboxes[i].nextSibling.nodeValue.includes("Status: Completed")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Use data attributes instead of text content for state management Parsing text content is fragile. Consider using data-status attributes to manage book states. Suggested implementation:
You'll also need to update the HTML elements where the book status is displayed to include the data-status attribute. For example, where you currently have text content showing the status, you should add the attribute to the parent element like this: <li data-status="completed">
<input type="checkbox" class="book-completed"> Status: Completed
</li> This change will need to be made wherever book status is displayed in the HTML structure. |
||
bookCompletedCheckboxes[i].checked = true; | ||
bookCompletedCheckboxes[i].parentElement.style.display = "list-item"; | ||
} | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Consolidate duplicate loops over bookCompletedCheckboxes
The two loops over bookCompletedCheckboxes can be combined into a single loop that handles both initialization and click handling setup.
Suggested implementation:
If there are other loops over bookCompletedCheckboxes elsewhere in the file that we can't see, those should also be consolidated into this single loop if they're performing related operations.