From ddc0fd1c8399c225f9a198614d6f1dfc98bdcbdc Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Sat, 8 Oct 2022 09:00:20 +0200 Subject: gray out superseded votes Thanks to waldyrious for the suggestion! --- Vote.php | 14 ++++++++++++-- extension.json | 5 +++++ resources/style.css | 3 +++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 resources/style.css diff --git a/Vote.php b/Vote.php index 63d8fde..e72fb07 100644 --- a/Vote.php +++ b/Vote.php @@ -94,7 +94,7 @@ class VoteHooks { $voteText = ''; $votes = []; - foreach ($lines as $line) { + foreach ($lines as $idx => $line) { if (array_key_exists('raw', $line)) { $voteText .= $line['raw']; } elseif (array_key_exists('error', $line)) { @@ -105,6 +105,13 @@ class VoteHooks { $vote = $line['vote']; $voteText .= '* '; + $class = ''; + for ($i = $idx + 1; $i < count($lines); $i++) { + if (($lines[$i]['user'] ?? null) == $user) { + $class = 'uncounted-vote'; + } + } + $voteText .= ""; if (array_key_exists($user, $votes)) { if ($votes[$user] == $vote) { $voteText .= "(" . $msg('vote-repeated') . ') '; @@ -119,7 +126,8 @@ class VoteHooks { } $userLink = $parser->getLinkRenderer()->makeLink($line['userTitle'], $user); - $voteText .= " --$userLink ". $line['date']->format('H:i, j F Y') . "\n"; + $voteText .= " --$userLink ". $line['date']->format('H:i, j F Y'); + $voteText .= "\n"; } } @@ -152,6 +160,8 @@ class VoteHooks { $parser->addTrackingCategory('pages-with-open-votes-category', $parser->getTitle()); } + $parser->getOutput()->addModules(['ext.vote-css']); + return $text; } diff --git a/extension.json b/extension.json index d681f1b..4cd2418 100644 --- a/extension.json +++ b/extension.json @@ -22,6 +22,11 @@ "ParserFirstCallInit": "VoteHooks::onParserFirstCallInit" }, "ResourceModules": { + "ext.vote-css": { + "localBasePath": "resources", + "remoteExtPath": "Vote/resources", + "styles": ["style.css"] + }, "ext.vote-js": { "localBasePath": "resources", "remoteExtPath": "Vote/resources", diff --git a/resources/style.css b/resources/style.css new file mode 100644 index 0000000..a9ded0f --- /dev/null +++ b/resources/style.css @@ -0,0 +1,3 @@ +.uncounted-vote { + color: #777; +} -- cgit v1.2.3