diff --git a/RANK.html b/RANK.html index eb9f529..6b6e7ac 100644 --- a/RANK.html +++ b/RANK.html @@ -21,9 +21,12 @@

该页面展示得分前五名和最近三十次提交成功的数据(包括零分)。

数据非实时刷新,可能有最长五分钟的延迟。

详细日志信息点击「查看详情」即可查看。

-

说明

-

挑战赛榜单正在施工中……暂时仅展示 kNN 挑战赛排行榜……

-

前十名排行榜

+

榜单选择

+

当前展示 榜单 +

前十名排行榜

这里展示得分前十名的数据。

以得分排序,分数高的靠前,若分数相同,则运行时间短的靠前。


diff --git a/RANK.md b/RANK.md index 3108bac..c541a0e 100644 --- a/RANK.md +++ b/RANK.md @@ -6,9 +6,12 @@ 详细日志信息点击「查看详情」即可查看。 -## 说明 +## 榜单选择 -挑战赛榜单正在施工中……**暂时**仅展示 kNN 挑战赛排行榜…… +当前展示 榜单 ## 前十名排行榜 diff --git a/get_scores.js b/get_scores.js index 89d311c..aceecc5 100644 --- a/get_scores.js +++ b/get_scores.js @@ -1,50 +1,39 @@ const BACKEND_URL = "https://rank.intcplab.cn"; +// 获取数据的函数 async function fetchScoresData(para, project, inject) { try { const response = await fetch(`${BACKEND_URL}/get_scores/${project}?sort_by=${para}`); const data = await response.json(); const tableBody = document.getElementById(`${inject}`); - tableBody.innerHTML = ""; + tableBody.innerHTML = ""; // 清空现有表格内容 data.forEach((item, index) => { const row = document.createElement("tr"); row.innerHTML = ` - ${item.time} - ${item.id} - ${item.name} - ${item.score.toFixed(2)} - ${item.running_time} - - - - `; + ${item.time} + ${item.id} + ${item.name} + ${item.score.toFixed(2)} + ${item.running_time} + + + + `; tableBody.appendChild(row); }); - - const modal = document.getElementById("detailsModal"); - const span = document.getElementsByClassName("close")[0]; - span.onclick = function () { - modal.style.display = "none"; - }; - - window.onclick = function (event) { - if (event.target === modal) { - modal.style.display = "none"; - } - }; } catch (error) { console.error("获取数据时发生错误:", error); } } +// 显示详情的函数 function showDetailsModal(para, project, index) { const modal = document.getElementById("detailsModal"); const modalDetails = document.getElementById("modal-details"); - console.log(para, index); fetch(`${BACKEND_URL}/get_scores/${project}?sort_by=${para}`) .then((response) => response.json()) .then((data) => { @@ -53,5 +42,24 @@ function showDetailsModal(para, project, index) { }); } -window.onload = fetchScoresData("score", "challenge_knn", "top-data-table-body"); -window.onload = fetchScoresData("time", "challenge_knn", "recent-data-table-body"); +// 关闭模态框 +window.onclick = function (event) { + const modal = document.getElementById("detailsModal"); + if (event.target === modal || event.target === document.getElementsByClassName("close")[0]) { + modal.style.display = "none"; + } +}; + +// 当页面加载时默认加载 +window.onload = () => { + fetchScoresData("score", "challenge_knn", "top-data-table-body"); + fetchScoresData("time", "challenge_knn", "recent-data-table-body"); +}; + +// 监听下拉框 +document.getElementById("projectSelect").addEventListener("change", function () { + const selectedProject = this.value; + // 根据选择的项目加载 + fetchScoresData("score", selectedProject, "top-data-table-body"); + fetchScoresData("time", selectedProject, "recent-data-table-body"); +});