feat: add top 50 rank
chore: adjust recent commit num to 30
This commit is contained in:
+11
-8
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user