diff --git a/.gitignore b/.gitignore index e61bca2..c458e60 100644 --- a/.gitignore +++ b/.gitignore @@ -103,9 +103,6 @@ venv.bak/ # Rope project settings .ropeproject -# mkdocs documentation -/site - # mypy .mypy_cache/ .dmypy.json diff --git a/site/board/board.js b/site/board/board.js new file mode 100644 index 0000000..3030cbd --- /dev/null +++ b/site/board/board.js @@ -0,0 +1,59 @@ +let load_url = "https://exmods.org/load?board=test1&count=10&start=0"; + +function build_board() { + let leaderboard = document.getElementById("leaderboard") + let leaderboard_container = document.getElementById("leaderboard-container") + let tmpEntry = {ID: -42, Rank:"?", PlayerURL: "#", PlayerName: "Loading...", Score:">9000"} + let errEntry = build_entry(tmpEntry) + leaderboard.appendChild(errEntry) + setTimeout(() => {document.getElementById("nameAnchor-42").innerText = "Something went wrong :(";}, 4000) // 5s + fetch(load_url).then( + (response) => { + if (!response.ok || (response.status) != 200) { + document.getElementById("nameAnchor-42").innerText = "Something went wrong :(" + return + } + errEntry.style.display = "none" + response.json().then( + (result) => { + leaderboard.removeChild(errEntry) + for (entry of result.Items) { + let newEntry = build_entry(entry) + // end + leaderboard.appendChild(newEntry) + } + } + ) + } + ) +} + +function build_entry(entry) { + let newEntry = document.createElement("div") + newEntry.setAttribute("id", "entry"+entry.ID) + newEntry.classList.add("board-entry") + // rank + let rankEntry = document.createElement("span") + rankEntry.setAttribute("id", "rank"+entry.ID) + rankEntry.innerText = entry.Rank + rankEntry.classList.add("board-rank") + newEntry.appendChild(rankEntry) + // name + let nameElem = document.createElement("span") + nameElem.setAttribute("id", "name"+entry.ID) + nameElem.classList.add("board-name") + let nameAElem = document.createElement("a") + nameAElem.setAttribute("id", "nameAnchor"+entry.ID) + nameAElem.classList.add("board-name-a") + nameAElem.href = entry.PlayerURL + nameAElem.innerText = entry.PlayerName + nameElem.appendChild(nameAElem) + newEntry.appendChild(nameElem) + // score + let scoreElem = document.createElement("span") + scoreElem.setAttribute("id", "score"+entry.ID) + scoreElem.classList.add("board-score") + scoreElem.innerText = entry.Score + newEntry.appendChild(scoreElem) + return newEntry +} diff --git a/site/board/index.html b/site/board/index.html new file mode 100644 index 0000000..382257a --- /dev/null +++ b/site/board/index.html @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + Exmods + + + +

Welcome to the Exmods leaderboard

+

I don't know how but they found me

+
+
+
+ Rank + Player + Score +
+
+
+ + diff --git a/site/static/style.css b/site/static/style.css index 4fdf79b..7e17778 100644 --- a/site/static/style.css +++ b/site/static/style.css @@ -1,3 +1,5 @@ +/* low priority fallback styles */ + body { background-color: #404040; color: #20c420; @@ -38,3 +40,75 @@ ul { li { text-align: left; } + +span { + display: inline-block; +} + +/* leaderboard style */ +.board { + font-size: 200%; + background-color: #e0e0e0; + color: #111111; + width: 100%; +} + +.board-container { + width: 99%; + border: 5px; + border-style: solid; + border-color: #505050; + text-align: left; +} + +.board-entry { + width: 100%; + padding-top: 0.25%; + padding-bottom: 0.25%; + border: 0px; + border-bottom: 4px; + border-style: solid; + border-color: #208020; +} + +.board-rank { + width: 15%; + font-size: 170%; + margin-left: 4%; + text-align: left; + vertical-align: middle; + color: #208020; +} + +.board-name { + width: 55%; + font-size: 130%; + text-align: left; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + vertical-align: middle; +} + +.board-name-a { + width: 100%; + color: #20c420; +} + +.board-score { + width: 20%; + margin-left: 4%; + font-size: 100%; + vertical-align: middle; + color: #667766; +} + +.board-header { + margin-top: 0.25%; + margin-bottom: 0.25%; + margin-left: -0.25%; + font-weight: bold; + text-align: center; + font-size: 150%; + color: #112211; +}