From 2cc85513868c0fd45ab490b5a9f1902a5e45da2e Mon Sep 17 00:00:00 2001 From: cutls Date: Tue, 26 Nov 2019 01:02:15 +0900 Subject: [PATCH] Improve: vote --- app/css/tl.css | 13 +++++++++++++ app/js/tl/parse.js | 30 ++++++++++++++++++++--------- app/view/make/language/en/main.json | 3 ++- app/view/make/language/ja/main.json | 3 ++- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/app/css/tl.css b/app/css/tl.css index ed58612d..401ed0db 100644 --- a/app/css/tl.css +++ b/app/css/tl.css @@ -643,6 +643,7 @@ p:not(:last-child) { margin-top: 3px; padding: 1px; border-radius: 3px; + overflow: hidden; } .fa-2x > .emoji-img { width: 36px !important; @@ -681,6 +682,18 @@ p:not(:last-child) { .votebtn:hover { 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 { display: inline-block; animation: jump 0.75s linear infinite; diff --git a/app/js/tl/parse.js b/app/js/tl/parse.js index 765a278e..6ab86858 100644 --- a/app/js/tl/parse.js +++ b/app/js/tl/parse.js @@ -1350,9 +1350,12 @@ function pollParse(poll, acct_id) { } else { var minechoice = [] } - + var refresh = ` + ${lang.lang_manager_refresh} + ` if (poll.voted) { var myvote = lang.lang_parse_voted + if(poll.expired) myvote = myvote + '/' + lang.lang_parse_endedvote var result_hide = '' } else if (poll.expired) { var myvote = lang.lang_parse_endedvote @@ -1364,12 +1367,13 @@ function pollParse(poll, acct_id) { myvote + ` ${lang.lang_parse_unvoted} - ` +  ` } var result_hide = 'hide' } var ended = date(poll.expires_at, datetype) var pollHtml = '' + var max = _.maxBy(choices, 'votes_count').votes_count; Object.keys(choices).forEach(function(keyc) { var choice = choices[keyc] var voteit = '' @@ -1388,25 +1392,33 @@ function pollParse(poll, acct_id) { var votesel = '' 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 + `
- ${escapeHTML(choice.title)} - - (${choice.votes_count}) + + ${escapeHTML(choice.title)} + + (${choice.votes_count}/${per}%) ${voteit}
` }) + if (poll.expired) { + refresh = '' + } pollHtml = `
${pollHtml}${myvote} - - ${lang.lang_manager_refresh} - + ${refresh} ${ended} - + ${poll.voters_count} ${lang.lang_parse_people}
` return pollHtml } diff --git a/app/view/make/language/en/main.json b/app/view/make/language/en/main.json index 8faecb9d..ce1f4440 100644 --- a/app/view/make/language/en/main.json +++ b/app/view/make/language/en/main.json @@ -199,10 +199,11 @@ "lang_parse_clientemp": "emphasized(/not emphasized)", "lang_parse_clientmute": "muted", "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_unvoted": "Show the result without voting", "lang_parse_endedvote": "Expired", + "lang_parse_people": "people", "lang_parse_thread": "Show thread", "lang_parse_unknown": "Attached file", "lang_parse_nsfw": "sensitive media", diff --git a/app/view/make/language/ja/main.json b/app/view/make/language/ja/main.json index 3be0b5e6..fb0968e6 100644 --- a/app/view/make/language/ja/main.json +++ b/app/view/make/language/ja/main.json @@ -199,10 +199,11 @@ "lang_parse_clientemp": "強調表示/解除", "lang_parse_clientmute": "ミュート", "lang_parse_mute": "ミュートします。設定から解除できます。", - "lang_parse_voted": "投票済みです", + "lang_parse_voted": "(投票済みもしくは自分)", "lang_parse_vote": "投票", "lang_parse_unvoted": "結果だけ見る", "lang_parse_endedvote": "終了済み", + "lang_parse_people": "人", "lang_parse_thread": "会話を表示", "lang_parse_unknown": "添付ファイル", "lang_parse_nsfw": "閲覧注意",