summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-10-20 13:52:06 -0500
committerOmar Roth <omarroth@hotmail.com>2018-10-20 13:52:06 -0500
commit3ee7201f5d1eb9655fc11f0f377529ec71a3b834 (patch)
tree9a2e92d681a3c20e27139153c1b3f6812cb29041
parent3c634d9f66ca39debd1f9946f07094634109d0fa (diff)
downloadinvidious-3ee7201f5d1eb9655fc11f0f377529ec71a3b834.tar.gz
invidious-3ee7201f5d1eb9655fc11f0f377529ec71a3b834.tar.bz2
invidious-3ee7201f5d1eb9655fc11f0f377529ec71a3b834.zip
Comma seperate comment scores
-rw-r--r--assets/js/watch.js7
-rw-r--r--src/invidious/comments.cr4
-rw-r--r--src/invidious/views/watch.ecr9
3 files changed, 10 insertions, 10 deletions
diff --git a/assets/js/watch.js b/assets/js/watch.js
index 4a84769e..99500686 100644
--- a/assets/js/watch.js
+++ b/assets/js/watch.js
@@ -28,13 +28,6 @@ function swap_comments(source) {
}
}
-function commaSeparateNumber(val) {
- while (/(\d+)(\d{3})/.test(val.toString())) {
- val = val.toString().replace(/(\d+)(\d{3})/, "$1" + "," + "$2");
- }
- return val;
-}
-
String.prototype.supplant = function(o) {
return this.replace(/{([^{}]*)}/g, function(a, b) {
var r = o[b];
diff --git a/src/invidious/comments.cr b/src/invidious/comments.cr
index 98062f4e..6a42701c 100644
--- a/src/invidious/comments.cr
+++ b/src/invidious/comments.cr
@@ -115,7 +115,7 @@ def template_youtube_comments(comments)
<p style="white-space:pre-wrap">#{child["contentHtml"]}</p>
#{recode_date(Time.epoch(child["published"].as_i64))} ago
|
- <i class="icon ion-ios-thumbs-up"></i> #{child["likeCount"]}
+ <i class="icon ion-ios-thumbs-up"></i> #{number_with_separator(child["likeCount"])}
</p>
#{replies_html}
</div>
@@ -158,7 +158,7 @@ def template_reddit_comments(root)
<p>
<a href="javascript:void(0)" onclick="toggle_parent(this)">[ - ]</a>
<b><a href="https://www.reddit.com/user/#{author}">#{author}</a></b>
- #{score} points
+ #{number_with_separator(score)} points
#{recode_date(child.created_utc)} ago
</p>
<div>
diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr
index 4fbd4d5b..9424bd10 100644
--- a/src/invidious/views/watch.ecr
+++ b/src/invidious/views/watch.ecr
@@ -152,6 +152,13 @@
</div>
<script>
+function number_with_separator(val) {
+ while (/(\d+)(\d{3})/.test(val.toString())) {
+ val = val.toString().replace(/(\d+)(\d{3})/, "$1" + "," + "$2");
+ }
+ return val;
+}
+
subscribe_button = document.getElementById("subscribe");
if (subscribe_button.getAttribute('onclick')) {
subscribe_button["href"] = "javascript:void(0);";
@@ -345,7 +352,7 @@ function get_youtube_comments() {
<div>{contentHtml}</div> \
<hr>'.supplant({
contentHtml: xhr.response.contentHtml,
- commentCount: commaSeparateNumber(xhr.response.commentCount)
+ commentCount: number_with_separator(xhr.response.commentCount)
});
} else {
comments.innerHTML = "";