From e2a787e519bf4e4f4163acff2819ffbf223a89bf Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Fri, 2 Jun 2023 23:43:22 +0100 Subject: [PATCH] Hide banner if mobile --- .../software/SPDF/config/AppConfig.java | 2 +- src/main/resources/static/js/homecard.js | 49 ++++++++++++++++ src/main/resources/templates/home.html | 58 +------------------ 3 files changed, 53 insertions(+), 56 deletions(-) create mode 100644 src/main/resources/static/js/homecard.js diff --git a/src/main/java/stirling/software/SPDF/config/AppConfig.java b/src/main/java/stirling/software/SPDF/config/AppConfig.java index ddffd045..430bcae8 100644 --- a/src/main/java/stirling/software/SPDF/config/AppConfig.java +++ b/src/main/java/stirling/software/SPDF/config/AppConfig.java @@ -16,7 +16,7 @@ public class AppConfig { @Bean(name = "appVersion") public String appVersion() { String version = getClass().getPackage().getImplementationVersion(); - return (version != null) ? version : "0.3.3"; + return (version != null) ? version : "0.0.0"; } @Bean(name = "homeText") diff --git a/src/main/resources/static/js/homecard.js b/src/main/resources/static/js/homecard.js new file mode 100644 index 00000000..f3d3de35 --- /dev/null +++ b/src/main/resources/static/js/homecard.js @@ -0,0 +1,49 @@ +function toggleFavorite(element) { + var img = element.querySelector('img'); + var card = element.closest('.feature-card'); + var cardId = card.id; + if (img.src.endsWith('star.svg')) { + img.src = 'images/star-fill.svg'; + card.classList.add('favorite'); + localStorage.setItem(cardId, 'favorite'); + } else { + img.src = 'images/star.svg'; + card.classList.remove('favorite'); + localStorage.removeItem(cardId); + } + reorderCards(); + updateFavoritesDropdown(); +} + +function reorderCards() { + var container = document.querySelector('.features-container'); + var cards = Array.from(container.getElementsByClassName('feature-card')); + cards.sort(function(a, b) { + var aIsFavorite = localStorage.getItem(a.id) === 'favorite'; + var bIsFavorite = localStorage.getItem(b.id) === 'favorite'; + if (aIsFavorite && !bIsFavorite) { + return -1; + } + if (!aIsFavorite && bIsFavorite) { + return 1; + } + return 0; + }); + cards.forEach(function(card) { + container.appendChild(card); + }); +} +function initializeCards() { + var cards = document.querySelectorAll('.feature-card'); + cards.forEach(function(card) { + var cardId = card.id; + var img = card.querySelector('.favorite-icon img'); + if (localStorage.getItem(cardId) === 'favorite') { + img.src = 'images/star-fill.svg'; + card.classList.add('favorite'); + } + }); + reorderCards(); + updateFavoritesDropdown(); +} +window.onload = initializeCards; \ No newline at end of file diff --git a/src/main/resources/templates/home.html b/src/main/resources/templates/home.html index 001bce45..1226d771 100644 --- a/src/main/resources/templates/home.html +++ b/src/main/resources/templates/home.html @@ -12,13 +12,13 @@
-
+

- +
@@ -69,59 +69,7 @@ - +