Spaces:
Sleeping
Sleeping
Update static/js/script.js
Browse files- static/js/script.js +99 -49
static/js/script.js
CHANGED
@@ -4,45 +4,45 @@ let currentHistoryIndex = -1;
|
|
4 |
// Store all refined problem suggestions
|
5 |
let storedRefinedProblems = {};
|
6 |
|
7 |
-
function generateQueries(event) {
|
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 |
function displayKeyIssues(keyIssues) {
|
48 |
// Get or create the key issues container
|
@@ -2544,24 +2544,74 @@ document.addEventListener('DOMContentLoaded', () => {
|
|
2544 |
issueCard.className = 'key-issue-card';
|
2545 |
issueCard.dataset.issueId = issue.id;
|
2546 |
|
2547 |
-
//
|
2548 |
let cardContent = `
|
2549 |
<div class="key-issue-title">${issue.title}</div>
|
2550 |
<div class="key-issue-description">${issue.description}</div>
|
2551 |
-
<
|
|
|
|
|
2552 |
`;
|
2553 |
|
2554 |
-
|
|
|
|
|
|
|
|
|
2555 |
issue.challenges.forEach(challenge => {
|
2556 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2557 |
});
|
2558 |
|
2559 |
-
|
2560 |
-
|
2561 |
-
<div class="key-issue-impact">Impact: ${issue.potential_impact}</div>
|
2562 |
-
`;
|
2563 |
-
|
2564 |
-
issueCard.innerHTML = cardContent;
|
2565 |
|
2566 |
// Add click handler to toggle selection
|
2567 |
issueCard.addEventListener('click', () => {
|
|
|
4 |
// Store all refined problem suggestions
|
5 |
let storedRefinedProblems = {};
|
6 |
|
7 |
+
// function generateQueries(event) {
|
8 |
+
// event.preventDefault();
|
9 |
+
|
10 |
+
// const userInput = document.getElementById('userInput').value.trim();
|
11 |
+
// if (!userInput) {
|
12 |
+
// alert('Please enter a technical problem description');
|
13 |
+
// return;
|
14 |
+
// }
|
15 |
+
|
16 |
+
// // Show loading indicator
|
17 |
+
// document.getElementById('loadingIndicator').style.display = 'block';
|
18 |
+
|
19 |
+
// // Send message to Flask backend
|
20 |
+
// fetch('/generate-key-issues', {
|
21 |
+
// method: 'POST',
|
22 |
+
// body: JSON.stringify({ 'query': userInput }),
|
23 |
+
// headers: { 'Content-Type': 'application/json' }
|
24 |
+
// })
|
25 |
+
// .then(response => response.json())
|
26 |
+
// .then(data => {
|
27 |
+
// // Hide loading indicator
|
28 |
+
// document.getElementById('loadingIndicator').style.display = 'none';
|
29 |
+
|
30 |
+
// // Check if we have key issues in the response
|
31 |
+
// if (data.key_issues && data.key_issues.length > 0) {
|
32 |
+
// // Display the key issues
|
33 |
+
// displayKeyIssues(data.key_issues);
|
34 |
+
// } else if (data.error) {
|
35 |
+
// alert('Error: ' + data.error);
|
36 |
+
// } else {
|
37 |
+
// alert('No key issues found. Please try a different query.');
|
38 |
+
// }
|
39 |
+
// })
|
40 |
+
// .catch(error => {
|
41 |
+
// document.getElementById('loadingIndicator').style.display = 'none';
|
42 |
+
// console.error('Error:', error);
|
43 |
+
// alert('There was an error communicating with the server. Please try again.');
|
44 |
+
// });
|
45 |
+
// }
|
46 |
|
47 |
function displayKeyIssues(keyIssues) {
|
48 |
// Get or create the key issues container
|
|
|
2544 |
issueCard.className = 'key-issue-card';
|
2545 |
issueCard.dataset.issueId = issue.id;
|
2546 |
|
2547 |
+
// Build the complete HTML structure
|
2548 |
let cardContent = `
|
2549 |
<div class="key-issue-title">${issue.title}</div>
|
2550 |
<div class="key-issue-description">${issue.description}</div>
|
2551 |
+
<div style="font-weight: bold; margin-top: 10px;">Challenges:</div>
|
2552 |
+
<div class="key-issue-challenges"></div>
|
2553 |
+
<div class="key-issue-impact">Impact: ${issue.potential_impact}</div>
|
2554 |
`;
|
2555 |
|
2556 |
+
issueCard.innerHTML = cardContent;
|
2557 |
+
|
2558 |
+
// Get the challenges list container that was just created
|
2559 |
+
const challengesList = issueCard.querySelector('.key-issue-challenges');
|
2560 |
+
|
2561 |
issue.challenges.forEach(challenge => {
|
2562 |
+
const challengeTag = document.createElement('div');
|
2563 |
+
challengeTag.className = 'challenge-tag';
|
2564 |
+
challengeTag.textContent = challenge;
|
2565 |
+
|
2566 |
+
// Add click handler to toggle selection
|
2567 |
+
challengeTag.addEventListener('click', function(e) {
|
2568 |
+
e.stopPropagation(); // Prevent triggering parent card click
|
2569 |
+
this.classList.toggle('selected');
|
2570 |
+
|
2571 |
+
// Update selected challenges data
|
2572 |
+
const selectedChallenges = JSON.parse(issueCard.dataset.selectedChallenges || '[]');
|
2573 |
+
const challengeText = this.textContent;
|
2574 |
+
|
2575 |
+
if (this.classList.contains('selected')) {
|
2576 |
+
// Add challenge to selected list if not already there
|
2577 |
+
if (!selectedChallenges.includes(challengeText)) {
|
2578 |
+
selectedChallenges.push(challengeText);
|
2579 |
+
}
|
2580 |
+
} else {
|
2581 |
+
// Remove challenge from selected list
|
2582 |
+
const index = selectedChallenges.indexOf(challengeText);
|
2583 |
+
if (index !== -1) {
|
2584 |
+
selectedChallenges.splice(index, 1);
|
2585 |
+
}
|
2586 |
+
}
|
2587 |
+
|
2588 |
+
// Update dataset
|
2589 |
+
issueCard.dataset.selectedChallenges = JSON.stringify(selectedChallenges);
|
2590 |
+
|
2591 |
+
// Update card selected state based on whether any challenges are selected
|
2592 |
+
if (selectedChallenges.length > 0) {
|
2593 |
+
issueCard.classList.add('selected');
|
2594 |
+
|
2595 |
+
// Add to selected key issues if not already there
|
2596 |
+
if (!selectedKeyIssues.some(item => item.id === issue.id)) {
|
2597 |
+
selectedKeyIssues.push(issue);
|
2598 |
+
}
|
2599 |
+
} else {
|
2600 |
+
issueCard.classList.remove('selected');
|
2601 |
+
|
2602 |
+
// Remove from selected key issues
|
2603 |
+
selectedKeyIssues = selectedKeyIssues.filter(item => item.id !== issue.id);
|
2604 |
+
}
|
2605 |
+
|
2606 |
+
// Update the comment area based on selections
|
2607 |
+
updateCommentArea();
|
2608 |
+
});
|
2609 |
+
|
2610 |
+
challengesList.appendChild(challengeTag);
|
2611 |
});
|
2612 |
|
2613 |
+
// The challenges list and impact are already in the HTML structure
|
2614 |
+
// We just need to populate the challenges list with individual challenge tags
|
|
|
|
|
|
|
|
|
2615 |
|
2616 |
// Add click handler to toggle selection
|
2617 |
issueCard.addEventListener('click', () => {
|