Analysis page no longer redirects on error
This commit is contained in:
parent
6d52140e32
commit
4c97a7bcca
14 changed files with 45 additions and 15 deletions
|
@ -16,7 +16,7 @@ module.exports = async (app, req, res, level) => {
|
|||
return res.send(response_data);
|
||||
} else {
|
||||
zlib.unzip(levelString, (err, buffer) => {
|
||||
if (err) { return res.send("-1"); }
|
||||
if (err) { return res.send("-2"); }
|
||||
|
||||
const raw_data = buffer.toString();
|
||||
const response_data = analyze_level(level, raw_data);
|
||||
|
|
|
@ -18,8 +18,9 @@ module.exports = async (app, req, res, api, ID, analyze) => {
|
|||
req.gdRequest('downloadGJLevel22', { levelID }, function (err, resp, body) {
|
||||
|
||||
if (err || !body || body == '-1' || body.startsWith("<")) {
|
||||
if (!api && levelID < 0) return res.redirect(`/?daily=${levelID * -1}`)
|
||||
if (!api) return res.redirect('search/' + req.params.id)
|
||||
if (api && analyze) return res.send("-3")
|
||||
else if (!api && levelID < 0) return res.redirect(`/?daily=${levelID * -1}`)
|
||||
else if (!api) return res.redirect('search/' + req.params.id)
|
||||
else return res.send("-1")
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ module.exports = async (app, req, res, api, analyze) => {
|
|||
let song = '~' + body.split('#')[2];
|
||||
song = app.parseResponse(song, '~|~')
|
||||
|
||||
let levelInfo = app.parseResponse(preRes[0])
|
||||
let levelInfo = app.parseResponse(preRes.find(x => x.startsWith(`1:${levelID}`)) || preRes[0])
|
||||
let level = new Level(levelInfo, req.server, false, author).getSongInfo(song)
|
||||
|
||||
if (req.isGDPS) level.gdps = (req.onePointNine ? "1.9/" : "") + req.endpoint
|
||||
|
|
|
@ -108,7 +108,7 @@ module.exports = async (app, req, res) => {
|
|||
let arr = x.split(':')
|
||||
authorList[arr[0]] = [arr[1], arr[2]]})
|
||||
|
||||
let levelArray = preRes.map(x => app.parseResponse(x)).filter(x => x[2])
|
||||
let levelArray = preRes.map(x => app.parseResponse(x)).filter(x => x[1])
|
||||
let parsedLevels = []
|
||||
|
||||
levelArray.forEach((x, y) => {
|
||||
|
|
BIN
assets/btn-back.png
Normal file
BIN
assets/btn-back.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 47 KiB |
BIN
assets/discord.png
Normal file
BIN
assets/discord.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
assets/gdps/silvrps_icon.png
Normal file
BIN
assets/gdps/silvrps_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 189 KiB |
BIN
assets/gdps/silvrps_logo.png
Normal file
BIN
assets/gdps/silvrps_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 130 KiB |
|
@ -8,7 +8,7 @@ let demonTypes = { 3: "Easy", 4: "Medium", 5: "Insane", 6: "Extreme" }
|
|||
|
||||
class Level {
|
||||
constructor(levelInfo, server, download, author = []) {
|
||||
if (!levelInfo[2]) return;
|
||||
if (!levelInfo[1]) return;
|
||||
this.name = levelInfo[2];
|
||||
this.id = levelInfo[1];
|
||||
this.description = Buffer.from((levelInfo[3] || ""), "base64").toString() || "(No description provided)";
|
||||
|
@ -37,11 +37,11 @@ class Level {
|
|||
this.customSong = +levelInfo[35] || 0
|
||||
this.coins = +levelInfo[37]
|
||||
this.verifiedCoins = levelInfo[38] > 0
|
||||
this.starsRequested = +levelInfo[39]
|
||||
this.starsRequested = +levelInfo[39] || 0
|
||||
this.ldm = levelInfo[40] > 0
|
||||
if (+levelInfo[41] > 100000) this.weekly = true
|
||||
if (+levelInfo[41]) { this.dailyNumber = (+levelInfo[41] > 100000 ? +levelInfo[41] - 100000 : +levelInfo[41]); this.nextDaily = null; this.nextDailyTimestamp = null }
|
||||
this.objects = +levelInfo[45]
|
||||
this.objects = +levelInfo[45] || 0
|
||||
this.large = levelInfo[45] > 40000;
|
||||
this.cp = Number((this.stars > 0) + this.featured + this.epic)
|
||||
|
||||
|
|
|
@ -15,9 +15,17 @@
|
|||
|
||||
<div id="everything" class="center">
|
||||
|
||||
<div class="popup" id="analyzeError">
|
||||
<div class="fancybox bounce center supercenter" style="width: 80vh; top: 46%">
|
||||
<h2 class="smaller center" style="font-size: 5.5vh">Something Went Wrong!</h2>
|
||||
<p class="bigger center" id="errorMessage" style="margin-bottom: 2vh; line-height: 5vh; margin-top: 1.5vh;">An <cr>unknown error</cr> occured while trying to analyze this level.</p>
|
||||
<a id="byebye"><img src="../assets/btn-back.png" width=26%; class="gdButton center closeWindow"></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="supercenter" id="loadingDiv" style="height:50%">
|
||||
<h1 style="transform:scale(1.2)">Analyzing level...</h1>
|
||||
<img class="spin noSelect" src="../assets/loading.png" height="25%" style="margin-top: 7%">
|
||||
<img id="loading" class="spin noSelect" src="../assets/loading.png" height="25%" style="margin-top: 7%">
|
||||
</div>
|
||||
|
||||
<div class="popup" id="colorInfo">
|
||||
|
@ -87,7 +95,7 @@
|
|||
</div>
|
||||
</body>
|
||||
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="../sizecheck.js?"></script>
|
||||
<script type="text/javascript" src="../sizecheck.js"></script>
|
||||
<script>
|
||||
|
||||
function clean(text) {return text.toString().replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/=/g, "=").replace(/"/g, """).replace(/'/g, "'")}
|
||||
|
@ -100,7 +108,18 @@ let dualPortals = ['dual', 'single']
|
|||
let mirrorPortals = ['mirrorOn', 'mirrorOff']
|
||||
|
||||
fetch(`../api${window.location.pathname}`).then(res => res.json()).then(res => {
|
||||
if (!res.level) return window.location.href = window.location.href.replace("analyze", "search")
|
||||
|
||||
if (!res.level) {
|
||||
switch(res) {
|
||||
case -1: $('#errorMessage').html("This level could not be be <cr>downloaded</cr>. Either the servers rejected the request, or the level simply <co>doesn't exist at all</co>."); break;
|
||||
case -2: $('#errorMessage').html("This level's data appears to be <cr>corrupt</cr> and cannot be <cy>parsed</cy>. It most likely won't load in GD."); break;
|
||||
case -3: $('#errorMessage').html("This level's data could not be obtained because <ca>RobTop</ca> has disabled <cg>level downloading</cg>."); break;
|
||||
}
|
||||
popupEsc = false
|
||||
$('#byebye').attr('href', window.location.href.replace("analyze/", ""))
|
||||
$('#analyzeError').show()
|
||||
return $('#loadingDiv').hide()
|
||||
}
|
||||
$('#levelName').text(res.level.name)
|
||||
$('#objectCount').text(commafy(res.objects) + " objects")
|
||||
document.title = "Analysis of " + res.level.name
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
<div class="fancybox bounce center supercenter" style="width: 75vh">
|
||||
<h2 class="smaller center" style="font-size: 5.5vh">Level Analysis</h2>
|
||||
<p class="bigger center" style="line-height: 5vh; margin-top: 1.5vh;">
|
||||
<cy>Level analysis</cy> is currently <cr>blocked</cr> by RobTop. We don't know when or if it will be re-enabled.<br><a class="youCanClickThis" style="color:aqua" href="./analyze/[[ID]]">(click to try anyways)</a>
|
||||
<cy>Level analysis</cy> is currently <cr>blocked</cr> by <ca>RobTop</ca>. We don't know when or if it will be re-enabled.<br><a class="youCanClickThis" style="color:aqua" href="./analyze/[[ID]]">(click to try anyways)</a>
|
||||
</p>
|
||||
<img src="../assets/ok.png" width=20%; class="gdButton center" onclick="$('.popup').hide()">
|
||||
</div>
|
||||
|
|
|
@ -161,7 +161,7 @@ function Append(firstLoad) {
|
|||
if (firstLoad) {
|
||||
pages = res[0].pages
|
||||
results = res[0].results
|
||||
if (pages == 1000 || pages < 1) {
|
||||
if (!pages || pages == 1000 || pages < 1) {
|
||||
pages = null
|
||||
if (!superSearch) $('#shuffle').addClass('grayscale')
|
||||
else $('#shuffle').css('filter', 'hue-rotate(100deg)')
|
||||
|
@ -193,7 +193,7 @@ function Append(firstLoad) {
|
|||
let noLink = songColor != "whatIfItWasPurple"
|
||||
|
||||
$('#searchBox').append(`<div class="searchresult" title="${clean(x.description)}">
|
||||
<h1 class="help lessspaced pre" title="${x.name} (${x.id})" style="width: fit-content; padding-right: 1%">${clean(x.name)}</h1>
|
||||
<h1 class="help lessspaced pre" title="${x.name} (${x.id})" style="width: fit-content; padding-right: 1%">${clean(x.name || " ")}</h1>
|
||||
<h2 class="lessSpaced pre smaller inline gdButton help ${hasAuthor ? "" : "green unregistered"}" title="Account ID: ${x.accountID}\nPlayer ID: ${x.playerID}">${hasAuthor && !onePointNine ? `<a href="../u/${x.author}">By ${x.author || "-"}</a>` : `<a ${userSearch ? "" : `href="../search/${x.playerID}?user"`}>By ${x.author || "-"}</a>`}</h2><h2 class="inline" style="margin-left: 1.5%; transform:translateY(30%)"> ${x.copiedID == '0' ? "" : `<a target="_blank" href="../${x.copiedID}"><img class="gdButton valign sideSpace" title="Original: ${x.copiedID}" src="../assets/copied.png" height="12%"></a>`}${x.large ? `<img class="help valign sideSpaceD" title="${x.objects}${x.objects == 65535 ? "+" : ""} objects" src="../assets/large.png" height="12%">` : ''}</h2>
|
||||
<h3 class="lessSpaced help ${noLink ? "" : 'gdButton '}pre ${songColor}" title="${filteredSong} by ${x.songAuthor} (${x.songID})" style="overflow: hidden; max-height: 19%; width: fit-content">${noLink ? filteredSong : `<a target="_blank" style="width: fit-content" href="https://www.newgrounds.com/audio/listen/${x.songID}">${filteredSong}</a>`}</h3>
|
||||
<h3 class="lessSpaced" style="width: fit-content" title="">
|
||||
|
|
|
@ -49,12 +49,13 @@ function Fetch(link) {
|
|||
}
|
||||
|
||||
let allowEsc = true;
|
||||
let popupEsc = true;
|
||||
|
||||
$(document).keydown(function(k) {
|
||||
if (k.keyCode == 27) { //esc
|
||||
if (!allowEsc) return
|
||||
k.preventDefault()
|
||||
if ($('.popup').is(":visible")) $('.popup').hide();
|
||||
if (popupEsc && $('.popup').is(":visible")) $('.popup').hide();
|
||||
else $('#backButton').trigger('click')
|
||||
}
|
||||
});
|
||||
|
|
|
@ -152,6 +152,15 @@
|
|||
"endpoint": "http://gdpsresu.000webhostapp.com/"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "SilvrPS",
|
||||
"link": "https://discord.gg/A3a6rka",
|
||||
"author": "silverra",
|
||||
"authorLink": "https://www.youtube.com/channel/UCdKNL3PFoZKBkRTo41Ss_dg",
|
||||
"id": "silvrps",
|
||||
"endpoint": "http://silvrragdps.7m.pl/database/"
|
||||
},
|
||||
|
||||
{
|
||||
"name": "Ausk’s GDPS",
|
||||
"link": "https://discord.gg/AEBhCaa",
|
||||
|
|
Loading…
Add table
Reference in a new issue