From ce69aa51297f9373c9a96b614185a6a7193ff93e Mon Sep 17 00:00:00 2001 From: Raymond Yang Date: Thu, 3 Aug 2023 22:29:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E6=AD=A5=E5=8A=A0=E5=85=A5=E6=8E=92?= =?UTF-8?q?=E5=90=8Dapi=E5=91=BC=E5=8F=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 4 ++++ js/index.js | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) 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); + }); +}