implement goto rating

This commit is contained in:
2019-06-09 01:31:46 +02:00
parent f41396c569
commit eb34339ceb
3 changed files with 19 additions and 4 deletions

View File

@@ -74,9 +74,10 @@ def leaderboard():
start = flask.request.args.get(PARAM_START)
page = flask.request.args.get("page")
# intentional double if, page is supposed to overwrite start #
if start:
start = int(start)
elif page:
if page:
start = SEGMENT * int(page)
else:
start = 0

View File

@@ -44,3 +44,17 @@ function firstPage(){
window.location.href = href.split(parameterSeperator)[0]
}
}
/* input fields */
var gotoRankInputField = document.getElementById("gotoRank");
gotoRankInputField.addEventListener("keyup", function(event) {
if (event.key == "Enter") {
event.preventDefault();
var url = new URL(window.location.href)
var rank = gotoRankInputField.value
var page = Math.trunc((rank - 1)/100)
url.searchParams.set("page", page)
url.searchParams.set("goto", rank)
window.location.href = url.href
}
});

View File

@@ -1,7 +1,7 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="static/site.css">
<script src="static/buttons.js"></script>
<script src="static/buttons.js" defer></script>
</head>
<body>
<div class=top-bar>
@@ -9,8 +9,8 @@
<button type="button" onclick=backward() class=top-button>Backward</button>
<button type="button" onclick=firstPage() class=top-button>Top 100 </button>
<input type="text" class=input-field placeholder="search player...">
<input type="number" class=input-field placeholder="goto rank...">
<input id="getPlayer" type="text" class=input-field placeholder="search player...">
<input id="gotoRank" type="number" class=input-field placeholder="goto rank...">
</div>
<div class=leaderboard-container>
<div class=colum-names>{{ columNames }}</div>