Added number of pages
This commit is contained in:
parent
af5751ac66
commit
01839edeb3
4 changed files with 34 additions and 18 deletions
|
@ -70,11 +70,13 @@ module.exports = async (app, req, res) => {
|
|||
form : filters}, async function(err, resp, body) {
|
||||
|
||||
if (err || !body || body == '-1') return res.send("-1")
|
||||
let preRes = body.split('#')[0].split('|', 10)
|
||||
console.log(body)
|
||||
let splitBody = body.split('#')
|
||||
let preRes = splitBody[0].split('|', 10)
|
||||
let authorList = {}
|
||||
let songList = {}
|
||||
let authors = body.split('#')[1].split('|')
|
||||
let songs = '~' + body.split('#')[2]; songs = songs.split('|~1~:').map(x => app.parseResponse(x + '|~1~', '~|~'))
|
||||
let authors = splitBody[1].split('|')
|
||||
let songs = '~' + splitBody[2]; songs = songs.split('|~1~:').map(x => app.parseResponse(x + '|~1~', '~|~'))
|
||||
songs.forEach(x => {songList[x['~1']] = x['2']})
|
||||
|
||||
authors.splice(10, 999)
|
||||
|
@ -87,6 +89,13 @@ module.exports = async (app, req, res) => {
|
|||
|
||||
await levelArray.forEach(async (x, y) => {
|
||||
let keys = Object.keys(x)
|
||||
|
||||
if (filters.page == 0) { //this is broken if you're not on page 0
|
||||
let pages = splitBody[3].split(":");
|
||||
x.results = +pages[0];
|
||||
x.pages = +Math.ceil(pages[0] / 10);
|
||||
}
|
||||
|
||||
x.name = x[2];
|
||||
x.id = x[1];
|
||||
x.description = Buffer.from(x[3], 'base64').toString() || "(No description provided)",
|
||||
|
@ -100,7 +109,7 @@ module.exports = async (app, req, res) => {
|
|||
x.length = length[x[15]] || "?";
|
||||
x.stars = x[18];
|
||||
x.orbs = orbs[x[18]];
|
||||
x.diamonds = x[18] < 2 ? 0 : parseInt(x[18]) + 2,
|
||||
x.diamonds = x[18] < 2 ? 0 : parseInt(x[18]) + 2;
|
||||
x.featured = x[19] > 0;
|
||||
x.epic = x[42] == 1;
|
||||
x.version = x[5];
|
||||
|
|
|
@ -73,10 +73,6 @@ img, .noSelect {
|
|||
font-size: 6vh;
|
||||
}
|
||||
|
||||
.smaller {
|
||||
font-size: 5vh;
|
||||
text-shadow: -0.2vh -0.2vh 0vh #000, 0.2vh -0.2vh 0vh #000, -0.2vh 0.2vh 0vh #000, 0.2vh 0.2vh 0vh #000, 0.3vh 0.4vh 0vh rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
.bigger {
|
||||
font-size: 3.5vh;
|
||||
|
|
|
@ -286,6 +286,7 @@
|
|||
<p class="reveal" onclick="$('#response-search').slideToggle(100)"><b>Response*</b></p>
|
||||
<div class="subdiv" id="response-search">
|
||||
<p>The response for searching is an array of up to 10 <a href="#level">level objects</a></p>
|
||||
<p>If the page is set to 0, the first level object will also display the number of pages and search results.<br>Since RobTop is a ploopy this only works on the first page, and may sometimes just display 9999 results.</p>
|
||||
</div>
|
||||
<br>
|
||||
<p class="reveal" onclick="$('#request-search').slideToggle(100)"><b>Examples</b></p>
|
||||
|
@ -596,7 +597,7 @@
|
|||
<div class="subdiv" id="params-icons">
|
||||
<p><b>Parameters can be used to modify parts of a fetched user's icon</b></p>
|
||||
<p>IDs generally correspond to their order of appearance in GD</p>
|
||||
<p>form: The form of the icon (cube/ship/ball/ufo/wave/robot/spider/cursed/swing)</p>
|
||||
<p>form: The form of the icon (cube/ship/ball/ufo/wave/robot/spider/cursed)</p>
|
||||
<p>icon: The ID of the icon to use</p>
|
||||
<p>col1: The ID of the primary color to use</p>
|
||||
<p>col2: The ID of the secondary color to use</p>
|
||||
|
|
|
@ -59,8 +59,8 @@
|
|||
<h1 id="header"></h1>
|
||||
</div>
|
||||
|
||||
<div style="text-align: right; position:absolute; top: 1.5%; right: 2%">
|
||||
<h2 class="smaller" id="pagenum"></h2>
|
||||
<div style="text-align: right; position:absolute; top: 1%; right: 2%">
|
||||
<h2 class="smaller" style="font-size: 4.5vh" id="pagenum"></h2>
|
||||
</div>
|
||||
|
||||
<div style="text-align: right; position:absolute; top: 7.5%; right: 2%; height: 12%;">
|
||||
|
@ -105,27 +105,37 @@ let gauntlet = url.searchParams.get('gauntlet')
|
|||
let mappack = url.searchParams.get('mappack')
|
||||
let userMode = url.searchParams.get('user')
|
||||
let type = url.searchParams.get('type')
|
||||
let page = 0
|
||||
let loading = false;
|
||||
let gauntlets = ["Fire", "Ice", "Poison", "Shadow", "Lava", "Bonus", "Chaos", "Demon", "Time", "Crystal", "Magic", "Spike", "Monster", "Doom", "Death"]
|
||||
|
||||
function Append() {
|
||||
let page = 0
|
||||
let pages = 0
|
||||
let legalPages = true
|
||||
|
||||
function Append(firstLoad) {
|
||||
|
||||
loading = true;
|
||||
if (!firstLoad) $('#pagenum').text(`Page ${(page + 1)}${pages ? ` of ${pages}` : ""}`)
|
||||
$('#searchBox').html('<div style="height: 4.5%"></div>')
|
||||
$('#pagenum').text('Page ' + (page + 1))
|
||||
$('#pageSelect').val(page + 1)
|
||||
$('#loading').show()
|
||||
|
||||
fetch(`../api/search/${type == 'saved' ? JSON.parse(localStorage.getItem('saved') || '[]').reverse().toString() : accID || path}?page=${page}${window.location.search.replace("?", "&").replace("page", "nope")}`).then(res => res.json()).then(res => {
|
||||
|
||||
if (page == 0) $('#pageDown').hide()
|
||||
else $('#pageDown').show()
|
||||
|
||||
fetch(`../api/search/${type == 'saved' ? JSON.parse(localStorage.getItem('saved') || '[]').reverse().toString() : accID || path}?page=${page}${window.location.search.replace("?", "&").replace("page", "nope")}`).then(res => res.json()).then(res => {
|
||||
|
||||
if (res == '-1' || (res.length < 9 && type != "recent")) $('#pageUp').hide()
|
||||
else $('#pageUp').show()
|
||||
|
||||
if (res == '-1') { $('#loading').hide(); return loading = false }
|
||||
if (res == '-1' || res.length == 0) { $('#loading').hide(); return loading = false }
|
||||
|
||||
if (firstLoad) {
|
||||
pages = res[0].pages
|
||||
if (res.length < 9 && res.length > 0) pages = 1
|
||||
else if (pages > 999 || pages < 1) pages = null
|
||||
$('#pagenum').text(`Page 1${pages ? ` of ${pages}` : ""}`)
|
||||
}
|
||||
|
||||
res.forEach((x, y) => {
|
||||
let hasAuthor = (x.accountID != "0")
|
||||
|
@ -168,7 +178,7 @@ function Append() {
|
|||
})
|
||||
}
|
||||
|
||||
Append()
|
||||
Append(true)
|
||||
|
||||
$('#pageUp').click(function() {page += 1; if (!loading) Append()})
|
||||
$('#pageDown').click(function() {page -= 1; if (!loading) Append()})
|
||||
|
|
Loading…
Add table
Reference in a new issue