EHDEM commited on
Commit
c8c1f55
·
verified ·
1 Parent(s): b268241

sync the github tokens of attendance.html students-ate.html and student-management.html via config.js

Browse files
Files changed (3) hide show
  1. attendance.html +12 -13
  2. student-management.html +4 -6
  3. students-ate.html +4 -6
attendance.html CHANGED
@@ -169,19 +169,18 @@
169
  <script src="config.js"></script>
170
 
171
  <script>
172
- // === NEW: Dynamic student list loading from private GitHub repo ===
173
- let students = {}; // Will be filled from GitHub
174
-
175
- async function loadStudentList() {
176
- try {
177
- const response = await fetch(`https://api.github.com/repos/${GITHUB_CONFIG.REPOS.STUDENT_LIST || GITHUB_CONFIG.REPOS.ATTENDANCE}/contents/student-list.json`, {
178
- headers: {
179
- 'Authorization': `token ${GITHUB_CONFIG.TOKEN}`,
180
- 'Accept': 'application/vnd.github.v3+json'
181
- }
182
- });
183
-
184
- if (response.status === 404) {
185
  console.log('student-list.json not found yet – starting with empty list');
186
  students = {};
187
  loadStudents(); // Update dropdowns anyway
 
169
  <script src="config.js"></script>
170
 
171
  <script>
172
+ // Load student list from GitHub using config token
173
+ let students = {}; // Will be filled from GitHub
174
+
175
+ async function loadStudentList() {
176
+ try {
177
+ const response = await fetch(`https://api.github.com/repos/${GITHUB_CONFIG.REPOS.STUDENT_LIST || GITHUB_CONFIG.REPOS.ATTENDANCE}/contents/student-list.json`, {
178
+ headers: {
179
+ 'Authorization': `token ${GITHUB_CONFIG.TOKEN}`,
180
+ 'Accept': 'application/vnd.github.v3+json'
181
+ }
182
+ });
183
+ if (response.status === 404) {
 
184
  console.log('student-list.json not found yet – starting with empty list');
185
  students = {};
186
  loadStudents(); // Update dropdowns anyway
student-management.html CHANGED
@@ -127,7 +127,7 @@
127
  <script src="config.js"></script>
128
 
129
  <script>
130
- // === NEW: Dynamic student list loading + saving from/to private GitHub repo ===
131
  let students = {}; // Will be filled from GitHub
132
 
133
  async function loadStudentList() {
@@ -138,8 +138,7 @@
138
  'Accept': 'application/vnd.github.v3+json'
139
  }
140
  });
141
-
142
- if (response.status === 404) {
143
  console.log('student-list.json not found yet – starting with empty list');
144
  students = {};
145
  loadStudentsForRemoval();
@@ -159,7 +158,7 @@
159
  loadStudentsForRemoval();
160
  }
161
  }
162
-
163
  async function saveStudentListToGitHub() {
164
  try {
165
  // Get current file (for SHA)
@@ -170,8 +169,7 @@
170
  'Accept': 'application/vnd.github.v3+json'
171
  }
172
  });
173
-
174
- if (getResponse.ok) {
175
  const fileData = await getResponse.json();
176
  sha = fileData.sha;
177
  }
 
127
  <script src="config.js"></script>
128
 
129
  <script>
130
+ // Load student list from GitHub using config token
131
  let students = {}; // Will be filled from GitHub
132
 
133
  async function loadStudentList() {
 
138
  'Accept': 'application/vnd.github.v3+json'
139
  }
140
  });
141
+ if (response.status === 404) {
 
142
  console.log('student-list.json not found yet – starting with empty list');
143
  students = {};
144
  loadStudentsForRemoval();
 
158
  loadStudentsForRemoval();
159
  }
160
  }
161
+ // Save student list to GitHub using config token
162
  async function saveStudentListToGitHub() {
163
  try {
164
  // Get current file (for SHA)
 
169
  'Accept': 'application/vnd.github.v3+json'
170
  }
171
  });
172
+ if (getResponse.ok) {
 
173
  const fileData = await getResponse.json();
174
  sha = fileData.sha;
175
  }
students-ate.html CHANGED
@@ -141,7 +141,7 @@
141
  <script src="config.js"></script>
142
 
143
  <script>
144
- // === NEW: Dynamic student list loading from private GitHub repo ===
145
  let students = {}; // Will be filled from GitHub
146
 
147
  async function loadStudentList() {
@@ -152,8 +152,7 @@
152
  'Accept': 'application/vnd.github.v3+json'
153
  }
154
  });
155
-
156
- if (response.status === 404) {
157
  console.log('student-list.json not found yet – starting with empty list');
158
  students = {};
159
  if (typeof loadStudents === 'function') loadStudents();
@@ -398,8 +397,7 @@
398
  } else if (initialMeal === 'supper') {
399
  mealIcon.classList.add('text-purple-600');
400
  }
401
-
402
- // Function to send data to GitHub
403
  async function sendDataToGitHub(data) {
404
  try {
405
  const getResponse = await fetch(`https://api.github.com/repos/${GITHUB_CONFIG.REPOS.CONSUMED}/contents/data%20who%20has%20ate%20at%20dm`, {
@@ -408,7 +406,7 @@
408
  'Authorization': `token ${GITHUB_CONFIG.TOKEN}`
409
  }
410
  });
411
- let currentContent = '';
412
  let sha = '';
413
  if (getResponse.ok) {
414
  const fileData = await getResponse.json();
 
141
  <script src="config.js"></script>
142
 
143
  <script>
144
+ // Load student list from GitHub using config token
145
  let students = {}; // Will be filled from GitHub
146
 
147
  async function loadStudentList() {
 
152
  'Accept': 'application/vnd.github.v3+json'
153
  }
154
  });
155
+ if (response.status === 404) {
 
156
  console.log('student-list.json not found yet – starting with empty list');
157
  students = {};
158
  if (typeof loadStudents === 'function') loadStudents();
 
397
  } else if (initialMeal === 'supper') {
398
  mealIcon.classList.add('text-purple-600');
399
  }
400
+ // Function to send data to GitHub using config token
 
401
  async function sendDataToGitHub(data) {
402
  try {
403
  const getResponse = await fetch(`https://api.github.com/repos/${GITHUB_CONFIG.REPOS.CONSUMED}/contents/data%20who%20has%20ate%20at%20dm`, {
 
406
  'Authorization': `token ${GITHUB_CONFIG.TOKEN}`
407
  }
408
  });
409
+ let currentContent = '';
410
  let sha = '';
411
  if (getResponse.ok) {
412
  const fileData = await getResponse.json();