mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
Render like count textually.
This commit is contained in:
parent
7a790c3491
commit
ec630087b6
2 changed files with 17 additions and 1 deletions
|
@ -63,7 +63,7 @@
|
||||||
</div>
|
</div>
|
||||||
<p>{{ comment.commentText }}</p>
|
<p>{{ comment.commentText }}</p>
|
||||||
<div>
|
<div>
|
||||||
<b>{{ comment.likeCount }}</b>
|
<b>{{ numberFormat(comment.likeCount) }}</b>
|
||||||
|
|
||||||
<font-awesome-icon icon="thumbs-up"></font-awesome-icon>
|
<font-awesome-icon icon="thumbs-up"></font-awesome-icon>
|
||||||
|
|
||||||
|
|
16
src/main.js
16
src/main.js
|
@ -33,6 +33,22 @@ const mixin = {
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
},
|
},
|
||||||
|
numberFormat(num) {
|
||||||
|
const digits = 2;
|
||||||
|
const si = [
|
||||||
|
{ value: 1, symbol: "" },
|
||||||
|
{ value: 1E3, symbol: "k" },
|
||||||
|
{ value: 1E6, symbol: "M" },
|
||||||
|
{ value: 1E9, symbol: "B" }
|
||||||
|
];
|
||||||
|
const rx = /\.0+$|(\.[0-9]*[1-9])0+$/;
|
||||||
|
for (var i = si.length - 1; i > 0; i--) {
|
||||||
|
if (num >= si[i].value) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (num / si[i].value).toFixed(digits).replace(rx, "$1") + si[i].symbol;
|
||||||
|
},
|
||||||
fetchJson: function (url, options) {
|
fetchJson: function (url, options) {
|
||||||
return fetch(url, options).then(response => {
|
return fetch(url, options).then(response => {
|
||||||
return response.json();
|
return response.json();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue