diff --git a/src/home/index.php b/src/home/index.php index b8b0d2681cd933950b2726dbd588be54c81496a3..ed2dca51f503ccb1234ce6dc27bab6f2e0e3600f 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 0000000000000000000000000000000000000000..f853c076af07716d164fa5fd3abd52ec01ae0b42 --- /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 bb43578b575a959b4bf01d16715fa97ca00df991..03598827c93c5476d98219a6440717f312bb6b0e 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 +}