From c6fdbfd9fd8a490ca48c72c4dafba048e289d372 Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Mon, 15 Mar 2021 07:12:10 +0000 Subject: [PATCH] Better format ranges on subscription manager page --- public/js/subscription.js | 9 ++++ src/views/subscription.html.ecr | 94 ++++++++++++++++----------------- 2 files changed, 54 insertions(+), 49 deletions(-) diff --git a/public/js/subscription.js b/public/js/subscription.js index e6e4909..ed2cb17 100644 --- a/public/js/subscription.js +++ b/public/js/subscription.js @@ -68,6 +68,15 @@ const component = () => { .fail((jqXHR, status) => { alert('danger', `Failed to check subscription. Error: [${jqXHR.status}] ${jqXHR.statusText}`); }); + }, + + formatRange(min, max) { + if (!isNaN(min) && isNaN(max)) return `≥ ${min}`; + if (isNaN(min) && !isNaN(max)) return `≤ ${max}`; + if (isNaN(min) && isNaN(max)) return 'All'; + + if (min === max) return `= ${min}`; + return `${min} - ${max}`; } }; }; diff --git a/src/views/subscription.html.ecr b/src/views/subscription.html.ecr index c01604e..cc96c47 100644 --- a/src/views/subscription.html.ecr +++ b/src/views/subscription.html.ecr @@ -1,58 +1,54 @@

MangaDex Subscription Manager

-

The subscription manager uses a MangaDex API that requires authentication. Please connect to MangaDex before using this feature.

+

The subscription manager uses a MangaDex API that requires authentication. Please connect to MangaDex before using this feature.

-

No subscription found. Go to the MangaDex download page and start subscribing.

+

No subscription found. Go to the MangaDex download page and start subscribing.

- +
<% content_for "script" do %> - <%= render_component "moment" %> - - + <%= render_component "moment" %> + + <% end %>