mirror of
https://github.com/openvk/openvk
synced 2024-12-23 00:51:03 +03:00
Refactor rating bar
This commit is contained in:
parent
aa5ac03bb4
commit
5c9c09c7a9
3 changed files with 24 additions and 4 deletions
|
@ -397,9 +397,15 @@ class User extends RowModel
|
|||
$incompleteness += 20;
|
||||
}
|
||||
|
||||
$total = max(100 - $incompleteness + $this->getRating(), 0);
|
||||
if(quirk("profile.rating-bar-behaviour") === 0)
|
||||
$percent = intval(substr(strval($total), -2));
|
||||
else
|
||||
$percent = min($total, 100);
|
||||
|
||||
return (object) [
|
||||
"total" => 100 - $incompleteness + $this->getRating(),
|
||||
"percent" => min(100 - $incompleteness + $this->getRating(), 100),
|
||||
"total" => $total,
|
||||
"percent" => $percent,
|
||||
"unfilled" => $unfilled,
|
||||
];
|
||||
}
|
||||
|
|
|
@ -122,8 +122,8 @@
|
|||
<div n:if="isset($thisUser) && !$thisUser->prefersNotToSeeRating()" class="profile-hints">
|
||||
{var completeness = $user->getProfileCompletenessReport()}
|
||||
|
||||
<div class="completeness-gauge, $completeness->total >= 100 ? completeness-gauge-gold">
|
||||
<div style="width: {if ($completeness->total >= 100)}{round(($completeness->total / 10**strlen(strval($completeness->total))) * 100, 0)}{else}{$completeness->percent}{/if}%"></div>
|
||||
<div n:class="completeness-gauge, $completeness->total >= 100 ? completeness-gauge-gold">
|
||||
<div style="width: {$completeness->percent}%"></div>
|
||||
<span>{$completeness->total}%</span>
|
||||
</div>
|
||||
|
||||
|
|
14
quirks.yml
14
quirks.yml
|
@ -0,0 +1,14 @@
|
|||
# Rating bar behaviour
|
||||
# If rating overflows 100 older versions of OpenVK
|
||||
# used to render a full bar, but original VK used to
|
||||
# treat last two digits of rating as % of bar fullness.
|
||||
#
|
||||
# Example:
|
||||
# Rating 20 - Old OVK: 20%, VK: 20%
|
||||
# Rating 100 - Old OVK: 100%, VK: 100%
|
||||
# Rating 1983 - Old OVK: 100%, VK: 83%
|
||||
#
|
||||
# Possible values:
|
||||
# + Set this option to 1 if you want to use quirky OpenVK behaviour
|
||||
# + Set this option to 0 if you want to use the canonical VK behaviour
|
||||
profile.rating-bar-behaviour: 0
|
Loading…
Reference in a new issue