feat: add top 50 rank

chore: adjust recent commit num to 30
This commit is contained in:
2024-09-28 00:54:31 +08:00
parent f9f17867be
commit 9e95339360
4 changed files with 136 additions and 15 deletions
+11 -8
View File
@@ -1,9 +1,11 @@
async function fetchData() {
const BACKEND_URL = "https://rank.intcplab.cn";
async function fetchScoresData(para, inject) {
try {
const response = await fetch("https://rank.intcplab.cn/get_scores");
const response = await fetch(`${BACKEND_URL}/${para}`);
const data = await response.json();
const tableBody = document.getElementById("data-table-body");
const tableBody = document.getElementById(`${inject}`);
tableBody.innerHTML = "";
data.forEach((item, index) => {
@@ -16,7 +18,7 @@ async function fetchData() {
<td>${item.score}</td>
<td>${item.running_time}</td>
<td>
<button onclick="showDetailsModal(${index})">查看详情</button>
<button onclick="showDetailsModal('${para}', ${index})">查看详情</button>
</td>
`;
@@ -39,11 +41,11 @@ async function fetchData() {
}
}
function showDetailsModal(index) {
function showDetailsModal(para, index) {
const modal = document.getElementById("detailsModal");
const modalDetails = document.getElementById("modal-details");
fetch("https://rank.intcplab.cn/get_scores")
console.log(para, index);
fetch(`${BACKEND_URL}/${para}`)
.then((response) => response.json())
.then((data) => {
modalDetails.innerHTML = data[index].details + "<br><br>";
@@ -51,4 +53,5 @@ function showDetailsModal(index) {
});
}
window.onload = fetchData;
window.onload = fetchScoresData("get_top_scores", "top-data-table-body");
window.onload = fetchScoresData("get_scores", "recent-data-table-body");