ikun520 commited on
Commit
77b728e
·
verified ·
1 Parent(s): 1ce82f9

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +14 -1
templates/index.html CHANGED
@@ -325,20 +325,33 @@
325
  </div>
326
 
327
  <script>
328
- let currentWeek = 1;
329
  function navigateToSection() {
330
  // 你可以在这里定义按钮点击后的行为,例如跳转到一个新的页面
331
  window.location.href = "https://ikun520-teachers.hf.space/"; // 这是一个例子,可以根据需要调整
332
  }
 
 
333
  function initializeWeeks() {
334
  const weekSelect = document.getElementById("week-select");
335
  for (let i = 1; i <= 18; i++) {
336
  const option = document.createElement("option");
337
  option.value = i;
338
  option.textContent = `第${i}周`;
 
 
 
339
  weekSelect.appendChild(option);
340
  }
341
  }
 
 
 
 
 
 
 
 
342
  function loadClasses() {
343
  const gradeSelect = document.getElementById("grade-select").value;
344
  fetch(`/api/classes`)
 
325
  </div>
326
 
327
  <script>
328
+
329
  function navigateToSection() {
330
  // 你可以在这里定义按钮点击后的行为,例如跳转到一个新的页面
331
  window.location.href = "https://ikun520-teachers.hf.space/"; // 这是一个例子,可以根据需要调整
332
  }
333
+ let currentWeek = getCurrentWeek(); // 使用 getCurrentWeek() 函数获取当前周次
334
+
335
  function initializeWeeks() {
336
  const weekSelect = document.getElementById("week-select");
337
  for (let i = 1; i <= 18; i++) {
338
  const option = document.createElement("option");
339
  option.value = i;
340
  option.textContent = `第${i}周`;
341
+ if (i === currentWeek) {
342
+ option.selected = true; // 默认选中当前周次
343
+ }
344
  weekSelect.appendChild(option);
345
  }
346
  }
347
+
348
+ function getCurrentWeek() {
349
+ const firstWeekStartDate = new Date("2024-09-02"); // 假设第一周从2024年9月2日(周一)开始
350
+ const today = new Date();
351
+ const timeDifference = today - firstWeekStartDate;
352
+ const daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24));
353
+ return Math.floor(daysDifference / 7) + 1; // 根据天数计算当前周次
354
+ }
355
  function loadClasses() {
356
  const gradeSelect = document.getElementById("grade-select").value;
357
  fetch(`/api/classes`)