eubottura commited on
Commit
46fe10c
·
verified ·
1 Parent(s): 7a06c05

e como sei que tá aplicado?

Browse files
Files changed (3) hide show
  1. index.html +32 -8
  2. script.js +117 -6
  3. style.css +73 -1
index.html CHANGED
@@ -93,15 +93,26 @@
93
  <div id="results-container" class="hidden">
94
  <h3 class="text-lg font-medium text-gray-700 mb-2">Corrected Files</h3>
95
  <div id="file-list" class="space-y-2 mb-4"></div>
96
- <div class="flex gap-2">
97
- <button id="download-all" class="flex-1 bg-secondary text-white py-2 rounded-lg hover:bg-purple-600 transition-colors">
98
- Download All Files
99
- </button>
100
- <button id="apply-changes" class="flex-1 bg-green-500 text-white py-2 rounded-lg hover:bg-green-600 transition-colors">
101
- Apply Changes to Project
102
- </button>
103
  </div>
 
104
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
  <!-- Code Output -->
107
  <div id="output-container" class="hidden">
@@ -112,7 +123,20 @@
112
  <div id="error-container" class="hidden bg-red-50 border border-red-200 rounded-lg p-4">
113
  <p class="text-red-700"></p>
114
  </div>
115
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  </div>
117
  </div>
118
  <script src="script.js"></script>
 
93
  <div id="results-container" class="hidden">
94
  <h3 class="text-lg font-medium text-gray-700 mb-2">Corrected Files</h3>
95
  <div id="file-list" class="space-y-2 mb-4"></div>
96
+ <div class="mb-4 p-4 bg-blue-50 border border-blue-200 rounded-lg hidden" id="applied-status">
97
+ <div class="flex items-center">
98
+ <i data-feather="check-circle" class="w-5 h-5 text-green-600 mr-2"></i>
99
+ <span class="text-blue-800 font-medium">Changes Applied Successfully!</span>
 
 
 
100
  </div>
101
+ <p class="text-sm text-blue-700 mt-1" id="applied-summary"></p>
102
  </div>
103
+
104
+ <div class="flex gap-2">
105
+ <button id="download-all" class="flex-1 bg-secondary text-white py-2 rounded-lg hover:bg-purple-600 transition-colors">
106
+ Download All Files
107
+ </button>
108
+ <button id="apply-changes" class="flex-1 bg-green-500 text-white py-2 rounded-lg hover:bg-green-600 transition-colors">
109
+ Apply Changes to Project
110
+ </button>
111
+ <button id="view-changes" class="flex-1 bg-blue-500 text-white py-2 rounded-lg hover:bg-blue-600 transition-colors hidden">
112
+ View Changes Summary
113
+ </button>
114
+ </div>
115
+ </div>
116
 
117
  <!-- Code Output -->
118
  <div id="output-container" class="hidden">
 
123
  <div id="error-container" class="hidden bg-red-50 border border-red-200 rounded-lg p-4">
124
  <p class="text-red-700"></p>
125
  </div>
126
+
127
+ <!-- Changes Summary Modal -->
128
+ <div id="changes-modal" class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
129
+ <div class="bg-white rounded-lg p-6 max-w-3xl max-h-[80vh] overflow-y-auto">
130
+ <div class="flex justify-between items-center mb-4">
131
+ <h3 class="text-xl font-bold text-gray-800">Applied Changes Summary</h3>
132
+ <button id="close-modal" class="text-gray-500 hover:text-gray-700">
133
+ <i data-feather="x" class="w-6 h-6"></i>
134
+ </button>
135
+ </div>
136
+ <div id="changes-content" class="space-y-4"></div>
137
+ </div>
138
+ </div>
139
+ </div>
140
  </div>
141
  </div>
142
  <script src="script.js"></script>
script.js CHANGED
@@ -25,7 +25,13 @@ const elements = {
25
  fileList: document.getElementById('file-list'),
26
  downloadAll: document.getElementById('download-all'),
27
  applyChanges: document.getElementById('apply-changes'),
28
- errorContainer: document.getElementById('error-container')
 
 
 
 
 
 
29
  };
30
  // Initialize the app
31
  document.addEventListener('DOMContentLoaded', () => {
@@ -44,10 +50,16 @@ function setupEventListeners() {
44
 
45
  // Start analysis
46
  elements.startAnalysis.addEventListener('click', startAnalysis);
47
-
48
  // Download and apply changes
49
  elements.downloadAll.addEventListener('click', downloadAllFiles);
50
  elements.applyChanges.addEventListener('click', applyChangesToProject);
 
 
 
 
 
 
 
51
  }
52
  // File handling functions
53
  function handleDragOver(e) {
@@ -434,12 +446,53 @@ function applyChangesToProject() {
434
  return;
435
  }
436
 
 
 
 
437
  // Apply corrected content to the file contents map
438
  state.correctedFiles.forEach(file => {
 
439
  state.fileContents.set(file.path, file.content);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
440
  });
441
 
 
 
 
 
 
442
  showNotification(`AI corrections applied to ${state.correctedFiles.length} file(s)!`, 'success');
 
 
 
443
  }
444
  // Render results
445
  function renderResults(files) {
@@ -508,25 +561,83 @@ async function downloadAllFiles() {
508
  showError('No corrected files available for download');
509
  }
510
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
511
  // Show notification
512
  function showNotification(message, type = 'info') {
513
  // Create notification element
514
  const notification = document.createElement('div');
515
- notification.className = `fixed top-4 right-4 px-6 py-4 rounded-lg shadow-lg text-white z-50 ${
516
  type === 'success' ? 'bg-green-500' :
517
  type === 'error' ? 'bg-red-500' :
518
  'bg-blue-500'
519
  }`;
520
- notification.textContent = message;
 
 
 
 
 
 
521
 
522
  document.body.appendChild(notification);
 
 
 
 
 
 
 
 
 
523
 
524
  // Remove after delay
525
  setTimeout(() => {
526
- notification.remove();
 
 
 
527
  }, 3000);
528
  }
529
-
530
  // Show error
531
  function showError(message) {
532
  elements.errorContainer.querySelector('p').textContent = message;
 
25
  fileList: document.getElementById('file-list'),
26
  downloadAll: document.getElementById('download-all'),
27
  applyChanges: document.getElementById('apply-changes'),
28
+ errorContainer: document.getElementById('error-container'),
29
+ appliedStatus: document.getElementById('applied-status'),
30
+ appliedSummary: document.getElementById('applied-summary'),
31
+ viewChanges: document.getElementById('view-changes'),
32
+ changesModal: document.getElementById('changes-modal'),
33
+ changesContent: document.getElementById('changes-content'),
34
+ closeModal: document.getElementById('close-modal')
35
  };
36
  // Initialize the app
37
  document.addEventListener('DOMContentLoaded', () => {
 
50
 
51
  // Start analysis
52
  elements.startAnalysis.addEventListener('click', startAnalysis);
 
53
  // Download and apply changes
54
  elements.downloadAll.addEventListener('click', downloadAllFiles);
55
  elements.applyChanges.addEventListener('click', applyChangesToProject);
56
+ elements.viewChanges.addEventListener('click', showChangesSummary);
57
+ elements.closeModal.addEventListener('click', hideChangesSummary);
58
+ elements.changesModal.addEventListener('click', (e) => {
59
+ if (e.target === elements.changesModal) {
60
+ hideChangesSummary();
61
+ }
62
+ });
63
  }
64
  // File handling functions
65
  function handleDragOver(e) {
 
446
  return;
447
  }
448
 
449
+ // Store original contents for comparison
450
+ const changesMade = [];
451
+
452
  // Apply corrected content to the file contents map
453
  state.correctedFiles.forEach(file => {
454
+ const originalContent = state.fileContents.get(file.path);
455
  state.fileContents.set(file.path, file.content);
456
+
457
+ // Track changes
458
+ changesMade.push({
459
+ path: file.path,
460
+ originalLength: originalContent ? originalContent.length : 0,
461
+ newLength: file.content.length,
462
+ diff: file.content.length - (originalContent ? originalContent.length : 0)
463
+ });
464
+ });
465
+
466
+ // Update UI to show changes applied
467
+ elements.appliedStatus.classList.remove('hidden');
468
+ elements.appliedSummary.textContent = `${state.correctedFiles.length} file(s) updated successfully`;
469
+ elements.viewChanges.classList.remove('hidden');
470
+
471
+ // Update file list to show applied status
472
+ document.querySelectorAll('#file-list .flex').forEach((item, index) => {
473
+ if (index < state.correctedFiles.length) {
474
+ const statusBadge = document.createElement('span');
475
+ statusBadge.className = 'ml-2 px-2 py-1 text-xs bg-green-100 text-green-800 rounded-full';
476
+ statusBadge.textContent = 'Applied';
477
+ item.appendChild(statusBadge);
478
+
479
+ // Add checkmark icon
480
+ const icon = document.createElement('i');
481
+ icon.setAttribute('data-feather', 'check');
482
+ icon.className = 'w-4 h-4 text-green-600 ml-2';
483
+ item.appendChild(icon);
484
+ }
485
  });
486
 
487
+ feather.replace();
488
+
489
+ // Store changes for modal view
490
+ state.changesMade = changesMade;
491
+
492
  showNotification(`AI corrections applied to ${state.correctedFiles.length} file(s)!`, 'success');
493
+
494
+ // Scroll to applied status
495
+ elements.appliedStatus.scrollIntoView({ behavior: 'smooth', block: 'center' });
496
  }
497
  // Render results
498
  function renderResults(files) {
 
561
  showError('No corrected files available for download');
562
  }
563
  }
564
+ // Show changes summary modal
565
+ function showChangesSummary() {
566
+ if (!state.changesMade || state.changesMade.length === 0) {
567
+ showError('No changes to display');
568
+ return;
569
+ }
570
+
571
+ elements.changesContent.innerHTML = '';
572
+
573
+ state.changesMade.forEach(change => {
574
+ const changeElement = document.createElement('div');
575
+ changeElement.className = 'border rounded-lg p-4 bg-gray-50';
576
+
577
+ const diffClass = change.diff > 0 ? 'text-green-600' : change.diff < 0 ? 'text-red-600' : 'text-gray-600';
578
+ const diffSymbol = change.diff > 0 ? '+' : change.diff < 0 ? '-' : '';
579
+
580
+ changeElement.innerHTML = `
581
+ <div class="flex justify-between items-start mb-2">
582
+ <h4 class="font-semibold text-gray-800">${change.path}</h4>
583
+ <span class="${diffClass} font-medium">${diffSymbol}${change.diff} chars</span>
584
+ </div>
585
+ <div class="text-sm text-gray-600">
586
+ <p>Original: ${change.originalLength} characters</p>
587
+ <p>New: ${change.newLength} characters</p>
588
+ <p class="mt-2 text-xs text-gray-500">
589
+ ${change.diff > 0 ? 'Content added' : change.diff < 0 ? 'Content removed' : 'No size change'}
590
+ </p>
591
+ </div>
592
+ `;
593
+
594
+ elements.changesContent.appendChild(changeElement);
595
+ });
596
+
597
+ elements.changesModal.classList.remove('hidden');
598
+ }
599
+
600
+ // Hide changes summary modal
601
+ function hideChangesSummary() {
602
+ elements.changesModal.classList.add('hidden');
603
+ }
604
+
605
  // Show notification
606
  function showNotification(message, type = 'info') {
607
  // Create notification element
608
  const notification = document.createElement('div');
609
+ notification.className = `fixed top-4 right-4 px-6 py-4 rounded-lg shadow-lg text-white z-50 flex items-center ${
610
  type === 'success' ? 'bg-green-500' :
611
  type === 'error' ? 'bg-red-500' :
612
  'bg-blue-500'
613
  }`;
614
+
615
+ const icon = type === 'success' ? 'check-circle' : type === 'error' ? 'alert-circle' : 'info';
616
+
617
+ notification.innerHTML = `
618
+ <i data-feather="${icon}" class="w-5 h-5 mr-3"></i>
619
+ <span>${message}</span>
620
+ `;
621
 
622
  document.body.appendChild(notification);
623
+ feather.replace();
624
+
625
+ // Animate in
626
+ notification.style.transform = 'translateX(100%)';
627
+ notification.style.transition = 'transform 0.3s ease-out';
628
+
629
+ setTimeout(() => {
630
+ notification.style.transform = 'translateX(0)';
631
+ }, 10);
632
 
633
  // Remove after delay
634
  setTimeout(() => {
635
+ notification.style.transform = 'translateX(100%)';
636
+ setTimeout(() => {
637
+ notification.remove();
638
+ }, 300);
639
  }, 3000);
640
  }
 
641
  // Show error
642
  function showError(message) {
643
  elements.errorContainer.querySelector('p').textContent = message;
style.css CHANGED
@@ -74,9 +74,81 @@ button:disabled {
74
  opacity: 0.5;
75
  cursor: not-allowed;
76
  }
77
-
78
  /* File item hover effects */
79
  .file-item:hover {
80
  background-color: #f9fafb;
81
  border-color: #6366f1;
82
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  opacity: 0.5;
75
  cursor: not-allowed;
76
  }
 
77
  /* File item hover effects */
78
  .file-item:hover {
79
  background-color: #f9fafb;
80
  border-color: #6366f1;
81
  }
82
+
83
+ /* Applied status animations */
84
+ #applied-status {
85
+ animation: slideIn 0.5s ease-out;
86
+ }
87
+
88
+ @keyframes slideIn {
89
+ from {
90
+ opacity: 0;
91
+ transform: translateY(-10px);
92
+ }
93
+ to {
94
+ opacity: 1;
95
+ transform: translateY(0);
96
+ }
97
+ }
98
+
99
+ /* Modal styles */
100
+ #changes-modal {
101
+ animation: fadeIn 0.3s ease-out;
102
+ }
103
+
104
+ @keyframes fadeIn {
105
+ from {
106
+ opacity: 0;
107
+ }
108
+ to {
109
+ opacity: 1;
110
+ }
111
+ }
112
+
113
+ #changes-modal > div {
114
+ animation: scaleIn 0.3s ease-out;
115
+ }
116
+
117
+ @keyframes scaleIn {
118
+ from {
119
+ transform: scale(0.9);
120
+ opacity: 0;
121
+ }
122
+ to {
123
+ transform: scale(1);
124
+ opacity: 1;
125
+ }
126
+ }
127
+
128
+ /* Status badge styles */
129
+ .status-badge {
130
+ animation: popIn 0.3s ease-out;
131
+ }
132
+
133
+ @keyframes popIn {
134
+ 0% {
135
+ transform: scale(0);
136
+ }
137
+ 70% {
138
+ transform: scale(1.1);
139
+ }
140
+ 100% {
141
+ transform: scale(1);
142
+ }
143
+ }
144
+
145
+ /* File item with applied status */
146
+ #file-list .flex {
147
+ position: relative;
148
+ transition: all 0.3s ease;
149
+ }
150
+
151
+ #file-list .flex:has(.status-badge) {
152
+ background-color: #f0fdf4;
153
+ border-left: 3px solid #22c55e;
154
+ }