Fix JS
Browse files- static/script.js +14 -7
static/script.js
CHANGED
@@ -334,6 +334,13 @@ function createCarousel(carouselTitle, id, cards) {
|
|
334 |
|
335 |
function categorizeRequirements(max_categories) {
|
336 |
isRequirements = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
337 |
fetch("https://game4all-reqroup.hf.space/reqs/categorize_requirements", {
|
338 |
method: "POST",
|
339 |
headers: {
|
@@ -404,7 +411,7 @@ function createSingleAccordionItem(item, index, versionIndex, solutionCriticized
|
|
404 |
const criticism = item.criticism;
|
405 |
|
406 |
// Récupérer le titre de la catégorie
|
407 |
-
const categoryTitle = document.querySelector(`#category-${
|
408 |
|
409 |
// Container pour chaque solution
|
410 |
const solutionCard = document.createElement('div');
|
@@ -424,7 +431,7 @@ function createSingleAccordionItem(item, index, versionIndex, solutionCriticized
|
|
424 |
<h3 class="text-sm font-semibold text-gray-800">${categoryTitle}</h3>
|
425 |
<div class="flex items-center space-x-2 bg-white px-3 py-1 rounded-full border">
|
426 |
<button class="version-btn-left w-6 h-6 flex items-center justify-center rounded-full hover:bg-gray-100 transition-colors ${currentVersion === 1 ? 'opacity-50 cursor-not-allowed' : ''}"
|
427 |
-
data-solution-index="${
|
428 |
${currentVersion === 1 ? 'disabled' : ''}>
|
429 |
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
430 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"></path>
|
@@ -432,7 +439,7 @@ function createSingleAccordionItem(item, index, versionIndex, solutionCriticized
|
|
432 |
</button>
|
433 |
<span class="text-xs font-medium text-gray-600 min-w-[60px] text-center version-indicator">Version ${currentVersion}</span>
|
434 |
<button class="version-btn-right w-6 h-6 flex items-center justify-center rounded-full hover:bg-gray-100 transition-colors ${currentVersion === totalVersions ? 'opacity-50 cursor-not-allowed' : ''}"
|
435 |
-
data-solution-index="${
|
436 |
${currentVersion === totalVersions ? 'disabled' : ''}>
|
437 |
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
438 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path>
|
@@ -449,10 +456,10 @@ function createSingleAccordionItem(item, index, versionIndex, solutionCriticized
|
|
449 |
// Contenu de l'accordéon
|
450 |
const content = document.createElement('div');
|
451 |
content.className = `accordion-content px-4 py-3 space-y-3`;
|
452 |
-
content.id = `content-${
|
453 |
|
454 |
// Vérifier l'état d'ouverture précédent
|
455 |
-
const isOpen = accordionStates[
|
456 |
if (!isOpen) {
|
457 |
content.classList.add('hidden');
|
458 |
} else {
|
@@ -552,11 +559,11 @@ function createSingleAccordionItem(item, index, versionIndex, solutionCriticized
|
|
552 |
if (isCurrentlyOpen) {
|
553 |
content.classList.add('hidden');
|
554 |
icon.style.transform = 'rotate(0deg)';
|
555 |
-
accordionStates[
|
556 |
} else {
|
557 |
content.classList.remove('hidden');
|
558 |
icon.style.transform = 'rotate(180deg)';
|
559 |
-
accordionStates[
|
560 |
}
|
561 |
});
|
562 |
|
|
|
334 |
|
335 |
function categorizeRequirements(max_categories) {
|
336 |
isRequirements = false;
|
337 |
+
document.getElementById('categorizeReq').setAttribute('disabled', 'true');
|
338 |
+
document.getElementById('downloadZip').setAttribute('disabled', 'true');
|
339 |
+
document.getElementById('searchReq').setAttribute('disabled', 'true');
|
340 |
+
document.getElementById('progressText').classList.remove('hidden');
|
341 |
+
document.getElementById('loadingBar').classList.remove('hidden');
|
342 |
+
document.getElementById('progressText').textContent = "Grouping requirements by their context ...";
|
343 |
+
|
344 |
fetch("https://game4all-reqroup.hf.space/reqs/categorize_requirements", {
|
345 |
method: "POST",
|
346 |
headers: {
|
|
|
411 |
const criticism = item.criticism;
|
412 |
|
413 |
// Récupérer le titre de la catégorie
|
414 |
+
const categoryTitle = document.querySelector(`#category-${solution['Category_Id']} h2`)?.textContent || `Catégorie ${solution['Category_Id'] + 1}`;
|
415 |
|
416 |
// Container pour chaque solution
|
417 |
const solutionCard = document.createElement('div');
|
|
|
431 |
<h3 class="text-sm font-semibold text-gray-800">${categoryTitle}</h3>
|
432 |
<div class="flex items-center space-x-2 bg-white px-3 py-1 rounded-full border">
|
433 |
<button class="version-btn-left w-6 h-6 flex items-center justify-center rounded-full hover:bg-gray-100 transition-colors ${currentVersion === 1 ? 'opacity-50 cursor-not-allowed' : ''}"
|
434 |
+
data-solution-index="${solution['Category_Id']}"
|
435 |
${currentVersion === 1 ? 'disabled' : ''}>
|
436 |
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
437 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"></path>
|
|
|
439 |
</button>
|
440 |
<span class="text-xs font-medium text-gray-600 min-w-[60px] text-center version-indicator">Version ${currentVersion}</span>
|
441 |
<button class="version-btn-right w-6 h-6 flex items-center justify-center rounded-full hover:bg-gray-100 transition-colors ${currentVersion === totalVersions ? 'opacity-50 cursor-not-allowed' : ''}"
|
442 |
+
data-solution-index="${solution['Category_Id']}"
|
443 |
${currentVersion === totalVersions ? 'disabled' : ''}>
|
444 |
<svg class="w-3 h-3" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
445 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"></path>
|
|
|
456 |
// Contenu de l'accordéon
|
457 |
const content = document.createElement('div');
|
458 |
content.className = `accordion-content px-4 py-3 space-y-3`;
|
459 |
+
content.id = `content-${solution['Category_Id']}`;
|
460 |
|
461 |
// Vérifier l'état d'ouverture précédent
|
462 |
+
const isOpen = accordionStates[solution['Category_Id']] || false;
|
463 |
if (!isOpen) {
|
464 |
content.classList.add('hidden');
|
465 |
} else {
|
|
|
559 |
if (isCurrentlyOpen) {
|
560 |
content.classList.add('hidden');
|
561 |
icon.style.transform = 'rotate(0deg)';
|
562 |
+
accordionStates[solution['Category_Id']] = false;
|
563 |
} else {
|
564 |
content.classList.remove('hidden');
|
565 |
icon.style.transform = 'rotate(180deg)';
|
566 |
+
accordionStates[solution['Category_Id']] = true;
|
567 |
}
|
568 |
});
|
569 |
|