Update templates/index.html
Browse files- templates/index.html +17 -8
templates/index.html
CHANGED
|
@@ -322,18 +322,27 @@
|
|
| 322 |
</div>
|
| 323 |
|
| 324 |
<script>
|
| 325 |
-
let currentWeek =
|
| 326 |
|
| 327 |
function initializeWeeks() {
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
|
|
|
| 334 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 335 |
}
|
| 336 |
-
|
| 337 |
function loadTeachers() {
|
| 338 |
fetch(`/api/teachers`) // 请求教师列表的API
|
| 339 |
.then(response => response.json())
|
|
|
|
| 322 |
</div>
|
| 323 |
|
| 324 |
<script>
|
| 325 |
+
let currentWeek = getCurrentWeek(); // 使用 getCurrentWeek() 函数获取当前周次
|
| 326 |
|
| 327 |
function initializeWeeks() {
|
| 328 |
+
const weekSelect = document.getElementById("week-select");
|
| 329 |
+
for (let i = 1; i <= 18; i++) {
|
| 330 |
+
const option = document.createElement("option");
|
| 331 |
+
option.value = i;
|
| 332 |
+
option.textContent = `第${i}周`;
|
| 333 |
+
if (i === currentWeek) {
|
| 334 |
+
option.selected = true; // 默认选中当前周次
|
| 335 |
}
|
| 336 |
+
weekSelect.appendChild(option);
|
| 337 |
+
}
|
| 338 |
+
}
|
| 339 |
+
function getCurrentWeek() {
|
| 340 |
+
const firstWeekStartDate = new Date("2024-09-02"); // 假设第一周从2024年9月2日(周一)开始
|
| 341 |
+
const today = new Date();
|
| 342 |
+
const timeDifference = today - firstWeekStartDate;
|
| 343 |
+
const daysDifference = Math.floor(timeDifference / (1000 * 60 * 60 * 24));
|
| 344 |
+
return Math.floor(daysDifference / 7) + 1; // 根据天数计算当前周次
|
| 345 |
}
|
|
|
|
| 346 |
function loadTeachers() {
|
| 347 |
fetch(`/api/teachers`) // 请求教师列表的API
|
| 348 |
.then(response => response.json())
|