-
Notifications
You must be signed in to change notification settings - Fork 26
/
internProfile.js
71 lines (60 loc) · 2.29 KB
/
internProfile.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Edit Mode Toggle Functionality
document.getElementById("edit-mode").addEventListener("change", function () {
const isEditable = this.checked;
// Toggle input fields for editing
document.getElementById("full-name").disabled = !isEditable;
document.getElementById("role").disabled = !isEditable;
document.getElementById("bio").disabled = !isEditable;
document.getElementById("linkedin").disabled = !isEditable;
document.getElementById("github").disabled = !isEditable;
// Toggle achievements buttons and inputs
document.querySelectorAll(".remove-achievement").forEach((btn) => {
btn.disabled = !isEditable;
});
document.getElementById("add-achievement").disabled = !isEditable;
// Toggle profile photo upload
document.getElementById("photo-upload").style.display = isEditable
? "block"
: "none";
});
// Handle Profile Photo Upload
const photoUploadInput = document.getElementById("photo-upload");
const profileImg = document.getElementById("profile-img");
photoUploadInput.addEventListener("change", function () {
const file = this.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function (e) {
profileImg.src = e.target.result;
};
reader.readAsDataURL(file);
}
});
// Handle Achievement Addition
document
.getElementById("add-achievement")
.addEventListener("click", function () {
const achievementsList = document.getElementById("achievements-list");
// Prompt for new achievement text
const newAchievementText = prompt("Enter your new achievement:");
if (newAchievementText) {
// Create new list item
const newAchievement = document.createElement("li");
newAchievement.innerHTML = `${newAchievementText} <button class="remove-achievement">Remove</button>`;
// Append new achievement to list
achievementsList.appendChild(newAchievement);
// Enable remove functionality
newAchievement
.querySelector(".remove-achievement")
.addEventListener("click", function () {
achievementsList.removeChild(newAchievement);
});
}
});
// Handle Achievement Removal
document.querySelectorAll(".remove-achievement").forEach((button) => {
button.addEventListener("click", function () {
const listItem = this.parentElement;
listItem.remove();
});
});