summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2018-10-19 11:14:26 -0500
committerOmar Roth <omarroth@hotmail.com>2018-10-19 11:14:26 -0500
commit5c87cf1547258c8b20133eae6909f5365d96a981 (patch)
tree72ff53854f1b74adb68919b351d453399df1205f
parent1cfa1f65591cc02c96778b0783114cad2e202e36 (diff)
downloadinvidious-5c87cf1547258c8b20133eae6909f5365d96a981.tar.gz
invidious-5c87cf1547258c8b20133eae6909f5365d96a981.tar.bz2
invidious-5c87cf1547258c8b20133eae6909f5365d96a981.zip
Update subscribe buttons
Diffstat (limited to '')
-rw-r--r--src/invidious/helpers/utils.cr19
-rw-r--r--src/invidious/views/channel.ecr8
-rw-r--r--src/invidious/views/watch.ecr8
3 files changed, 27 insertions, 8 deletions
diff --git a/src/invidious/helpers/utils.cr b/src/invidious/helpers/utils.cr
index 7ff2e622..dab8e0e9 100644
--- a/src/invidious/helpers/utils.cr
+++ b/src/invidious/helpers/utils.cr
@@ -138,6 +138,25 @@ def number_with_separator(number)
number.to_s.reverse.gsub(/(\d{3})(?=\d)/, "\\1,").reverse
end
+def number_to_short_text(number)
+ seperated = number_with_separator(number).gsub(",", ".").split("")
+ text = seperated.first(2).join
+
+ if seperated[2]? && seperated[2] != "."
+ text += seperated[2]
+ end
+
+ text = text.rchop(".0")
+
+ if number / 1000000 != 0
+ text += "M"
+ elsif number / 1000 != 0
+ text += "K"
+ end
+
+ text
+end
+
def arg_array(array, start = 1)
if array.size == 0
args = "NULL"
diff --git a/src/invidious/views/channel.ecr b/src/invidious/views/channel.ecr
index 4a3997aa..475d3880 100644
--- a/src/invidious/views/channel.ecr
+++ b/src/invidious/views/channel.ecr
@@ -19,14 +19,14 @@
<p>
<a id="subscribe" onclick="unsubscribe()" class="pure-button pure-button-primary"
href="/subscription_ajax?action_remove_subscriptions=1&c=<%= ucid %>&referer=<%= env.get("current_page") %>">
- <b>Unsubscribe from <%= author %> <%= number_with_separator(sub_count) %></b>
+ <b>Unsubscribe <%= number_to_short_text(sub_count) %></b>
</a>
</p>
<% else %>
<p>
<a id="subscribe" onclick="subscribe()" class="pure-button pure-button-primary"
href="/subscription_ajax?action_create_subscription_to_channel=1&c=<%= ucid %>&referer=<%= env.get("current_page") %>">
- <b>Subscribe to <%= author %> <%= number_with_separator(sub_count) %></b>
+ <b>Subscribe <%= number_to_short_text(sub_count) %></b>
</a>
</p>
<% end %>
@@ -82,7 +82,7 @@ function subscribe() {
if (xhr.status == 200) {
subscribe_button = document.getElementById("subscribe");
subscribe_button.onclick = unsubscribe;
- subscribe_button.innerHTML = '<b>Unsubscribe from <%= author %> <%= number_with_separator(sub_count + 1) %></b>'
+ subscribe_button.innerHTML = '<b>Unsubscribe <%= number_to_short_text(sub_count) %></b>'
}
}
}
@@ -101,7 +101,7 @@ function unsubscribe() {
if (xhr.status == 200) {
subscribe_button = document.getElementById("subscribe");
subscribe_button.onclick = subscribe;
- subscribe_button.innerHTML = '<b>Subscribe to <%= author %> <%= number_with_separator(sub_count) %></b>'
+ subscribe_button.innerHTML = '<b>Subscribe <%= number_to_short_text(sub_count) %></b>'
}
}
}
diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr
index 456526f4..866b8bad 100644
--- a/src/invidious/views/watch.ecr
+++ b/src/invidious/views/watch.ecr
@@ -94,14 +94,14 @@
<p>
<a id="subscribe" onclick="unsubscribe()" class="pure-button pure-button-primary"
href="/subscription_ajax?action_remove_subscriptions=1&c=<%= video.ucid %>&referer=<%= env.get("current_page") %>">
- <b>Unsubscribe from <%= video.author %> <%= video.sub_count_text %></b>
+ <b>Unsubscribe <%= video.sub_count_text %></b>
</a>
</p>
<% else %>
<p>
<a id="subscribe" onclick="subscribe()" class="pure-button pure-button-primary"
href="/subscription_ajax?action_create_subscription_to_channel=1&c=<%= video.ucid %>&referer=<%= env.get("current_page") %>">
- <b>Subscribe to <%= video.author %> <%= video.sub_count_text %></b>
+ <b>Subscribe <%= video.sub_count_text %></b>
</a>
</p>
<% end %>
@@ -170,7 +170,7 @@ function subscribe() {
if (xhr.status == 200) {
subscribe_button = document.getElementById("subscribe");
subscribe_button.onclick = unsubscribe;
- subscribe_button.innerHTML = '<b>Unsubscribe from <%= video.author %> <%= video.sub_count_text %></b>'
+ subscribe_button.innerHTML = '<b>Unsubscribe <%= video.sub_count_text %></b>'
}
}
}
@@ -189,7 +189,7 @@ function unsubscribe() {
if (xhr.status == 200) {
subscribe_button = document.getElementById("subscribe");
subscribe_button.onclick = subscribe;
- subscribe_button.innerHTML = '<b>Subscribe to <%= video.author %> <%= video.sub_count_text %></b>'
+ subscribe_button.innerHTML = '<b>Subscribe <%= video.sub_count_text %></b>'
}
}
}