mirror of
https://github.com/FAUSheppy/open-web-leaderboard.git
synced 2025-12-06 07:01:36 +01:00
implement goto rating
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user