Format numbers with commas.

This commit is contained in:
FireMasterK 2021-06-03 00:22:58 +05:30
parent 366d81a546
commit c594dc51b2
No known key found for this signature in database
GPG key ID: 8DFF5DD33E93DB58
2 changed files with 7 additions and 3 deletions

View file

@ -10,14 +10,14 @@
<p class="uk-dark">
<font-awesome-icon icon="thumbs-up"></font-awesome-icon>
<b>{{ video.likes }}</b>
<b>{{ addCommas(video.likes) }}</b>
&nbsp;
<font-awesome-icon icon="thumbs-down"></font-awesome-icon>
<b>{{ video.dislikes }}</b>
<b>{{ addCommas(video.dislikes) }}</b>
</p>
<p>
<font-awesome-icon icon="eye"></font-awesome-icon>
<b>{{ video.views }}</b> views
<b>{{ addCommas(video.views) }}</b> views
</p>
<p>
Uploaded on <b>{{ video.uploadDate }}</b>

View file

@ -49,6 +49,10 @@ const mixin = {
}
return (num / si[i].value).toFixed(digits).replace(rx, "$1") + si[i].symbol;
},
addCommas(num) {
num = parseInt(num)
return num.toLocaleString('en-US')
},
fetchJson: function (url, options) {
return fetch(url, options).then(response => {
return response.json();