Live comments now update likes

oops i also forgot the last 2 colors in the icon kit
This commit is contained in:
GDColon 2020-11-26 22:45:11 -05:00
parent 0b5363bed9
commit 8b5d20dafa
3 changed files with 11 additions and 9 deletions

View file

@ -229,6 +229,8 @@ fetch(`../api${!history ? window.location.pathname : "/comments/" + lvl.playerID
res.forEach((x, index) => { res.forEach((x, index) => {
$(`#date-${x.ID}`).html(x.date) $(`#date-${x.ID}`).html(x.date)
$(`#likes-${x.ID}`).html(x.likes)
$(`#thumb-${x.ID}`).attr('style', x.likes < 0 ? 'transform: translateY(25%); margin-right: 0.4%' : '').attr('src', `../assets/${x.likes < 0 ? "dis" : ""}like.png`)
if ($(`.comment[commentID=${x.ID}]`).length) return // auto mode, ignore duplicates if ($(`.comment[commentID=${x.ID}]`).length) return // auto mode, ignore duplicates
let bgCol = index % 2 ? "evenComment" : "oddComment" let bgCol = index % 2 ? "evenComment" : "oddComment"
@ -265,9 +267,9 @@ fetch(`../api${!history ? window.location.pathname : "/comments/" + lvl.playerID
<div class="commentLikes"> <div class="commentLikes">
${history ? `<h3 style="margin-right: 1.5vh; pointer-events: all;" class="gold inline"><a href="../${x.levelID}">(${x.levelID})</a></h3>` : ""} ${history ? `<h3 style="margin-right: 1.5vh; pointer-events: all;" class="gold inline"><a href="../${x.levelID}">(${x.levelID})</a></h3>` : ""}
<div class="inline gdButton likeComment" commentID="${x.ID}" ${x.levelID ? `levelID="${x.levelID}"` : ""}"> <div class="inline gdButton likeComment" commentID="${x.ID}" ${x.levelID ? `levelID="${x.levelID}"` : ""}">
<img class="inline gdButton" ${x.likes < 0 ? "style='transform: translateY(25%); margin-right: 0.4%'" : ""} src="../assets/${x.likes < 0 ? "dis" : ""}like.png" height=20%> <img id="thumb-${x.ID}" class="inline gdButton" ${x.likes < 0 ? "style='transform: translateY(25%); margin-right: 0.4%'" : ""} src="../assets/${x.likes < 0 ? "dis" : ""}like.png" height=20%>
</div> </div>
<h3 class="inline">${x.likes}</h3> <h3 id="likes-${x.ID}" class="inline">${x.likes}</h3>
</div> </div>
</div>` </div>`
@ -290,9 +292,9 @@ fetch(`../api${!history ? window.location.pathname : "/comments/" + lvl.playerID
<div class="commentLikes"> <div class="commentLikes">
${history ? `<h3 style="margin-right: 0.5vh; pointer-events: all;" class="gold inline"><a href="../${x.levelID}">(${x.levelID})</a></h3>` : ""} ${history ? `<h3 style="margin-right: 0.5vh; pointer-events: all;" class="gold inline"><a href="../${x.levelID}">(${x.levelID})</a></h3>` : ""}
<div class="inline gdButton likeComment" commentID="${x.ID}"${x.levelID ? `levelID="${x.levelID}"` : ""}> <div class="inline gdButton likeComment" commentID="${x.ID}"${x.levelID ? `levelID="${x.levelID}"` : ""}>
<img class="inline" ${x.likes < 0 ? "style='transform: translateY(15%); margin-right: 0.4%'" : ""} src="../assets/${x.likes < 0 ? "dis" : ""}like.png" height=27%> <img id="thumb-${x.ID}" class="inline" ${x.likes < 0 ? "style='transform: translateY(15%); margin-right: 0.4%'" : ""} src="../assets/${x.likes < 0 ? "dis" : ""}like.png" height=27%>
</div> </div>
<h3 class="inline">${x.likes}</h3> <h3 id="likes-${x.ID}" class="inline">${x.likes}</h3>
</div> </div>
</div>` </div>`

View file

@ -343,20 +343,20 @@ fetch('./api/icons').then(res => {
$("#cp2").on('input change', function() { $("#cp2").on('input change', function() {
picking[1] = true; colorBG(2, $(this).val(), true); picking[1] = true; colorBG(2, $(this).val(), true);
$(".color1").removeClass("iconSelected"); $("#done").show() $(".color2").removeClass("iconSelected"); $("#done").show()
}) })
$("#cpG").on('input change', function() { $("#cpG").on('input change', function() {
picking[2] = true; colorBG('G', $(this).val(), true); picking[2] = true; colorBG('G', $(this).val(), true);
$(".color1").removeClass("iconSelected"); $("#done").show() $(".colorG").removeClass("iconSelected"); $("#done").show()
}) })
$("#cpW").on('input change', function() { $("#cpW").on('input change', function() {
picking[3] = true; colorBG('W', $(this).val(), true); picking[3] = true; colorBG('W', $(this).val(), true);
$(".color1").removeClass("iconSelected"); $("#done").show() $(".colorW").removeClass("iconSelected"); $("#done").show()
}) })
$("#done").click(function() { $("#done img").click(function() {
$("#done").hide() $("#done").hide()
if (picking[0]) selectedCol1 = $('#cp1').val().slice(1) if (picking[0]) selectedCol1 = $('#cp1').val().slice(1)
if (picking[1]) selectedCol2 = $('#cp2').val().slice(1) if (picking[1]) selectedCol2 = $('#cp2').val().slice(1)

View file

@ -36,7 +36,7 @@ let sampleIcons = require('./misc/sampleIcons.json')
let colorList = require('./icons/colors.json') let colorList = require('./icons/colors.json')
let forms = { "player": "cube", "bird": "ufo", "dart": "wave" } let forms = { "player": "cube", "bird": "ufo", "dart": "wave" }
let whiteIcons = fs.readdirSync('./icons').filter(x => x.endsWith("extra_001.png")).map(function (x) { let xh = x.split("_"); return [xh[1] == "ball" ? "ball" : forms[xh[0]] || xh[0], +xh[xh[1] == "ball" ? 2 : 1]]}) let whiteIcons = fs.readdirSync('./icons').filter(x => x.endsWith("extra_001.png")).map(function (x) { let xh = x.split("_"); return [xh[1] == "ball" ? "ball" : forms[xh[0]] || xh[0], +xh[xh[1] == "ball" ? 2 : 1]]})
let colorOrder = [0, 1, 2, 3, 16, 4, 5, 6, 13, 7, 8, 9, 29, 10, 14, 11, 12, 17, 18, 15, 27, 32, 28, 38, 20, 33, 21, 34, 22, 39, 23, 35, 24, 36, 25, 37, 30, 26, 31, 19] let colorOrder = [0, 1, 2, 3, 16, 4, 5, 6, 13, 7, 8, 9, 29, 10, 14, 11, 12, 17, 18, 15, 27, 32, 28, 38, 20, 33, 21, 34, 22, 39, 23, 35, 24, 36, 25, 37, 30, 26, 31, 19, 40, 41]
app.use(compression()); app.use(compression());
app.use(express.json()); app.use(express.json());