Diamond leaderboard + random tweaks
This commit is contained in:
parent
8e2c88bb76
commit
cb1481bfd8
8 changed files with 26 additions and 14 deletions
|
@ -1,9 +1,11 @@
|
||||||
const {GoogleSpreadsheet} = require('google-spreadsheet');
|
const {GoogleSpreadsheet} = require('google-spreadsheet');
|
||||||
const sheet = new GoogleSpreadsheet('1ADIJvAkL0XHGBDhO7PP9aQOuK3mPIKB2cVPbshuBBHc'); // accurate leaderboard spreadsheet
|
const sheet = new GoogleSpreadsheet('1ADIJvAkL0XHGBDhO7PP9aQOuK3mPIKB2cVPbshuBBHc'); // accurate leaderboard spreadsheet
|
||||||
|
|
||||||
|
let indexes = ["stars", "coins", "demons", "diamonds"]
|
||||||
|
|
||||||
let forms = ['cube', 'ship', 'ball', 'ufo', 'wave', 'robot', 'spider']
|
let forms = ['cube', 'ship', 'ball', 'ufo', 'wave', 'robot', 'spider']
|
||||||
let lastIndex = [{"stars": 0, "coins": 0, "demons": 0}, {"stars": 0, "coins": 0, "demons": 0}]
|
let lastIndex = [{"stars": 0, "coins": 0, "demons": 0}, {"stars": 0, "coins": 0, "demons": 0, "diamonds": 0}]
|
||||||
let caches = [{"stars": null, "coins": null, "demons": null}, {"stars": null, "coins": null, "demons": null}, {"stars": null, "coins": null, "demons": null}] // 0 for JSON, 1 for mods, 2 for GD
|
let caches = [{"stars": null, "coins": null, "demons": null, "diamonds": null}, {"stars": null, "coins": null, "demons": null, "diamonds": null}, {"stars": null, "coins": null, "demons": null, "diamonds": null}] // 0 for JSON, 1 for mods, 2 for GD
|
||||||
|
|
||||||
module.exports = async (app, req, res, post) => {
|
module.exports = async (app, req, res, post) => {
|
||||||
|
|
||||||
|
@ -15,16 +17,16 @@ module.exports = async (app, req, res, post) => {
|
||||||
|
|
||||||
let type = req.query.type ? req.query.type.toLowerCase() : 'stars'
|
let type = req.query.type ? req.query.type.toLowerCase() : 'stars'
|
||||||
if (type == "usercoins") type = "coins"
|
if (type == "usercoins") type = "coins"
|
||||||
if (!["stars", "coins", "demons"].includes(type)) type = "stars"
|
if (!indexes.includes(type)) type = "stars"
|
||||||
if (lastIndex[modMode ? 1 : 0][type] + 600000 > Date.now() && cache[type]) return res.send(gdMode ? cache[type] : JSON.parse(cache[type])) // 10 min cache
|
if (lastIndex[modMode ? 1 : 0][type] + 600000 > Date.now() && cache[type]) return res.send(gdMode ? cache[type] : JSON.parse(cache[type])) // 10 min cache
|
||||||
|
|
||||||
sheet.useApiKey(app.sheetsKey)
|
sheet.useApiKey(app.sheetsKey)
|
||||||
sheet.loadInfo().then(async () => {
|
sheet.loadInfo().then(async () => {
|
||||||
let tab = sheet.sheetsById[1555821000]
|
let tab = sheet.sheetsById[1555821000]
|
||||||
await tab.loadCells('A2:F2')
|
await tab.loadCells('A2:H2')
|
||||||
|
|
||||||
let cellIndex = type == "demons" ? 2 : type == "coins" ? 1 : 0
|
let cellIndex = indexes.findIndex(x => type == x)
|
||||||
if (modMode) cellIndex += 3
|
if (modMode) cellIndex += indexes.length
|
||||||
|
|
||||||
let cell = tab.getCell(1, cellIndex).value
|
let cell = tab.getCell(1, cellIndex).value
|
||||||
if (!cell || typeof cell != "string" || cell.startsWith("GoogleSpreadsheetFormulaError")) { console.log("Spreadsheet Error:"); console.log(cell); return res.send("-1") }
|
if (!cell || typeof cell != "string" || cell.startsWith("GoogleSpreadsheetFormulaError")) { console.log("Spreadsheet Error:"); console.log(cell); return res.send("-1") }
|
||||||
|
|
BIN
assets/sort-diamonds-on.png
Normal file
BIN
assets/sort-diamonds-on.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
assets/sort-diamonds.png
Normal file
BIN
assets/sort-diamonds.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
|
@ -340,7 +340,7 @@
|
||||||
<p>count: The amount of players to list (default is 100, max is 5000, does not work with accurate leaderboard)</p>
|
<p>count: The amount of players to list (default is 100, max is 5000, does not work with accurate leaderboard)</p>
|
||||||
<p>creator: Fetches the creator leaderboard</p>
|
<p>creator: Fetches the creator leaderboard</p>
|
||||||
<p>accurate: Fetches the accurate leaderboard</p>
|
<p>accurate: Fetches the accurate leaderboard</p>
|
||||||
<p class="red">type: The type of stat to sort by (stars, coins, or demons)</p>
|
<p class="red">type: The type of stat to sort by (stars, coins, diamonds, or demons)</p>
|
||||||
<p class="red">mod: Restricts the leaderboard to GD mods only</p>
|
<p class="red">mod: Restricts the leaderboard to GD mods only</p>
|
||||||
<p class="red">gd: Formats the leaderboard using GD's number:value syntax (for use in GD)</p>
|
<p class="red">gd: Formats the leaderboard using GD's number:value syntax (for use in GD)</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -242,7 +242,8 @@ $('.lengthDiv').click(function() {
|
||||||
})
|
})
|
||||||
|
|
||||||
$(document).keydown(function(k) {
|
$(document).keydown(function(k) {
|
||||||
if (!$(':focus-visible').length && k.which == 13) { // enter
|
let searchFocus = $(':focus-visible').length == 1 && $(':focus-visible').first().attr('id') == "levelName"
|
||||||
|
if ((!$(':focus-visible').length || searchFocus) && k.which == 13) { // enter
|
||||||
if (!$('#customlist').is(':hidden')) k.preventDefault();
|
if (!$('#customlist').is(':hidden')) k.preventDefault();
|
||||||
else if ($('#filters').is(':hidden')) $('#searchBtn').trigger('click')
|
else if ($('#filters').is(':hidden')) $('#searchBtn').trigger('click')
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,8 @@
|
||||||
<div id="dl" style="display: none; position:absolute; top: 15%; right: 0.5%; text-align: center; width: 17%">
|
<div id="dl" style="display: none; position:absolute; top: 15%; right: 0.5%; text-align: center; width: 17%">
|
||||||
<h1 class="smaller" style="margin-bottom: 1%">Note</h1>
|
<h1 class="smaller" style="margin-bottom: 1%">Note</h1>
|
||||||
<p style="font-size: 2.2vh; margin-top: 1.2%"><ca>Level downloading</ca> has been <cr>blocked</cr> by RobTop.
|
<p style="font-size: 2.2vh; margin-top: 1.2%"><ca>Level downloading</ca> has been <cr>blocked</cr> by RobTop.
|
||||||
<cy>Level analysis, daily levels, and downloading extra info</cy> will <cg>not work</cg> until a resolution is made.</p>
|
<cy>Level analysis, daily levels, and downloading extra info</cy> will <cg>not work</cg> until he choses to unblock downloads.
|
||||||
|
These features still work <ca><a class="underline" target="_blank" href="https://github.com/GDColon/GDBrowser">locally</a></ca> and on <ca><a class="underline" href="../gdps">private servers</a></ca></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="supercenter center" id="menuButtons" style="bottom: 5%;">
|
<div class="supercenter center" id="menuButtons" style="bottom: 5%;">
|
||||||
|
|
|
@ -55,8 +55,9 @@
|
||||||
<img class="gdButton" id="modSort" style="margin-bottom: 1vh" title="Moderators" src="../assets/sort-mod.png" height="11%">
|
<img class="gdButton" id="modSort" style="margin-bottom: 1vh" title="Moderators" src="../assets/sort-mod.png" height="11%">
|
||||||
<img class="gdButton" id="weeklyStats" style="margin-bottom: 1vh" title="Weekly Stats" src="../assets/sort-week.png" height="11%">
|
<img class="gdButton" id="weeklyStats" style="margin-bottom: 1vh" title="Weekly Stats" src="../assets/sort-week.png" height="11%">
|
||||||
</div>
|
</div>
|
||||||
<div class="sortDiv" style="position: relative; right: 10.5%; top: 0%; width: 0.1%; transform: translateY(-33.3%)">
|
<div class="sortDiv" style="position: relative; right: 10.5%; top: 0%; width: 0.1%; transform: translateY(-33.3%)" id="statSort">
|
||||||
<img class="gdButton sortButton" style="margin-bottom: 1vh" sort="stars" title="Most stars" src="../assets/sort-stars-on.png" height="11%" id="starSort">
|
<img class="gdButton sortButton" style="margin-bottom: 1vh" sort="stars" title="Most stars" src="../assets/sort-stars-on.png" height="11%" id="starSort">
|
||||||
|
<img class="gdButton sortButton" style="margin-bottom: 1vh" sort="diamonds" title="Most diamonds" src="../assets/sort-diamonds.png" height="11%">
|
||||||
<img class="gdButton sortButton" style="margin-bottom: 1vh" sort="coins" title="Most coins" src="../assets/sort-coins.png" height="11%">
|
<img class="gdButton sortButton" style="margin-bottom: 1vh" sort="coins" title="Most coins" src="../assets/sort-coins.png" height="11%">
|
||||||
<img class="gdButton sortButton" style="margin-bottom: 1vh" sort="demons" title="Most demons" src="../assets/sort-demons.png" height="11%">
|
<img class="gdButton sortButton" style="margin-bottom: 1vh" sort="demons" title="Most demons" src="../assets/sort-demons.png" height="11%">
|
||||||
<img class="gdButton sortButton" style="margin-bottom: 1vh; display: none" sort="cp" title="Most creator points" src="../assets/sort-cp.png" height="11%" id="cpSort">
|
<img class="gdButton sortButton" style="margin-bottom: 1vh; display: none" sort="cp" title="Most creator points" src="../assets/sort-cp.png" height="11%" id="cpSort">
|
||||||
|
@ -157,7 +158,7 @@ function leaderboard(val) {
|
||||||
|
|
||||||
<h3 class="lessSpaced leaderboardStats">
|
<h3 class="lessSpaced leaderboardStats">
|
||||||
${type != "weekly" ? "" : `<span${x.stars >= 1000 ? " class='yellow'" : ""}>+${x.stars}</span> <img class="help valign" src="../assets/star.png" title="Star Gain">`}
|
${type != "weekly" ? "" : `<span${x.stars >= 1000 ? " class='yellow'" : ""}>+${x.stars}</span> <img class="help valign" src="../assets/star.png" title="Star Gain">`}
|
||||||
${wk || onePointNine ? "" : `<span${x.diamonds >= 65535 ? ` class='blue'>${type == "accurate" ? "~" : ""}` : ">"}${x.diamonds}</span> <img class="help valign" src="../assets/diamond.png" title="Diamonds">`}
|
${wk || onePointNine ? "" : `<span${x.diamonds >= 65535 ? ` class='blue'>` : ">"}${x.diamonds}</span> <img class="help valign" src="../assets/diamond.png" title="Diamonds">`}
|
||||||
${wk ? " " : `<span${x.coins >= 149 ? " class='yellow'" : ""}>${x.coins}</span> <img class="help valign" src="../assets/coin.png" title="Secret Coins">`}
|
${wk ? " " : `<span${x.coins >= 149 ? " class='yellow'" : ""}>${x.coins}</span> <img class="help valign" src="../assets/coin.png" title="Secret Coins">`}
|
||||||
${wk || onePointNine ? "" : `<span${x.usercoins >= 10000 ? " class='brightblue'" : ""}>${x.usercoins}</span> <img class="help valign" src="../assets/silvercoin.png" title="User Coins">`}
|
${wk || onePointNine ? "" : `<span${x.usercoins >= 10000 ? " class='brightblue'" : ""}>${x.usercoins}</span> <img class="help valign" src="../assets/silvercoin.png" title="User Coins">`}
|
||||||
${wk ? "" : `<span${x.demons >= 1000 ? " class='brightred'" : ""}>${x.demons}</span> <img class="help valign" src="../assets/demon.png" title="Demons">`}
|
${wk ? "" : `<span${x.demons >= 1000 ? " class='brightred'" : ""}>${x.demons}</span> <img class="help valign" src="../assets/demon.png" title="Demons">`}
|
||||||
|
@ -256,8 +257,15 @@ $('#creatorTabOff').click(function() {
|
||||||
$('#modSort').click(function() {
|
$('#modSort').click(function() {
|
||||||
modMode = !modMode
|
modMode = !modMode
|
||||||
$(this).attr('src', `../assets/sort-mod${modMode ? "-on" : ""}.png`)
|
$(this).attr('src', `../assets/sort-mod${modMode ? "-on" : ""}.png`)
|
||||||
if (modMode) { $('#cpSort').show() }
|
if (modMode) {
|
||||||
else { $('#cpSort').hide(); if (sort == "cp") $('#starSort').trigger('click') }
|
$('#cpSort').show();
|
||||||
|
$('#statSort').css('transform', 'translateY(-26.7%')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('#cpSort').hide();
|
||||||
|
$('#statSort').css('transform', 'translateY(-33.3%')
|
||||||
|
if (sort == "cp") $('#starSort').trigger('click')
|
||||||
|
}
|
||||||
leaderboard(type)
|
leaderboard(type)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -226,7 +226,7 @@ function Append(firstLoad) {
|
||||||
<a title="View level" href="../${x.id}""><img style="margin-bottom: 4.5%" class="valign gdButton" src="../assets/view.png" height="105%"></a>
|
<a title="View level" href="../${x.id}""><img style="margin-bottom: 4.5%" class="valign gdButton" src="../assets/view.png" height="105%"></a>
|
||||||
${demonList ? `<br><a title="View leaderboard" href="../demon/${x.demonPosition}""><img class="valign gdButton" src="../assets/trophyButton.png" height="110%"></a>
|
${demonList ? `<br><a title="View leaderboard" href="../demon/${x.demonPosition}""><img class="valign gdButton" src="../assets/trophyButton.png" height="110%"></a>
|
||||||
<a title="View on Pointercrate" href="${demonListLink}demonlist/${x.demonPosition}" target=_blank><img class="valign gdButton" src="../assets/demonButton.png" height="110%"></a>` : "" }
|
<a title="View on Pointercrate" href="${demonListLink}demonlist/${x.demonPosition}" target=_blank><img class="valign gdButton" src="../assets/demonButton.png" height="110%"></a>` : "" }
|
||||||
<p title="Level ID" style="text-align: right; color: rgba(0, 0, 0, 0.4); font-size: 2.2vh; transform: translate(2.8vh, 2.5vh)">#${x.id}</p>
|
<p title="Level ID" style="text-align: right; color: rgba(0, 0, 0, 0.4); font-size: 2.2vh; transform: translate(2.8vh, ${demonList ? -1.8 : 2.5}vh)">#${x.id}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>`)
|
</div>`)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue