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