Fix: #227
This commit is contained in:
parent
c8786ca00f
commit
343b02bf19
|
@ -1391,6 +1391,7 @@ function client(name) {
|
|||
}
|
||||
//Poll Parser
|
||||
function pollParse(poll, acct_id, emojis) {
|
||||
var rand = randomStr(8)
|
||||
var datetype = localStorage.getItem('datetype')
|
||||
var anime = localStorage.getItem('animation')
|
||||
if (anime == 'yes' || !anime) {
|
||||
|
@ -1408,7 +1409,7 @@ function pollParse(poll, acct_id, emojis) {
|
|||
} else {
|
||||
var minechoice = []
|
||||
}
|
||||
var refresh = `<a onclick="voteMastodonrefresh('${acct_id}','${poll.id}')" class="pointer">
|
||||
var refresh = `<a onclick="voteMastodonrefresh('${acct_id}','${poll.id}','${rand}')" class="pointer">
|
||||
${lang.lang_manager_refresh}
|
||||
</a>`
|
||||
if (poll.voted && poll.own_votes.length) {
|
||||
|
@ -1423,11 +1424,11 @@ function pollParse(poll, acct_id, emojis) {
|
|||
var myvote = lang.lang_parse_endedvote
|
||||
var result_hide = ''
|
||||
} else {
|
||||
var myvote = `<a onclick="voteMastodon('${acct_id}','${poll.id}')" class="votebtn">${lang.lang_parse_vote}</a><br>`
|
||||
var myvote = `<a onclick="voteMastodon('${acct_id}','${poll.id}','${rand}')" class="votebtn">${lang.lang_parse_vote}</a><br>`
|
||||
if (choices[0].votes_count === 0 || choices[0].votes_count > 0) {
|
||||
myvote =
|
||||
myvote +
|
||||
`<a onclick="showResult('${acct_id}','${poll.id}')" class="pointer">
|
||||
`<a onclick="showResult('${acct_id}','${poll.id}','${rand}')" class="pointer">
|
||||
${lang.lang_parse_unvoted}
|
||||
</a> `
|
||||
}
|
||||
|
@ -1454,7 +1455,7 @@ function pollParse(poll, acct_id, emojis) {
|
|||
}
|
||||
if (!poll.voted && !poll.expired) {
|
||||
var votesel =
|
||||
"voteSelMastodon('" + acct_id + "','" + poll.id + "'," + keyc + ',' + poll.multiple + ')'
|
||||
`voteSelMastodon('${acct_id}','${poll.id}',${keyc},${poll.multiple}, this)`
|
||||
var voteclass = 'pointer'
|
||||
} else {
|
||||
var votesel = ''
|
||||
|
@ -1469,9 +1470,9 @@ function pollParse(poll, acct_id, emojis) {
|
|||
}
|
||||
var openData = ''
|
||||
if (choice.votes_count !== null) {
|
||||
openData = `<span style="float: right">${choice.votes_count}<span class="sml">(${per}%)</span></span>`
|
||||
openData = `<span style="float: right">${voteit}${choice.votes_count}<span class="sml">(${per}%)</span></span>`
|
||||
} else {
|
||||
openData = `<span style="float: right">?<span class="sml">(-%)</span></span>`
|
||||
openData = `<span style="float: right">${voteit}?<span class="sml">(-%)</span></span>`
|
||||
}
|
||||
var choiceText = escapeHTML(choice.title)
|
||||
if (emojis) {
|
||||
|
@ -1497,7 +1498,7 @@ function pollParse(poll, acct_id, emojis) {
|
|||
pollHtml +
|
||||
`<div class="${voteclass} vote vote_${acct_id}_${poll.id}_${keyc}" onclick="${votesel}">
|
||||
<span class="vote_${acct_id}_${poll.id}_result leadPoll ${result_hide} ${addPoll} ${lpAnime}" style="width: ${per}%"></span>
|
||||
<span class="onPoll">${choiceText}${voteit}</span>
|
||||
<span class="onPoll">${choiceText}</span>
|
||||
<span class="vote_${acct_id}_${poll.id}_result ${result_hide} onPoll">
|
||||
${openData}
|
||||
</span>
|
||||
|
@ -1506,7 +1507,7 @@ function pollParse(poll, acct_id, emojis) {
|
|||
if (poll.expired) {
|
||||
refresh = ''
|
||||
}
|
||||
pollHtml = `<div class="vote_${acct_id}_${poll.id}">
|
||||
pollHtml = `<div class="vote_${acct_id}_${poll.id}" id="vote${rand}">
|
||||
${pollHtml}${myvote}
|
||||
${refresh}
|
||||
<span class="cbadge cbadge-hover" title="${date(poll.expires_at, 'absolute')}">
|
||||
|
|
|
@ -49,30 +49,25 @@ function pollCalc() {
|
|||
return days * 86400 + hrs * 3600 + mins * 60
|
||||
}
|
||||
//Vote
|
||||
function voteSelMastodon(acct_id, id, to, mul) {
|
||||
if ($('.vote_' + acct_id + '_' + id + '_' + to).hasClass('sel')) {
|
||||
$('.vote_' + acct_id + '_' + id + '_' + to).css('background-color', 'transparent')
|
||||
$('.vote_' + acct_id + '_' + id + '_' + to).removeClass('sel')
|
||||
function voteSelMastodon(acct_id, id, to, mul, elem) {
|
||||
if ($(elem).hasClass('sel')) {
|
||||
$(elem).css('background-color', 'transparent')
|
||||
$(elem).removeClass('sel')
|
||||
} else {
|
||||
if (!mul) {
|
||||
$('.vote_' + acct_id + '_' + id + ' div').each(function(i, elem) {
|
||||
if (i == to) {
|
||||
$(this).css('background-color', 'var(--emphasized)')
|
||||
$(this).addClass('sel')
|
||||
$('.vote_' + acct_id + '_' + id + ' div').css('background-color', 'transparent')
|
||||
$('.vote_' + acct_id + '_' + id + ' div').removeClass('sel')
|
||||
$(elem).css('background-color', 'var(--emphasized)')
|
||||
$(elem).addClass('sel')
|
||||
} else {
|
||||
$(this).css('background-color', 'transparent')
|
||||
$(this).removeClass('sel')
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$('.vote_' + acct_id + '_' + id + '_' + to).css('background-color', 'var(--emphasized)')
|
||||
$('.vote_' + acct_id + '_' + id + '_' + to).addClass('sel')
|
||||
$(elem).css('background-color', 'var(--emphasized)')
|
||||
$(elem).addClass('sel')
|
||||
}
|
||||
}
|
||||
}
|
||||
function voteMastodon(acct_id, id) {
|
||||
function voteMastodon(acct_id, id, target) {
|
||||
var choice = []
|
||||
$('.vote_' + acct_id + '_' + id + ' div').each(function(i, elem) {
|
||||
$(`#vote${target} div`).each(function(i, elem) {
|
||||
if ($(this).hasClass('sel')) {
|
||||
choice.push(i + '')
|
||||
}
|
||||
|
@ -90,13 +85,13 @@ function voteMastodon(acct_id, id) {
|
|||
httpreq.responseType = 'json'
|
||||
httpreq.send(JSON.stringify({ choices: choice }))
|
||||
httpreq.onreadystatechange = function() {
|
||||
voteMastodonrefresh(acct_id, id)
|
||||
voteMastodonrefresh(acct_id, id, target)
|
||||
}
|
||||
}
|
||||
function showResult(acct_id, id) {
|
||||
$('.vote_' + acct_id + '_' + id + '_result').toggleClass('hide')
|
||||
}
|
||||
function voteMastodonrefresh(acct_id, id) {
|
||||
function voteMastodonrefresh(acct_id, id, target) {
|
||||
var datetype = localStorage.getItem('datetype')
|
||||
if (!datetype) {
|
||||
datetype = 'absolute'
|
||||
|
@ -121,7 +116,7 @@ function voteMastodonrefresh(acct_id, id) {
|
|||
return false
|
||||
}
|
||||
var poll = pollParse(json, acct_id, json.emojis)
|
||||
$('.vote_' + acct_id + '_' + json.id).html(poll)
|
||||
$(`#vote${target}`).html(poll)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user