Added a timer for daily/weeklies
This commit is contained in:
parent
01aefc8314
commit
1ad82e91fb
4 changed files with 48 additions and 15 deletions
|
@ -22,13 +22,22 @@ module.exports = async (app, req, res, api, ID, analyze) => {
|
|||
else return res.send("-1")
|
||||
}
|
||||
|
||||
let authorData = body.split("#")[3] // daily/weekly only, most likely
|
||||
|
||||
let levelInfo = app.parseResponse(body)
|
||||
let level = new Level(levelInfo, true)
|
||||
|
||||
request.post(app.endpoint + 'getGJUsers20.php', req.gdParams({ str: level.authorID }), function (err1, res1, b1) {
|
||||
let gdSearchResult = app.parseResponse(b1)
|
||||
request.post(app.endpoint + 'getGJUserInfo20.php', req.gdParams({ targetAccountID: gdSearchResult[16] }), function (err2, res2, b2) {
|
||||
if (b2 != '-1') {
|
||||
request.post(authorData ? "" : app.endpoint + 'getGJUsers20.php', authorData ? {} : req.gdParams({ str: level.authorID }), function (err1, res1, b1) {
|
||||
let gdSearchResult = authorData ? "" : app.parseResponse(b1)
|
||||
request.post(authorData ? "" : app.endpoint + 'getGJUserInfo20.php', authorData ? {} : req.gdParams({ targetAccountID: gdSearchResult[16] }), function (err2, res2, b2) {
|
||||
|
||||
if (err2 && authorData) {
|
||||
let authorInfo = authorData.split(":")
|
||||
level.author = authorInfo[1]
|
||||
level.accountID = authorInfo[0]
|
||||
}
|
||||
|
||||
else if (!err && b2 != '-1') {
|
||||
let account = app.parseResponse(b2)
|
||||
level.author = account[1]
|
||||
level.accountID = gdSearchResult[16]
|
||||
|
@ -41,7 +50,7 @@ module.exports = async (app, req, res, api, ID, analyze) => {
|
|||
|
||||
request.post(app.endpoint + 'getGJSongInfo.php', req.gdParams({ songID: level.customSong }), async function (err, resp, songRes) {
|
||||
|
||||
if (songRes != '-1') {
|
||||
if (!err && songRes != '-1') {
|
||||
let songData = app.parseResponse(songRes, '~|~')
|
||||
level.songName = songData[2] || "Unknown"
|
||||
level.songAuthor = songData[4] || "Unknown"
|
||||
|
@ -77,14 +86,24 @@ module.exports = async (app, req, res, api, ID, analyze) => {
|
|||
})
|
||||
}
|
||||
|
||||
if (level.difficulty == "Extreme Demon") {
|
||||
if (levelID < 0) {
|
||||
request.post(app.endpoint + 'getGJDailyLevel.php', req.gdParams({ weekly: levelID == -2 ? "1" : "0" }), async function (err, resp, dailyInfo) {
|
||||
if (err || dailyInfo == -1) return sendLevel()
|
||||
let dailyTime = dailyInfo.split("|")[1]
|
||||
level.nextDaily = +dailyTime
|
||||
level.nextDailyTimestamp = Math.round((Date.now() + (+dailyTime * 1000)) / 100000) * 100000
|
||||
return sendLevel()
|
||||
})
|
||||
}
|
||||
|
||||
else if (level.difficulty == "Extreme Demon") {
|
||||
request.get('https://www.pointercrate.com/api/v1/demons/?name=' + level.name.trim(), function (err, resp, demonList) {
|
||||
if (err) return sendLevel()
|
||||
let demon = JSON.parse(demonList)
|
||||
if (demon[0] && demon[0].position <= 150) level.demonList = demon[0].position
|
||||
return sendLevel()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
else return sendLevel()
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ h2 {
|
|||
text-shadow: -0.275vh -0.275vh 0vh #000, 0.275vh -0.275vh 0vh #000, -0.275vh 0.275vh 0vh #000, 0.275vh 0.275vh 0vh #000, 0.5vh 0.5vh 0vh rgba(0,0,0,0.4);
|
||||
}
|
||||
|
||||
h3, input[type=text], input[type=password], input[type=number] {
|
||||
h3, input[type=text], input[type=password], input[type=number], .h3Size {
|
||||
font-weight: normal;
|
||||
margin: 0 0;
|
||||
font-size: 3.5vh;
|
||||
|
|
|
@ -38,8 +38,8 @@ class Level {
|
|||
this.verifiedCoins = levelInfo[38] > 0
|
||||
this.starsRequested = +levelInfo[39]
|
||||
this.ldm = levelInfo[40] > 0
|
||||
if (+levelInfo[41]) this.dailyNumber = (+levelInfo[41] > 100000 ? +levelInfo[41] - 100000 : +levelInfo[41])
|
||||
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.large = levelInfo[45] > 40000;
|
||||
this.cp = Number((this.stars > 0) + this.featured + this.epic)
|
||||
|
|
|
@ -84,8 +84,8 @@
|
|||
<h2 class="inline slightlySmaller normalCursor sideSpaceC">
|
||||
<img class="inline valign" id="copiedBadge" style="height: 60%; cursor:help" src="../assets/copied.png" title="Level is a copy or a collaboration">
|
||||
<img class="inline valign" id="largeBadge" style="height: 60%; margin-left: -7%; cursor:help" src="../assets/large.png" title="Contains more than 40,000 objects"></h2><br>
|
||||
<img class="inline spaced dailyLevel" id="dailyIcon" style="height:90%; display: none; margin-right: 0.5%; margin-top: 0.5%; vertical-align: middle;">
|
||||
<h1 class="inline smallerer spaced dailyLevel" style="display: none; margin: 0 0 0 0">#[[DAILYNUMBER]]</h1>
|
||||
<img class="inline spaced dailyLevel" id="dailyIcon" style="height:90%; display: none; margin-right: 0.5%; margin-top: 0.4%; vertical-align: middle;">
|
||||
<h1 class="inline smallerer spaced dailyLevel" style="display: none; margin: 0 0 0 0">#[[DAILYNUMBER]]<span style="font-size: 2.5vh; vertical-align: middle;" class="h3Size" id="dailyTime"></span></h1>
|
||||
</div>
|
||||
|
||||
<div class="transparentBox center" style="position:absolute; bottom: 32%; left: 0; right: 0; width: 75vh; margin-left: auto; margin-right: auto">
|
||||
|
@ -156,8 +156,14 @@
|
|||
let messageText = 'Your <span style="color: yellow">Geometry Dash password</span> will <span style="color: lime">not be stored</span> anywhere on the site, both <span style="color:rgb(113, 234, 255)">locally and server-side.</span> You can view the code used for liking a level <a class="menuLink" target="_blank" href="https://github.com/GDColon/GDBrowser/blob/master/api/post/like.js">here</a>.'
|
||||
$('#message').html(messageText)
|
||||
|
||||
function colonize(secs) {
|
||||
return [Math.floor(+secs / 3600), Math.floor(+secs / 60) % 60, +secs % 60].map(v => v < 10 ? "0" + v : v).filter((v,i) => v !== "00" || i > 0).join(":")
|
||||
function colonize(secs, timeUp) {
|
||||
if (secs < 0) {
|
||||
if (timeUp) return "Time's up!"
|
||||
else secs = 0
|
||||
}
|
||||
let days = Math.floor(secs / 86400)
|
||||
if (days) secs -= days * 86400
|
||||
return `${days ? `${days}d + ` : ""}${[Math.floor(+secs / 3600), Math.floor(+secs / 60) % 60, +secs % 60].map(v => v < 10 ? "0" + v : v).filter((v,i) => v !== "00" || i > 0).join(":")}`
|
||||
}
|
||||
|
||||
if (window.location.href.endsWith('?download')) $('#infoDiv').show()
|
||||
|
@ -168,6 +174,7 @@ if (window.location.href.endsWith('?download')) $('#infoDiv').show()
|
|||
let copies = 0
|
||||
let animated = false;
|
||||
let freeze = false;
|
||||
let dailyTime = Number('[[NEXTDAILY]]') || null
|
||||
|
||||
$('#playButton').click(function () {
|
||||
if (!($('#copied').is(':animated')) && !animated) {
|
||||
|
@ -227,10 +234,17 @@ if (!'[[DEMONLIST]]'.startsWith("[")) {
|
|||
else $('.demonList').remove()
|
||||
|
||||
if (!'[[DAILYNUMBER]]'.startsWith("[")) {
|
||||
$('.dailyLevel').show()
|
||||
$('#dailyTime').html(` (${colonize(dailyTime, true)})`)
|
||||
$('#dailyIcon').attr('src', `../assets/crown-${'[[WEEKLY]]'.startsWith("[") ? "daily" : "weekly"}.png`)
|
||||
$('.dailyLevel').show()
|
||||
|
||||
setInterval(() => {
|
||||
dailyTime -= 1
|
||||
$('#dailyTime').html(` (${colonize(dailyTime, true)})`)
|
||||
}, 1000);
|
||||
|
||||
}
|
||||
else $('.demonList').remove()
|
||||
else $('.dailyLevel').remove()
|
||||
|
||||
if ("[[SONGID]]".startsWith("Level")) {
|
||||
$('#songInfo').text('[[SONGID]]')
|
||||
|
|
Loading…
Add table
Reference in a new issue