Conflict Resolution Assistant
Generated Resolution Plan
The generated plan will appear below. You can click the text to make edits before downloading.
Your plan will appear here. Go to the "Define Conflict" tab to get started.
Analyzing and generating plan...
Describe the Conflict
Sorry, an error occurred. Please try again.
`; } finally { showLoading(false); } }; const callGenerativeAPI = async (prompt, data) => { // --- SIMULATED API CALL --- return new Promise(resolve => { setTimeout(() => { const partiesList = data.parties.split(',').map(p => `Conflict Summary
A disagreement has arisen between ${escapeHTML(data.parties)} regarding ${escapeHTML(data.problem.toLowerCase())}. The core issue appears to stem from differing expectations and communication gaps.
Key Perspectives
-
${partiesList || '
- No specific parties listed. '}
Proposed Solutions
-
${solutionsList || '
- No initial solutions provided. '}
- Conduct a facilitated mediation session.
- Establish clearer communication protocols.
Recommended Action Steps
- Schedule a Meeting: All involved parties should meet within the next 48 hours to discuss this plan.
- Acknowledge Perspectives: Begin the meeting by allowing each party to state their perspective without interruption.
- Identify Common Ground: Work together to find areas of agreement and shared goals.
- Select a Solution: Collaboratively decide on one or more of the proposed solutions to implement.
- Define Next Steps: Assign clear, actionable tasks with deadlines and owners to implement the chosen solution.
- Follow-Up: Schedule a follow-up meeting in one week to review progress and make adjustments.
${content.innerHTML}
`;
elements.pdfContent.classList.remove('hidden');
try {
const canvas = await html2canvas(elements.pdfContent, { scale: 2 });
const imgData = canvas.toDataURL('image/png');
const pdf = new jsPDF('p', 'pt', 'a4');
const imgProps = pdf.getImageProperties(imgData);
const pdfWidth = pdf.internal.pageSize.getWidth();
const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width;
pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight);
pdf.save('conflict-resolution-plan.pdf');
} catch (error) {
console.error("PDF Error:", error);
} finally {
elements.pdfContent.classList.add('hidden');
}
};
const escapeHTML = (str) => str.replace(/[&<>'"]/g, tag => ({'&': '&','<': '<','>': '>',"'": ''','"': '"'}[tag]));
// --- EVENT HANDLERS ---
elements.tabButtons.dashboard.addEventListener('click', () => switchTab('dashboard'));
elements.tabButtons.input.addEventListener('click', () => switchTab('input'));
elements.prevBtn.addEventListener('click', () => { const i = TABS.indexOf(activeTab); if (i > 0) switchTab(TABS[i - 1]); });
elements.nextBtn.addEventListener('click', () => { const i = TABS.indexOf(activeTab); if (i < TABS.length - 1) switchTab(TABS[i + 1]); });
elements.conflictForm.addEventListener('submit', handleGeneratePlan);
elements.downloadPdfBtn.addEventListener('click', downloadPDF);
// Save data on input change
['conflict-problem', 'conflict-parties', 'conflict-perspectives', 'conflict-solutions'].forEach(id => {
document.getElementById(id).addEventListener('input', saveData);
});
// --- INITIALIZATION ---
loadData();
switchTab('dashboard');
});
