-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
126 lines (95 loc) · 4.04 KB
/
Copy pathscript.js
File metadata and controls
126 lines (95 loc) · 4.04 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
const nameInput = document.getElementById("name");
const emailInput = document.getElementById("email");
const phoneInput = document.getElementById("phone");
const previewName = document.getElementById("previewName");
const previewContact = document.getElementById("previewContact");
nameInput.addEventListener("input", () => {
previewName.textContent = nameInput.value || "Your Name";
});
emailInput.addEventListener("input", updateContact);
phoneInput.addEventListener("input", updateContact);
function updateContact() {
let text = "";
if (emailInput.value) text += emailInput.value;
if (phoneInput.value) text += " | " + phoneInput.value;
previewContact.textContent = text;
}
const profilePic = document.getElementById("profilePic");
const previewImage = document.getElementById("previewImage");
profilePic.addEventListener("change", () => {
const file = profilePic.files[0];
if (!file || !file.type.startsWith("image/")) return;
const reader = new FileReader();
reader.onload = () => previewImage.src = reader.result;
reader.readAsDataURL(file);
});
const summaryInput = document.getElementById("summary");
const previewSummary = document.getElementById("previewSummary");
summaryInput.addEventListener("input", () => {
previewSummary.textContent = summaryInput.value;
});
const skillInput = document.getElementById("skillInput");
const previewSkills = document.getElementById("previewSkills");
document.getElementById("addSkill").addEventListener("click", () => {
const skill = skillInput.value.trim();
if (!skill) return;
const li = document.createElement("li");
li.textContent = skill;
li.onclick = () => li.remove();
previewSkills.appendChild(li);
skillInput.value = "";
});
document.getElementById("addExperience").addEventListener("click", () => {
const wrapper = document.createElement("div");
wrapper.innerHTML = `
<input class="role" placeholder="Role / Project">
<input class="duration" placeholder="Duration">
<textarea class="desc" placeholder="Description"></textarea>
<button type="button" class="save">Save</button>
<hr>
`;
wrapper.querySelector(".save").onclick = () => {
const role = wrapper.querySelector(".role").value.trim();
const duration = wrapper.querySelector(".duration").value.trim();
const desc = wrapper.querySelector(".desc").value.trim();
if (!role || !desc) return alert("Role & description required");
const tr = document.createElement("tr");
tr.innerHTML = `<td>${role}</td><td>${desc}</td><td>${duration}</td>`;
document.getElementById("previewExperience").appendChild(tr);
wrapper.remove();
};
document.getElementById("experienceFields").appendChild(wrapper);
});
const eduNameInput = document.getElementById("educationName");
const eduYearInput = document.getElementById("educationYear");
document.getElementById("addEducation").addEventListener("click", () => {
if (!eduNameInput.value || !eduYearInput.value) return;
const row = document.createElement("div");
row.className = "education-row";
row.innerHTML = `<span>${eduNameInput.value}</span><span>${eduYearInput.value}</span>`;
row.onclick = () => row.remove();
document.getElementById("previewEducationList").appendChild(row);
eduNameInput.value = "";
eduYearInput.value = "";
});
const printBtn = document.getElementById("printBtn");
const printModal = document.getElementById("printModal");
const modalPreview = document.getElementById("modalPreview");
const cancelPrint = document.getElementById("cancelPrint");
printBtn.addEventListener("click", () => {
const clone = document.querySelector(".resume").cloneNode(true);
const actions = clone.querySelector(".actions");
if (actions) actions.remove();
modalPreview.innerHTML = "";
modalPreview.appendChild(clone);
printModal.style.display = "block";
});
cancelPrint.addEventListener("click", () => {
printModal.style.display = "none";
});
printModal.addEventListener("click", (e) => {
if (e.target === printModal) {
printModal.style.display = "none";
}
});
document.getElementById("exportBtn").onclick = () => window.print();