mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Showing vote thanks page, restricting vote names to pre specified ones
This commit is contained in:
parent
d55115f353
commit
bd8e46f6c7
2 changed files with 53 additions and 4 deletions
|
@ -40,6 +40,7 @@ const dataEditsLog = 'stats/dataEdits'
|
||||||
const dailyDataCountFile = 'stats/dailyDataCount'
|
const dailyDataCountFile = 'stats/dailyDataCount'
|
||||||
const usersDbBackupPath = 'data/dbs/backup'
|
const usersDbBackupPath = 'data/dbs/backup'
|
||||||
const quickVoteResultsDir = 'stats/qvote'
|
const quickVoteResultsDir = 'stats/qvote'
|
||||||
|
const quickVotes = 'stats/qvote/votes.json'
|
||||||
|
|
||||||
// other constants
|
// other constants
|
||||||
const maxVeteranPwGetCount = 10
|
const maxVeteranPwGetCount = 10
|
||||||
|
@ -135,13 +136,30 @@ function GetApp () {
|
||||||
const val = req.query.val
|
const val = req.query.val
|
||||||
|
|
||||||
if (!key || !val) {
|
if (!key || !val) {
|
||||||
res.json({
|
res.render('votethank', {
|
||||||
results: 'error',
|
results: 'error',
|
||||||
msg: 'no key or val query param!'
|
msg: 'no key or val query param!'
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let votes = {}
|
||||||
|
if (utils.FileExists(quickVotes)) {
|
||||||
|
votes = utils.ReadJSON(quickVotes)
|
||||||
|
} else {
|
||||||
|
res.render('votethank', {
|
||||||
|
result: 'no such pool'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!votes.voteNames.includes(key)) {
|
||||||
|
res.render('votethank', {
|
||||||
|
result: 'no such pool'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const voteFile = quickVoteResultsDir + '/' + key + '.json'
|
const voteFile = quickVoteResultsDir + '/' + key + '.json'
|
||||||
const user = req.session.user
|
const user = req.session.user
|
||||||
|
|
||||||
|
@ -165,14 +183,14 @@ function GetApp () {
|
||||||
voteData.users.push(user.id)
|
voteData.users.push(user.id)
|
||||||
|
|
||||||
logger.Log(`Vote from #${user.id}: ${key}: ${val}`, logger.GetColor('blue'))
|
logger.Log(`Vote from #${user.id}: ${key}: ${val}`, logger.GetColor('blue'))
|
||||||
res.json({
|
res.render('votethank', {
|
||||||
result: 'success',
|
result: 'success',
|
||||||
msg: 'vote added'
|
msg: 'vote added'
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
logger.Log(`#${user.id} already voted for: ${key}: ${val}`, logger.GetColor('blue'))
|
logger.Log(`#${user.id} already voted for: ${key}: ${val}`, logger.GetColor('blue'))
|
||||||
res.json({
|
res.render('votethank', {
|
||||||
result: 'success',
|
result: 'already voted',
|
||||||
msg: 'already voted'
|
msg: 'already voted'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
31
modules/api/views/votethank.ejs
Executable file
31
modules/api/views/votethank.ejs
Executable file
|
@ -0,0 +1,31 @@
|
||||||
|
<html>
|
||||||
|
<body bgcolor="#212127">
|
||||||
|
<head>
|
||||||
|
<title>Shit uploader</title>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<style>
|
||||||
|
.main {
|
||||||
|
font-size: 28px;
|
||||||
|
color: #ffffff;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<div class='main'>
|
||||||
|
<%
|
||||||
|
if (result == 'success') {
|
||||||
|
%> ty a szavazásért c: <%
|
||||||
|
} else if (result == 'no such pool') {
|
||||||
|
%> Ilyen nevű szavazás nincs :c <%
|
||||||
|
} else if (result == 'already voted') {
|
||||||
|
%> Már szavaztál, de azért ty c: <%
|
||||||
|
} else if (result == 'error') {
|
||||||
|
%> Helytelen url paraméterek :c <%
|
||||||
|
} else {
|
||||||
|
%> bit of a fuckup here <%
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
ty c:
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Add table
Add a link
Reference in a new issue