From 7101f715682daf6daaaffc8b96721c78dd7e4e9a Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 25 Jul 2025 22:52:32 +0530 Subject: [PATCH] Fix job posting generator frontend JavaScript issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix element ID mismatch: use 'resultsContainer' and 'resultsContent' instead of 'jobResults' and 'jobContent' - Add proper HTML element existence checks before manipulation - Add missing utility functions expected by results component (copyResults, downloadResults, resetForm) - Improve content rendering with proper HTML formatting - Fix results container display/hide logic The job posting generator should now work properly without getting stuck on processing. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .../job_posting_generator/detail.html | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/job_posting_generator/templates/job_posting_generator/detail.html b/job_posting_generator/templates/job_posting_generator/detail.html index 18b0f59..7719e0d 100644 --- a/job_posting_generator/templates/job_posting_generator/detail.html +++ b/job_posting_generator/templates/job_posting_generator/detail.html @@ -351,8 +351,8 @@ // Display results function displayResults(result) { - const resultsContainer = document.getElementById('jobResults'); - const contentElement = document.getElementById('jobContent'); + const resultsContainer = document.getElementById('resultsContainer'); + const contentElement = document.getElementById('resultsContent'); if (result.wallet_balance !== undefined) { updateWalletBalance(result.wallet_balance); @@ -364,10 +364,14 @@ } let content = result.job_posting_content || result.content || 'Job posting generated successfully!'; - JobPostingUtils.renderSecureContent(contentElement, content); + if (contentElement) { + contentElement.innerHTML = `
${content}
`; + } - resultsContainer.style.display = 'block'; - resultsContainer.scrollIntoView({ behavior: 'smooth' }); + if (resultsContainer) { + resultsContainer.style.display = 'block'; + resultsContainer.scrollIntoView({ behavior: 'smooth' }); + } showToast('✅ Job posting created successfully!', 'success'); } @@ -449,7 +453,8 @@ showProcessing(); processButton.disabled = true; - document.getElementById('jobResults').style.display = 'none'; + const resultsContainer = document.getElementById('resultsContainer'); + if (resultsContainer) resultsContainer.style.display = 'none'; fetch(window.location.href, { method: 'POST', @@ -472,5 +477,29 @@ showToast('❌ Network error', 'error'); }); }); + + // Add functions expected by the results component + function copyResults() { + const content = document.getElementById('resultsContent'); + if (content) { + const text = content.textContent || content.innerText || ''; + copyToClipboard(text, 'Job posting copied to clipboard!'); + } + } + + function downloadResults() { + const content = document.getElementById('resultsContent'); + if (content) { + const text = content.textContent || content.innerText || ''; + downloadAsFile(text, `job-posting-${Date.now()}.txt`, 'Job posting downloaded!'); + } + } + + function resetForm() { + document.getElementById('jobPostingForm').reset(); + const resultsContainer = document.getElementById('resultsContainer'); + if (resultsContainer) resultsContainer.style.display = 'none'; + document.getElementById('processButton').disabled = false; + } {% endblock %} \ No newline at end of file