|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
const sections = document.querySelectorAll('.form-section');
|
|
let draggedSection = null;
|
|
|
|
sections.forEach(section => {
|
|
section.addEventListener('dragstart', function() {
|
|
draggedSection = this;
|
|
setTimeout(() => {
|
|
this.classList.add('dragging');
|
|
}, 0);
|
|
});
|
|
|
|
section.addEventListener('dragend', function() {
|
|
this.classList.remove('dragging');
|
|
});
|
|
});
|
|
|
|
const form = document.querySelector('.resume-form');
|
|
form.addEventListener('dragover', function(e) {
|
|
e.preventDefault();
|
|
const afterElement = getDragAfterElement(form, e.clientY);
|
|
if (afterElement == null) {
|
|
form.appendChild(draggedSection);
|
|
} else {
|
|
form.insertBefore(draggedSection, afterElement);
|
|
}
|
|
});
|
|
|
|
function getDragAfterElement(container, y) {
|
|
const draggableElements = [...container.querySelectorAll('.form-section:not(.dragging)')];
|
|
|
|
return draggableElements.reduce((closest, child) => {
|
|
const box = child.getBoundingClientRect();
|
|
const offset = y - box.top - box.height / 2;
|
|
if (offset < 0 && offset > closest.offset) {
|
|
return { offset: offset, element: child };
|
|
} else {
|
|
return closest;
|
|
}
|
|
}, { offset: Number.NEGATIVE_INFINITY }).element;
|
|
}
|
|
|
|
|
|
document.getElementById('add-experience').addEventListener('click', function() {
|
|
const experienceSection = this.parentElement;
|
|
const newEntry = document.createElement('div');
|
|
newEntry.className = 'experience-entry';
|
|
newEntry.innerHTML = `
|
|
<input type="text" class="job-title" placeholder="Job Title">
|
|
<input type="text" class="company" placeholder="Company">
|
|
<input type="text" class="duration" placeholder="Duration">
|
|
<textarea class="description" placeholder="Job Description"></textarea>
|
|
<button class="ai-suggest" data-for="experience">Improve with AI</button>
|
|
`;
|
|
experienceSection.insertBefore(newEntry, this);
|
|
});
|
|
|
|
|
|
document.getElementById('add-skill').addEventListener('click', function() {
|
|
const skillInput = document.getElementById('skills-input');
|
|
const skillsList = document.getElementById('skills-list');
|
|
|
|
if (skillInput.value.trim() !== '') {
|
|
const skillTag = document.createElement('span');
|
|
skillTag.className = 'skill-tag';
|
|
skillTag.textContent = skillInput.value;
|
|
skillsList.appendChild(skillTag);
|
|
skillInput.value = '';
|
|
}
|
|
});
|
|
|
|
|
|
const modal = document.getElementById('ai-modal');
|
|
const span = document.getElementsByClassName('close')[0];
|
|
const aiSuggestions = document.getElementById('ai-suggestions');
|
|
let currentField = '';
|
|
|
|
document.querySelectorAll('.ai-suggest').forEach(button => {
|
|
button.addEventListener('click', function() {
|
|
currentField = this.getAttribute('data-for');
|
|
const fieldContent = getFieldContent(currentField);
|
|
|
|
|
|
|
|
simulateAIResponse(fieldContent);
|
|
|
|
modal.style.display = 'block';
|
|
});
|
|
});
|
|
|
|
span.onclick = function() {
|
|
modal.style.display = 'none';
|
|
}
|
|
|
|
window.onclick = function(event) {
|
|
if (event.target == modal) {
|
|
modal.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
document.getElementById('apply-suggestion').addEventListener('click', function() {
|
|
|
|
alert('Suggestion applied!');
|
|
modal.style.display = 'none';
|
|
});
|
|
|
|
function getFieldContent(field) {
|
|
switch(field) {
|
|
case 'summary':
|
|
return document.getElementById('summary').value;
|
|
case 'experience':
|
|
|
|
const experiences = document.querySelectorAll('.experience-entry');
|
|
const lastExperience = experiences[experiences.length - 1];
|
|
return lastExperience.querySelector('.description').value;
|
|
default:
|
|
return '';
|
|
}
|
|
}
|
|
|
|
function simulateAIResponse(content) {
|
|
|
|
const responses = {
|
|
summary: [
|
|
"Consider starting with a strong action word and quantifying your achievements.",
|
|
"Try to align your summary more closely with the job description keywords.",
|
|
"Your summary could benefit from more specific metrics about your impact."
|
|
],
|
|
experience: [
|
|
"Reformat your bullet points to start with action verbs and include measurable results.",
|
|
"Consider adding more context about the scale of your projects or responsibilities.",
|
|
"This could be strengthened by showing progression or promotion if applicable."
|
|
]
|
|
};
|
|
|
|
aiSuggestions.innerHTML = '';
|
|
responses[currentField].forEach((suggestion, index) => {
|
|
const suggestionDiv = document.createElement('div');
|
|
suggestionDiv.className = 'suggestion';
|
|
suggestionDiv.innerHTML = `
|
|
<input type="radio" id="suggestion-${index}" name="ai-suggestion" value="${index}">
|
|
<label for="suggestion-${index}">${suggestion}</label>
|
|
`;
|
|
aiSuggestions.appendChild(suggestionDiv);
|
|
});
|
|
}
|
|
|
|
|
|
document.getElementById('preview-resume').addEventListener('click', function() {
|
|
|
|
const previewContent = document.getElementById('preview-content');
|
|
previewContent.innerHTML = `
|
|
<h3>${document.getElementById('name').value || 'Your Name'}</h3>
|
|
<p>${document.getElementById('email').value || '[email protected]'} |
|
|
${document.getElementById('phone').value || '(123) 456-7890'}</p>
|
|
<h4>Professional Summary</h4>
|
|
<p>${document.getElementById('summary').value || 'Experienced professional seeking new opportunities.'}</p>
|
|
<h4>Work Experience</h4>
|
|
<div class="preview-experience">
|
|
${Array.from(document.querySelectorAll('.experience-entry')).map(exp => `
|
|
<h5>${exp.querySelector('.job-title').value || 'Job Title'} at ${exp.querySelector('.company').value || 'Company'}</h5>
|
|
<p>${exp.querySelector('.duration').value || 'Duration'}</p>
|
|
<p>${exp.querySelector('.description').value || 'Job description and accomplishments.'}</p>
|
|
`).join('')}
|
|
</div>
|
|
`;
|
|
});
|
|
|
|
|
|
document.getElementById('analyze-resume').addEventListener('click', function() {
|
|
|
|
alert('In a complete app, this would analyze your resume for ATS compatibility and suggest improvements.');
|
|
});
|
|
|
|
|
|
document.getElementById('download-pdf').addEventListener('click', function() {
|
|
|
|
alert('In a complete app, this would generate and download a PDF of your resume.');
|
|
});
|
|
}); |