Repository navigation
Expand file tree
/
Copy pathScript.js
More file actions
67 lines (53 loc) · 1.97 KB
/
Copy pathScript.js
File metadata and controls
67 lines (53 loc) · 1.97 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
// script.js
document.addEventListener("DOMContentLoaded", function () {
const uploadButton = document.querySelector("button");
uploadButton.addEventListener("click", async () => {
const resumeText = document.getElementById("resumeText").value;
if (!resumeText.trim()) {
alert("Please paste your resume content.");
return;
}
try {
const response = await fetch("http://127.0.0.1:5000/analyze", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ text: resumeText })
});
if (!response.ok) {
throw new Error("Error analyzing resume");
}
const data = await response.json();
displayAnalysis(data);
} catch (error) {
console.error("Analysis failed:", error);
alert("Something went wrong while analyzing your resume.");
}
});
function displayAnalysis(data) {
let output = `<h4>Analysis Result</h4>`;
output += `<p><strong>ATS Score:</strong> ${data.ats_score}%</p>`;
output += `<h5>Strengths:</h5><ul>`;
data.strengths.forEach(item => output += `<li>${item}</li>`);
output += `</ul>`;
output += `<h5>Weaknesses:</h5><ul>`;
data.weaknesses.forEach(item => output += `<li>${item}</li>`);
output += `</ul>`;
output += `<h5>Recommendations:</h5><ul>`;
data.recommendations.forEach(item => output += `<li>${item}</li>`);
output += `</ul>`;
output += `<h5>Suggested Templates:</h5><ul>`;
data.suggested_templates.forEach(template => output += `<li>${template}</li>`);
output += `</ul>`;
output += `<h5>Job Matches:</h5><ul>`;
data.job_matches.forEach(job => {
output += `<li>${job.title} at ${job.company} (${job.location})</li>`;
});
output += `</ul>`;
const resultBox = document.createElement("div");
resultBox.classList.add("result-box");
resultBox.innerHTML = output;
document.querySelector(".upload-section").appendChild(resultBox);
}
});