diff --git a/index.html b/index.html index 4172647..e00c2cd 100644 --- a/index.html +++ b/index.html @@ -22,9 +22,13 @@
+
+
+ +
\ No newline at end of file diff --git a/js/index.js b/js/index.js index e90819c..40292ac 100644 --- a/js/index.js +++ b/js/index.js @@ -21,8 +21,10 @@ let tbody = document.createElement("tbody"); generateTable(); getDateOfRecords(); +getDateOfRank() setInterval(getDateOfRecords, 2000); +setInterval(getDateOfRank, 2000); function generateTable() { table.appendChild(thead); @@ -94,7 +96,7 @@ function getDateOfRecords() { }) .then(function (response) { const data = response.data; - //console.log(data); + console.log(data); // 清除原有的資料列 while (tbody.firstChild) { tbody.removeChild(tbody.firstChild); @@ -143,4 +145,33 @@ function getDateOfRecords() { .catch(function (error) { console.error('資料取得失敗:', error); }); -} \ No newline at end of file +} + + + +// 取得刀表 +function getDateOfRank() { + var dateSplit = dateInput.value.split("-"); + console.log(dateSplit); + // 取得刀表 + axios.get("https://pcredive.ray650128.com/backend/api/rank/" + dateSplit[0] + "/" + dateSplit[1] + "/" + dateSplit[2], { + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json' + } + }) + .then(function (response) { + const data = response.data; + console.log(data); + const rank = data.rank; + if (rank !== null) { + document.getElementById("rank").innerHTML = "

結算時排名:" + rank + "

"; + } else { + document.getElementById("rank").innerHTML = "

結算時排名:---

"; + } + }) + .catch(function (error) { + document.getElementById("rank").innerHTML = "

結算時排名:---

"; + console.error('資料取得失敗:', error); + }); +}