krushimitravit commited on
Commit
beafc5f
·
verified ·
1 Parent(s): c103fb6

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +33 -20
templates/index.html CHANGED
@@ -417,26 +417,39 @@
417
  type: 'POST',
418
  data: $(this).serialize(),
419
  success: function (response) {
420
- if (response.predicted_crop_list) {
421
- $('#result-box').fadeIn();
422
- var resultsDiv = $('#crop-results');
423
- resultsDiv.empty();
424
-
425
- response.predicted_crop_list.forEach(function (crop) {
426
- resultsDiv.append('<div class="crop-tag">' + crop + '</div>');
427
- });
428
-
429
- // Scroll down to results
430
- $('html, body').animate({
431
- scrollTop: $('#result-box').offset().top - 50
432
- }, 800);
433
- } else if (response.error) {
434
- alert('Prediction Error: ' + response.error);
435
- }
436
-
437
- btn.html(oldText);
438
- btn.prop('disabled', false);
439
- },
 
 
 
 
 
 
 
 
 
 
 
 
 
440
  error: function () {
441
  alert('Could not connect to server.');
442
  btn.html(oldText);
 
417
  type: 'POST',
418
  data: $(this).serialize(),
419
  success: function (response) {
420
+ if (response.predicted_crop_list) {
421
+ // 1. LOGIC: Check if "All" is present in the list (case-insensitive)
422
+ const containsAll = response.predicted_crop_list.some(crop =>
423
+ crop.trim().toLowerCase() === 'all'
424
+ );
425
+
426
+ // 2. If "All" is found, hide the box and stop.
427
+ if (containsAll) {
428
+ $('#result-box').hide();
429
+ console.log("Recommendation contained 'All' - Omitted results.");
430
+ }
431
+ // 3. Otherwise, proceed to show the results normally
432
+ else {
433
+ $('#result-box').fadeIn();
434
+ var resultsDiv = $('#crop-results');
435
+ resultsDiv.empty();
436
+
437
+ response.predicted_crop_list.forEach(function (crop) {
438
+ resultsDiv.append('<div class="crop-tag">' + crop + '</div>');
439
+ });
440
+
441
+ // Scroll down to results
442
+ $('html, body').animate({
443
+ scrollTop: $('#result-box').offset().top - 50
444
+ }, 800);
445
+ }
446
+ } else if (response.error) {
447
+ alert('Prediction Error: ' + response.error);
448
+ }
449
+
450
+ btn.html(oldText);
451
+ btn.prop('disabled', false);
452
+ },
453
  error: function () {
454
  alert('Could not connect to server.');
455
  btn.html(oldText);