From 7d7f7240d4a721c997a774de5878098649d7bc4b Mon Sep 17 00:00:00 2001 From: dginovker Date: Wed, 9 Dec 2020 08:35:42 -0500 Subject: [PATCH] Some more work --- services/m=hiscore/hiscores.html | 4 +-- services/m=hiscore/hiscores.js | 45 +++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/services/m=hiscore/hiscores.html b/services/m=hiscore/hiscores.html index 5f13d293a..bdefafe21 100644 --- a/services/m=hiscore/hiscores.html +++ b/services/m=hiscore/hiscores.html @@ -587,12 +587,12 @@ English
+ href="./hiscores.html"> U + href="./hiscores.html"> D diff --git a/services/m=hiscore/hiscores.js b/services/m=hiscore/hiscores.js index e49999e13..b3e043330 100644 --- a/services/m=hiscore/hiscores.js +++ b/services/m=hiscore/hiscores.js @@ -1,15 +1,36 @@ -for (let i = 1; i <= 22; i++) { - row = document.getElementsByClassName(`row row${i}`)[0]; +let page = 0; - row.childNodes[3].replaceWith(document.createElement("td")); - row.childNodes[3].className = "alL"; - row.childNodes[3].innerHTML = "PlayerName"; +function populateHSTable() { + for (let i = 1; i <= 22; i++) { + row = document.getElementsByClassName(`row row${i}`)[0]; - row.childNodes[5].replaceWith(document.createElement("td")); - row.childNodes[5].className = "alL"; - row.childNodes[5].innerHTML = "Level"; + row.childNodes[3].replaceWith(document.createElement("td")); + row.childNodes[3].className = "alL"; + row.childNodes[3].innerHTML = "PlayerName"; - row.childNodes[7].replaceWith(document.createElement("td")); - row.childNodes[7].className = "alL"; - row.childNodes[7].innerHTML = "XP,XP"; -} \ No newline at end of file + row.childNodes[5].replaceWith(document.createElement("td")); + row.childNodes[5].className = "alL"; + row.childNodes[5].innerHTML = "Level"; + + row.childNodes[7].replaceWith(document.createElement("td")); + row.childNodes[7].className = "alL"; + row.childNodes[7].innerHTML = "XP,XP"; + } +} + + +// Handle page arrows +document.getElementById("button-up").addEventListener("click", function (e) { + e.preventDefault(); + if (page > 0) { + page--; + } + populateHSTable(); +}); +document.getElementById("button-down").addEventListener("click", function (e) { + e.preventDefault(); + page++; + populateHSTable(); +}); + +populateHSTable(); \ No newline at end of file