From 60887ff167a6e1ad4daeed3ea17e1d5219bf655a Mon Sep 17 00:00:00 2001 From: unknown <13521043@std.stei.itb.ac.id> Date: Tue, 24 Oct 2023 00:27:28 +0700 Subject: [PATCH] update: seperate format card --- src/home/index.php | 1 + src/public/javascript/gym/format_card.js | 19 +++++++++++++++++++ src/public/javascript/gym/gym_card.js | 22 +--------------------- 3 files changed, 21 insertions(+), 21 deletions(-) create mode 100644 src/public/javascript/gym/format_card.js diff --git a/src/home/index.php b/src/home/index.php index b8b0d26..ed2dca5 100644 --- a/src/home/index.php +++ b/src/home/index.php @@ -91,6 +91,7 @@ $selectedSorting = $_GET["sorting"] ?? null; </div> </div> + <script src="/public/javascript/gym/format_card.js"></script> <script src="/public/javascript/gym/gym_card.js"></script> <script src="/public/javascript/pagination.js"></script> <script src="/public/javascript/gym/filter.js"></script> diff --git a/src/public/javascript/gym/format_card.js b/src/public/javascript/gym/format_card.js new file mode 100644 index 0000000..f853c07 --- /dev/null +++ b/src/public/javascript/gym/format_card.js @@ -0,0 +1,19 @@ +function truncateText(text, length) +{ + if (text.length <= length) { + return text; + } else { + text = text.substring(0, length-3); + text = text + "..."; + return text; + } +} + +function formatPrice(price) +{ + if (price == 0) { + return "Free"; + } + price = price.toLocaleString('id-ID'); + return 'Rp' + price; +} \ No newline at end of file diff --git a/src/public/javascript/gym/gym_card.js b/src/public/javascript/gym/gym_card.js index bb43578..0359882 100644 --- a/src/public/javascript/gym/gym_card.js +++ b/src/public/javascript/gym/gym_card.js @@ -1,23 +1,3 @@ -function truncateText(text, length) -{ - if (text.length <= length) { - return text; - } else { - text = text.substring(0, length-3); - text = text + "..."; - return text; - } -} - -function formatPrice(price) -{ - if (price == 0) { - return "Free"; - } - price = price.toLocaleString('id-ID'); - return 'Rp' + price; -} - function GymCard(gym){ let truncated_name = truncateText(gym.name, 16); let formatted_price = formatPrice(gym.monthly_price); @@ -41,4 +21,4 @@ function GymCard(gym){ </a> `; return gym_card; -} \ No newline at end of file +} -- GitLab