EHDEM commited on
Commit
f4d21cd
·
verified ·
1 Parent(s): eb861b3

temove the filter in students-ate.html and attendence.html and add back the students name list popup

Browse files
Files changed (2) hide show
  1. attendance.html +45 -117
  2. students-ate.html +44 -116
attendance.html CHANGED
@@ -158,56 +158,10 @@
158
  </select>
159
  </div>
160
  </div>
161
- <!-- Filter Buttons Row -->
162
- <div class="mb-4">
163
- <h3 class="text-gray-700 font-medium mb-2">Filter by Class:</h3>
164
- <div class="flex flex-wrap gap-2">
165
- <button onclick="filterByClass('')" class="px-3 py-1 rounded-full bg-blue-100 text-blue-700 hover:bg-blue-200 transition">
166
- All Classes
167
- </button>
168
- <button onclick="filterByClass('BUDI')" class="px-3 py-1 rounded-full bg-blue-100 text-blue-700 hover:bg-blue-200 transition">
169
- BUDI
170
- </button>
171
- <button onclick="filterByClass('USAHA')" class="px-3 py-1 rounded-full bg-blue-100 text-blue-700 hover:bg-blue-200 transition">
172
- USAHA
173
- </button>
174
- <button onclick="filterByClass('MAJU')" class="px-3 py-1 rounded-full bg-blue-100 text-blue-700 hover:bg-blue-200 transition">
175
- MAJU
176
- </button>
177
- <button onclick="filterByClass('JAYA')" class="px-3 py-1 rounded-full bg-blue-100 text-blue-700 hover:bg-blue-200 transition">
178
- JAYA
179
- </button>
180
- </div>
181
- </div>
182
-
183
- <div class="mb-4">
184
- <h3 class="text-gray-700 font-medium mb-2">Filter by Form:</h3>
185
- <div class="flex flex-wrap gap-2">
186
- <button onclick="filterByForm('')" class="px-3 py-1 rounded-full bg-green-100 text-green-700 hover:bg-green-200 transition">
187
- All Forms
188
- </button>
189
- <button onclick="filterByForm('1')" class="px-3 py-1 rounded-full bg-green-100 text-green-700 hover:bg-green-200 transition">
190
- Form 1
191
- </button>
192
- <button onclick="filterByForm('2')" class="px-3 py-1 rounded-full bg-green-100 text-green-700 hover:bg-green-200 transition">
193
- Form 2
194
- </button>
195
- <button onclick="filterByForm('3')" class="px-3 py-1 rounded-full bg-green-100 text-green-700 hover:bg-green-200 transition">
196
- Form 3
197
- </button>
198
- <button onclick="filterByForm('4')" class="px-3 py-1 rounded-full bg-green-100 text-green-700 hover:bg-green-200 transition">
199
- Form 4
200
- </button>
201
- <button onclick="filterByForm('5')" class="px-3 py-1 rounded-full bg-green-100 text-green-700 hover:bg-green-200 transition">
202
- Form 5
203
- </button>
204
- </div>
205
- </div>
206
- <div id="student-container" class="hidden">
207
- <label for="student" class="block text-gray-700 font-medium mb-2">Student Name</label>
208
- <select id="student" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
209
- <option value="">Select Student</option>
210
- </select>
211
  </div>
212
  </div>
213
  <!-- Attendance Choice -->
@@ -753,80 +707,54 @@ method: 'PUT',
753
  studentContainer.classList.add('hidden');
754
  }
755
  }
756
- // Global filter variables
757
- let currentClassFilter = '';
758
- let currentFormFilter = '';
759
-
760
- function filterByClass(className) {
761
- currentClassFilter = className;
762
- updateStudentList(currentClassFilter, currentFormFilter);
763
- updateActiveClassButtons();
764
- }
 
 
 
 
765
 
766
- function filterByForm(formValue) {
767
- currentFormFilter = formValue;
768
- updateStudentList(currentClassFilter, currentFormFilter);
769
- updateActiveFormButtons();
770
- }
771
 
772
- function updateActiveClassButtons() {
773
- const classButtons = document.querySelectorAll('[onclick^="filterByClass"]');
774
- classButtons.forEach(btn => {
775
- const classValue = btn.getAttribute('onclick').match(/'([^']+)'/)[1];
776
- if (classValue === currentClassFilter) {
777
- btn.classList.remove('bg-blue-100', 'text-blue-700');
778
- btn.classList.add('bg-blue-600', 'text-white');
779
- } else {
780
- btn.classList.remove('bg-blue-600', 'text-white');
781
- btn.classList.add('bg-blue-100', 'text-blue-700');
782
- }
783
- });
784
- }
785
 
786
- function updateActiveFormButtons() {
787
- const formButtons = document.querySelectorAll('[onclick^="filterByForm"]');
788
- formButtons.forEach(btn => {
789
- const formValue = btn.getAttribute('onclick').match(/'([^']+)'/)[1];
790
- if (formValue === currentFormFilter) {
791
- btn.classList.remove('bg-green-100', 'text-green-700');
792
- btn.classList.add('bg-green-600', 'text-white');
793
- } else {
794
- btn.classList.remove('bg-green-600', 'text-white');
795
- btn.classList.add('bg-green-100', 'text-green-700');
796
- }
797
- });
798
- }
799
- function updateStudentList(filterClass = '', filterForm = '') {
800
- const studentSelect = document.getElementById('student');
801
- studentSelect.innerHTML = '<option value="">Select Student</option>';
802
-
803
- if (allStudents.length === 0) return;
804
-
805
- let filteredStudents = [...allStudents];
806
-
807
- if (filterClass) {
808
- filteredStudents = filteredStudents.filter(student => {
809
- const classMatch = student.includes(` ${filterClass}`);
810
- return classMatch;
811
  });
812
  }
813
 
814
- if (filterForm) {
815
- filteredStudents = filteredStudents.filter(student => {
816
- const formMatch = student.includes(`FORM ${filterForm}`) ||
817
- student.includes(`Form ${filterForm}`);
818
- return formMatch;
819
- });
 
820
  }
821
-
822
- filteredStudents.forEach(student => {
823
- const option = document.createElement('option');
824
- option.value = student;
825
- option.textContent = student;
826
- studentSelect.appendChild(option);
827
- });
828
- }
829
- // Function to reset the form
830
  function resetForm() {
831
  // Clear form fields
832
  document.getElementById('class').value = '';
 
158
  </select>
159
  </div>
160
  </div>
161
+ <div id="student-container" class="relative">
162
+ <label for="student-search" class="block text-gray-700 font-medium mb-2">Student Name</label>
163
+ <input type="text" id="student-search" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Search student name...">
164
+ <div id="student-results" class="absolute z-10 w-full mt-1 bg-white border border-gray-300 rounded-lg shadow-lg hidden max-h-60 overflow-y-auto"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  </div>
166
  </div>
167
  <!-- Attendance Choice -->
 
707
  studentContainer.classList.add('hidden');
708
  }
709
  }
710
+ // Student search functionality
711
+ document.getElementById('student-search').addEventListener('input', function() {
712
+ const searchTerm = this.value.toLowerCase();
713
+ const resultsContainer = document.getElementById('student-results');
714
+ const classVal = document.getElementById('class').value;
715
+ const formVal = document.getElementById('form').value;
716
+
717
+ resultsContainer.innerHTML = '';
718
+
719
+ if (!classVal || !formVal) {
720
+ resultsContainer.classList.add('hidden');
721
+ return;
722
+ }
723
 
724
+ if (searchTerm.length < 2) {
725
+ resultsContainer.classList.add('hidden');
726
+ return;
727
+ }
 
728
 
729
+ const filteredStudents = studentsByForm[formVal][classVal].filter(student =>
730
+ student.toLowerCase().includes(searchTerm)
731
+ );
 
 
 
 
 
 
 
 
 
 
732
 
733
+ if (filteredStudents.length === 0) {
734
+ resultsContainer.innerHTML = '<div class="p-2 text-gray-500">No students found</div>';
735
+ } else {
736
+ filteredStudents.forEach(student => {
737
+ const div = document.createElement('div');
738
+ div.className = 'p-2 hover:bg-gray-100 cursor-pointer';
739
+ div.textContent = student;
740
+ div.onclick = () => {
741
+ document.getElementById('student-search').value = student;
742
+ resultsContainer.classList.add('hidden');
743
+ };
744
+ resultsContainer.appendChild(div);
 
 
 
 
 
 
 
 
 
 
 
 
 
745
  });
746
  }
747
 
748
+ resultsContainer.classList.remove('hidden');
749
+ });
750
+
751
+ // Close dropdown when clicking outside
752
+ document.addEventListener('click', function(e) {
753
+ if (!e.target.closest('#student-container')) {
754
+ document.getElementById('student-results').classList.add('hidden');
755
  }
756
+ });
757
+ // Function to reset the form
 
 
 
 
 
 
 
758
  function resetForm() {
759
  // Clear form fields
760
  document.getElementById('class').value = '';
students-ate.html CHANGED
@@ -127,56 +127,10 @@
127
  </select>
128
  </div>
129
  </div>
130
- <!-- Filter Buttons Row -->
131
- <div class="mb-4">
132
- <h3 class="text-gray-700 font-medium mb-2">Filter by Class:</h3>
133
- <div class="flex flex-wrap gap-2">
134
- <button onclick="filterByClass('')" class="px-3 py-1 rounded-full bg-blue-100 text-blue-700 hover:bg-blue-200 transition">
135
- All Classes
136
- </button>
137
- <button onclick="filterByClass('BUDI')" class="px-3 py-1 rounded-full bg-blue-100 text-blue-700 hover:bg-blue-200 transition">
138
- BUDI
139
- </button>
140
- <button onclick="filterByClass('USAHA')" class="px-3 py-1 rounded-full bg-blue-100 text-blue-700 hover:bg-blue-200 transition">
141
- USAHA
142
- </button>
143
- <button onclick="filterByClass('MAJU')" class="px-3 py-1 rounded-full bg-blue-100 text-blue-700 hover:bg-blue-200 transition">
144
- MAJU
145
- </button>
146
- <button onclick="filterByClass('JAYA')" class="px-3 py-1 rounded-full bg-blue-100 text-blue-700 hover:bg-blue-200 transition">
147
- JAYA
148
- </button>
149
- </div>
150
- </div>
151
-
152
- <div class="mb-4">
153
- <h3 class="text-gray-700 font-medium mb-2">Filter by Form:</h3>
154
- <div class="flex flex-wrap gap-2">
155
- <button onclick="filterByForm('')" class="px-3 py-1 rounded-full bg-green-100 text-green-700 hover:bg-green-200 transition">
156
- All Forms
157
- </button>
158
- <button onclick="filterByForm('1')" class="px-3 py-1 rounded-full bg-green-100 text-green-700 hover:bg-green-200 transition">
159
- Form 1
160
- </button>
161
- <button onclick="filterByForm('2')" class="px-3 py-1 rounded-full bg-green-100 text-green-700 hover:bg-green-200 transition">
162
- Form 2
163
- </button>
164
- <button onclick="filterByForm('3')" class="px-3 py-1 rounded-full bg-green-100 text-green-700 hover:bg-green-200 transition">
165
- Form 3
166
- </button>
167
- <button onclick="filterByForm('4')" class="px-3 py-1 rounded-full bg-green-100 text-green-700 hover:bg-green-200 transition">
168
- Form 4
169
- </button>
170
- <button onclick="filterByForm('5')" class="px-3 py-1 rounded-full bg-green-100 text-green-700 hover:bg-green-200 transition">
171
- Form 5
172
- </button>
173
- </div>
174
- </div>
175
- <div id="student-container" class="hidden">
176
- <label for="student" class="block text-gray-700 font-medium mb-2">Student Name</label>
177
- <select id="student" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
178
- <option value="">Select Student</option>
179
- </select>
180
  </div>
181
  </div>
182
 
@@ -690,79 +644,53 @@ method: 'PUT',
690
  studentContainer.classList.add('hidden');
691
  }
692
  }
693
- // Global filter variables
694
- let currentClassFilter = '';
695
- let currentFormFilter = '';
696
-
697
- function filterByClass(className) {
698
- currentClassFilter = className;
699
- updateStudentList(currentClassFilter, currentFormFilter);
700
- updateActiveClassButtons();
701
- }
 
 
 
 
702
 
703
- function filterByForm(formValue) {
704
- currentFormFilter = formValue;
705
- updateStudentList(currentClassFilter, currentFormFilter);
706
- updateActiveFormButtons();
707
- }
708
 
709
- function updateActiveClassButtons() {
710
- const classButtons = document.querySelectorAll('[onclick^="filterByClass"]');
711
- classButtons.forEach(btn => {
712
- const classValue = btn.getAttribute('onclick').match(/'([^']+)'/)[1];
713
- if (classValue === currentClassFilter) {
714
- btn.classList.remove('bg-blue-100', 'text-blue-700');
715
- btn.classList.add('bg-blue-600', 'text-white');
716
- } else {
717
- btn.classList.remove('bg-blue-600', 'text-white');
718
- btn.classList.add('bg-blue-100', 'text-blue-700');
719
- }
720
- });
721
- }
722
 
723
- function updateActiveFormButtons() {
724
- const formButtons = document.querySelectorAll('[onclick^="filterByForm"]');
725
- formButtons.forEach(btn => {
726
- const formValue = btn.getAttribute('onclick').match(/'([^']+)'/)[1];
727
- if (formValue === currentFormFilter) {
728
- btn.classList.remove('bg-green-100', 'text-green-700');
729
- btn.classList.add('bg-green-600', 'text-white');
730
- } else {
731
- btn.classList.remove('bg-green-600', 'text-white');
732
- btn.classList.add('bg-green-100', 'text-green-700');
733
- }
734
- });
735
- }
736
- function updateStudentList(filterClass = '', filterForm = '') {
737
- const studentSelect = document.getElementById('student');
738
- studentSelect.innerHTML = '<option value="">Select Student</option>';
739
-
740
- if (allStudents.length === 0) return;
741
-
742
- let filteredStudents = [...allStudents];
743
-
744
- if (filterClass) {
745
- filteredStudents = filteredStudents.filter(student => {
746
- const classMatch = student.includes(` ${filterClass}`);
747
- return classMatch;
748
  });
749
  }
750
 
751
- if (filterForm) {
752
- filteredStudents = filteredStudents.filter(student => {
753
- const formMatch = student.includes(`FORM ${filterForm}`) ||
754
- student.includes(`Form ${filterForm}`);
755
- return formMatch;
756
- });
 
757
  }
758
-
759
- filteredStudents.forEach(student => {
760
- const option = document.createElement('option');
761
- option.value = student;
762
- option.textContent = student;
763
- studentSelect.appendChild(option);
764
- });
765
- }
766
  // Function to reset the form
767
  function resetForm() {
768
  // Clear form fields
 
127
  </select>
128
  </div>
129
  </div>
130
+ <div id="student-container" class="relative">
131
+ <label for="student-search" class="block text-gray-700 font-medium mb-2">Student Name</label>
132
+ <input type="text" id="student-search" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Search student name...">
133
+ <div id="student-results" class="absolute z-10 w-full mt-1 bg-white border border-gray-300 rounded-lg shadow-lg hidden max-h-60 overflow-y-auto"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  </div>
135
  </div>
136
 
 
644
  studentContainer.classList.add('hidden');
645
  }
646
  }
647
+ // Student search functionality
648
+ document.getElementById('student-search').addEventListener('input', function() {
649
+ const searchTerm = this.value.toLowerCase();
650
+ const resultsContainer = document.getElementById('student-results');
651
+ const classVal = document.getElementById('class').value;
652
+ const formVal = document.getElementById('form').value;
653
+
654
+ resultsContainer.innerHTML = '';
655
+
656
+ if (!classVal || !formVal) {
657
+ resultsContainer.classList.add('hidden');
658
+ return;
659
+ }
660
 
661
+ if (searchTerm.length < 2) {
662
+ resultsContainer.classList.add('hidden');
663
+ return;
664
+ }
 
665
 
666
+ const filteredStudents = studentsByForm[formVal][classVal].filter(student =>
667
+ student.toLowerCase().includes(searchTerm)
668
+ );
 
 
 
 
 
 
 
 
 
 
669
 
670
+ if (filteredStudents.length === 0) {
671
+ resultsContainer.innerHTML = '<div class="p-2 text-gray-500">No students found</div>';
672
+ } else {
673
+ filteredStudents.forEach(student => {
674
+ const div = document.createElement('div');
675
+ div.className = 'p-2 hover:bg-gray-100 cursor-pointer';
676
+ div.textContent = student;
677
+ div.onclick = () => {
678
+ document.getElementById('student-search').value = student;
679
+ resultsContainer.classList.add('hidden');
680
+ };
681
+ resultsContainer.appendChild(div);
 
 
 
 
 
 
 
 
 
 
 
 
 
682
  });
683
  }
684
 
685
+ resultsContainer.classList.remove('hidden');
686
+ });
687
+
688
+ // Close dropdown when clicking outside
689
+ document.addEventListener('click', function(e) {
690
+ if (!e.target.closest('#student-container')) {
691
+ document.getElementById('student-results').classList.add('hidden');
692
  }
693
+ });
 
 
 
 
 
 
 
694
  // Function to reset the form
695
  function resetForm() {
696
  // Clear form fields