More song checking tweaks + Skipped message counting

This commit is contained in:
GDColon 2021-01-07 10:38:55 -05:00
parent 33cd695030
commit 318e2f925c
5 changed files with 29 additions and 14 deletions

View file

@ -13,9 +13,12 @@ module.exports = async (app, req, res) => {
let params = req.gdParams({
count: amount,
type: (req.query.hasOwnProperty("creator") || req.query.hasOwnProperty("creators")) ? "creators" : "top",
type: "top",
})
if (["creators", "creator", "cp"].some(x => req.query.hasOwnProperty(x) || req.query.type == x)) type = "creators"
else if (["week", "weekly"].some(x => req.query.hasOwnProperty(x) || req.query.type == x)) type = "weekly" // i think GDPS'es use this
request.post(app.endpoint + 'getGJScores20.php', params, async function(err, resp, body) {
if (err || body == '-1' || !body) return res.send("-1")

View file

@ -15,7 +15,7 @@ module.exports = async (app, req, res) => {
request.post(app.endpoint + 'getGJUserInfo20.php', params, async function (err, resp, body) {
if (err || body == '-1' || body == '-2' || !body) return res.status(400).send("Error fetching profile! Make sure your username and password are entered correctly. (this is not an issue with gdbrowser)")
if (err || body == '-1' || body == '-2' || !body) return res.status(400).send("Error counting messages! Messages get blocked a lot so try again later, or make sure your username and password are entered correctly. (this is not an issue with gdbrowser)")
let count = app.parseResponse(body)[38]
if (!count) return res.status(400).send("Error fetching unread messages!")
else res.status(200).send(count)

View file

@ -17,7 +17,7 @@ module.exports = async (app, req, res, api) => {
request.post(app.endpoint + 'getGJMessages20.php', params, async function (err, resp, body) {
if (err || body == '-1' || body == '-2' || !body) return res.status(400).send("Error fetching messages!")
if (err || body == '-1' || body == '-2' || !body) return res.status(400).send("Error fetching messages! Messages get blocked a lot so try again later, or make sure your username and password are entered correctly. (this is not an issue with gdbrowser)")
let messages = body.split("|").map(msg => app.parseResponse(msg))
let messageArray = []

View file

@ -116,13 +116,14 @@
<div style="margin-left: 0.5%">
<h1 class="pre slightlySmaller" id="songname">[[SONGNAME]]</h1>
<h2 class="pre smaller">By: [[SONGAUTHOR]]<!--
--><img id="scout" title="Artist is scouted" style="display: none; cursor: help; margin-left: 1.5%; filter: hue-rotate(-55deg);" class="valign" src="../assets/check.png" width="5%"><!--
--><img id="whitelist" title="Artist is whitelisted" style="display: none; cursor: help" class="valign" src="../assets/check.png" width="5%"><!--
--><img id="scout" title="Artist is scouted" style="display: none; cursor: help; margin-left: 1.5%; filter: hue-rotate(-55deg);" class="artistIcon valign" src="../assets/check.png" width="5%"><!--
--><img id="whitelist" title="Artist is whitelisted" style="display: none; cursor: help" class="artistIcon valign" src="../assets/check.png" width="5%"><!--
--> <a class="songLink" href="https://[[SONGAUTHOR]].newgrounds.com" target="_blank"><img class="gdButton valign" src="../assets/more.png" width="12%"></a></h2>
<img id="checkSong" style="display: none; margin-top: 1%" class="gdButton valign" src="../assets/btn-check.png" width="16%">
<h3 id="songLoading" style="display: none; margin-top: 0.5%;">Loading...</h3>
<h3 id="songAllowed" style="display: none; margin-top: 0.5%; color: lime">Song is allowed for use</h3>
<h3 id="songNotAllowed" style="display: none; margin-top: 0.5%; color: red">Song is not allowed for use</h3>
<h3 id="artistInfo" style="display: none; margin-top: 0.5%"></h3>
</div>
<a class="songLink" href="https://www.newgrounds.com/audio/listen/[[SONGID]]" target="_blank"><img class="gdButton sideButton" src="../assets/playsong.png" style="position:absolute; right: 1%; top: 50%; width: 11%; height: auto;"></a>
</div>
@ -310,7 +311,7 @@ $('#checkSong').click(function() {
$('#songLoading').show()
fetch(`../api/song/[[SONGID]]`).then(res => res.json()).then(info => {
$('#songLoading').hide()
$(info.song.allowed ? '#songAllowed' : '#songNotAllowed').show()
$(info.song.allowed ? '#songAllowed' : '#songNotAllowed').show().addClass('songStatus')
if (!info.artist.scouted) {
$('#scout').attr('src', '../assets/x.png')
$('#scout').attr('title', $('#scout').attr('title').replace('is ', 'is NOT '))
@ -324,6 +325,17 @@ $('#checkSong').click(function() {
})
})
$('.artistIcon').hover(function() {
let title = $(this).attr('title')
$('#artistInfo').css('color', title.includes("NOT") ? "red" : "lime")
$('.songStatus').hide()
$('#artistInfo').show()
$('#artistInfo').text(title)
}, function() {
$('#artistInfo').hide()
$('.songStatus').show()
})
// let like;
// let likedLevels = localStorage.likedLevels ? JSON.parse(localStorage.likedLevels) : []
// if (likedLevels.includes('[[ID]]')) $('#likeButton').attr('src', '../assets/voted.png').removeClass('gdButton').prop("onclick", null)

View file

@ -267,16 +267,16 @@
if (!res || res == "-1") { $('.postbutton').show(); return $('#message').text("The username you provided doesn't exist!") }
else accountID = res.accountID
$.post("../messages", { password, accountID, count: true })
.done(count => {
$('#msgCount').html(`Loading <span style="color: yellow">${count}</span> unread messages...`)
$('#access').hide()
$('#loading').show()
// $.post("../messages", { password, accountID, count: true })
// .done(count => {
// $('#msgCount').html(`Loading <span style="color: yellow">${count}</span> unread messages...`)
// $('#access').hide()
// $('#loading').show()
$.post("../messages", { password, accountID })
.done(msgs => {
messages = msgs
$('#loading').hide()
$('#access').hide()
appendMessages()
$('#messages').show()
@ -299,8 +299,8 @@
})
}
})
.fail(e => { $('#loadingicon').hide(); $('#msgCount').text(e.responseText.includes("DOCTYPE") ? "Something went wrong..." : e.responseText) })
// })
// .fail(e => { $('#loadingicon').hide(); $('#msgCount').text(e.responseText.includes("DOCTYPE") ? "Something went wrong..." : e.responseText) })
})
.fail(e => { $('.postbutton').show(); $('#message').text(e.responseText.includes("DOCTYPE") ? "Something went wrong..." : e.responseText) })