Improve: vote

This commit is contained in:
cutls 2019-11-26 01:02:15 +09:00
parent b35ecbf79c
commit 2cc8551386
4 changed files with 38 additions and 11 deletions

View File

@ -643,6 +643,7 @@ p:not(:last-child) {
margin-top: 3px; margin-top: 3px;
padding: 1px; padding: 1px;
border-radius: 3px; border-radius: 3px;
overflow: hidden;
} }
.fa-2x > .emoji-img { .fa-2x > .emoji-img {
width: 36px !important; width: 36px !important;
@ -681,6 +682,18 @@ p:not(:last-child) {
.votebtn:hover { .votebtn:hover {
background-color: var(--color); background-color: var(--color);
} }
.leadPoll {
position: absolute;
background-color: var(--box);
height: 20px;
border-radius: 3px;
}
.onPoll {
position: relative;
}
.maxVoter {
background-color: var(--shared);
}
.jump { .jump {
display: inline-block; display: inline-block;
animation: jump 0.75s linear infinite; animation: jump 0.75s linear infinite;

View File

@ -1350,9 +1350,12 @@ function pollParse(poll, acct_id) {
} else { } else {
var minechoice = [] var minechoice = []
} }
var refresh = `<a onclick="voteMastodonrefresh('${acct_id}','${poll.id}')" class="pointer">
${lang.lang_manager_refresh}
</a>`
if (poll.voted) { if (poll.voted) {
var myvote = lang.lang_parse_voted var myvote = lang.lang_parse_voted
if(poll.expired) myvote = myvote + '/' + lang.lang_parse_endedvote
var result_hide = '' var result_hide = ''
} else if (poll.expired) { } else if (poll.expired) {
var myvote = lang.lang_parse_endedvote var myvote = lang.lang_parse_endedvote
@ -1364,12 +1367,13 @@ function pollParse(poll, acct_id) {
myvote + myvote +
`<a onclick="showResult('${acct_id}','${poll.id}')" class="pointer"> `<a onclick="showResult('${acct_id}','${poll.id}')" class="pointer">
${lang.lang_parse_unvoted} ${lang.lang_parse_unvoted}
</a>` </a> `
} }
var result_hide = 'hide' var result_hide = 'hide'
} }
var ended = date(poll.expires_at, datetype) var ended = date(poll.expires_at, datetype)
var pollHtml = '' var pollHtml = ''
var max = _.maxBy(choices, 'votes_count').votes_count;
Object.keys(choices).forEach(function(keyc) { Object.keys(choices).forEach(function(keyc) {
var choice = choices[keyc] var choice = choices[keyc]
var voteit = '' var voteit = ''
@ -1388,25 +1392,33 @@ function pollParse(poll, acct_id) {
var votesel = '' var votesel = ''
var voteclass = '' var voteclass = ''
} }
var per = Math.ceil(choice.votes_count / poll.votes_count * 100)
if(max == choice.votes_count) {
var addPoll = 'maxVoter'
} else {
var addPoll = ''
}
pollHtml = pollHtml =
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}">
${escapeHTML(choice.title)} <span class="leadPoll ${addPoll}" style="width: ${per}%"></span>
<span class="vote_${acct_id}_${poll.id}_result ${result_hide}"> <span class="onPoll">${escapeHTML(choice.title)}</span>
(${choice.votes_count}) <span class="vote_${acct_id}_${poll.id}_result ${result_hide} onPoll">
(${choice.votes_count}/${per}%)
</span> </span>
${voteit} ${voteit}
</div>` </div>`
}) })
if (poll.expired) {
refresh = ''
}
pollHtml = `<div class="vote_${acct_id}_${poll.id}"> pollHtml = `<div class="vote_${acct_id}_${poll.id}">
${pollHtml}${myvote} ${pollHtml}${myvote}
<a onclick="voteMastodonrefresh('${acct_id}','${poll.id}')" class="pointer"> ${refresh}
${lang.lang_manager_refresh}
</a>
<span class="cbadge cbadge-hover" title="${date(poll.expires_at, 'absolute')}"> <span class="cbadge cbadge-hover" title="${date(poll.expires_at, 'absolute')}">
<i class="far fa-calendar-times"></i> <i class="far fa-calendar-times"></i>
${ended} ${ended}
</span> </span>${poll.voters_count} ${lang.lang_parse_people}
</div>` </div>`
return pollHtml return pollHtml
} }

View File

@ -199,10 +199,11 @@
"lang_parse_clientemp": "emphasized(/not emphasized)", "lang_parse_clientemp": "emphasized(/not emphasized)",
"lang_parse_clientmute": "muted", "lang_parse_clientmute": "muted",
"lang_parse_mute": " will be muted. You can remove on preferences.", "lang_parse_mute": " will be muted. You can remove on preferences.",
"lang_parse_voted": "Voted", "lang_parse_voted": "(Voted or mine poll)",
"lang_parse_vote": "Vote", "lang_parse_vote": "Vote",
"lang_parse_unvoted": "Show the result without voting", "lang_parse_unvoted": "Show the result without voting",
"lang_parse_endedvote": "Expired", "lang_parse_endedvote": "Expired",
"lang_parse_people": "people",
"lang_parse_thread": "Show thread", "lang_parse_thread": "Show thread",
"lang_parse_unknown": "Attached file", "lang_parse_unknown": "Attached file",
"lang_parse_nsfw": "sensitive media", "lang_parse_nsfw": "sensitive media",

View File

@ -199,10 +199,11 @@
"lang_parse_clientemp": "強調表示/解除", "lang_parse_clientemp": "強調表示/解除",
"lang_parse_clientmute": "ミュート", "lang_parse_clientmute": "ミュート",
"lang_parse_mute": "ミュートします。設定から解除できます。", "lang_parse_mute": "ミュートします。設定から解除できます。",
"lang_parse_voted": "投票済みです", "lang_parse_voted": "(投票済みもしくは自分)",
"lang_parse_vote": "投票", "lang_parse_vote": "投票",
"lang_parse_unvoted": "結果だけ見る", "lang_parse_unvoted": "結果だけ見る",
"lang_parse_endedvote": "終了済み", "lang_parse_endedvote": "終了済み",
"lang_parse_people": "人",
"lang_parse_thread": "会話を表示", "lang_parse_thread": "会話を表示",
"lang_parse_unknown": "添付ファイル", "lang_parse_unknown": "添付ファイル",
"lang_parse_nsfw": "閲覧注意", "lang_parse_nsfw": "閲覧注意",