-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
50 lines (41 loc) · 1.67 KB
/
Copy pathscript.js
File metadata and controls
50 lines (41 loc) · 1.67 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
document.addEventListener("DOMContentLoaded", () => {
const profileName = document.getElementById("profileName");
const profileBio = document.getElementById("profileBio");
const profileImage = document.getElementById("profileImage");
const profileCard = document.getElementById("profileCard");
const feedback = document.getElementById("feedback");
const nameInput = document.getElementById("nameInput");
const bioInput = document.getElementById("bioInput");
const imageInput = document.getElementById("imageInput");
const bgColorInput = document.getElementById("bgColorInput");
const updateButton = document.createElement("button");
updateButton.textContent = "Update Profile Card";
updateButton.type = "button";
document.querySelector(".editor form fieldset").appendChild(updateButton);
function updateName() {
profileName.textContent = nameInput.value.trim() || "John Doe";
}
function updateBio() {
profileBio.textContent = bioInput.value.trim() || "This is a short bio.";
}
function updateImage() {
const imageUrl = imageInput.value.trim();
if (imageUrl) {
profileImage.setAttribute("src", imageUrl);
}
}
function changeBackgroundColor() {
profileCard.style.backgroundColor = bgColorInput.value || "#fff";
}
function updateProfile() {
updateName();
updateBio();
updateImage();
changeBackgroundColor();
feedback.textContent = "Profile updated successfully!";
setTimeout(() => {
feedback.textContent = "";
}, 3000);
}
updateButton.addEventListener("click", updateProfile);
});