From 5859dbce105779105ebbdf31d5f342e0d61b1659 Mon Sep 17 00:00:00 2001 From: grandeljay Date: Sat, 11 Jun 2022 15:28:07 +0200 Subject: [PATCH] Refactor --- src/assets/js/wishlists.js | 6 ++---- src/classes/cache/embed.php | 6 +++--- src/classes/wish.php | 4 +++- src/pages/parts/wish-add.php | 18 +++++++++--------- src/pages/wishlists.php | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/assets/js/wishlists.js b/src/assets/js/wishlists.js index e3c01798..bc42a3b7 100644 --- a/src/assets/js/wishlists.js +++ b/src/assets/js/wishlists.js @@ -444,10 +444,12 @@ $(function () { $(document).on('click', '.button.wishlist-wish-add', function () { validateURL = true; + /** Form */ var formAdd = $('.form.wishlist-wish-add'); formAdd.trigger('reset'); formAdd.find('.dropdown').dropdown('restore defaults'); + /** Modal */ var modalWishlistWishAdd = $('.ui.modal.wishlist-wish-add'); modalWishlistWishAdd.find('[name="wishlist_id"]').val($('.ui.dropdown.wishlists').dropdown('get value')); modalWishlistWishAdd @@ -585,8 +587,6 @@ $(function () { .then(handleFetchError) .then(handleFetchResponse) .then(function(response) { - console.log(response); - $('body').toast({ message: text.toast_wish_update }); wishlistsRefresh(); @@ -614,8 +614,6 @@ $(function () { .then(handleFetchError) .then(handleFetchResponse) .then(function(response) { - console.log(response); - $('body').toast({ message: text.toast_wish_update }); wishlistsRefresh(); diff --git a/src/classes/cache/embed.php b/src/classes/cache/embed.php index 4f49cd2a..999a0e52 100644 --- a/src/classes/cache/embed.php +++ b/src/classes/cache/embed.php @@ -51,7 +51,7 @@ class Embed extends Cache $info_simplified->favicon = ''; $info_simplified->feeds = array(); $info_simplified->icon = ''; - $info_simplified->image = ''; + $info_simplified->image = null; $info_simplified->keywords = array(); $info_simplified->language = ''; $info_simplified->languages = array(); @@ -74,7 +74,7 @@ class Embed extends Cache $info_simplified->favicon = (string) $info->favicon; $info_simplified->feeds = (array) $info->feeds; $info_simplified->icon = (string) $info->icon; - $info_simplified->image = isset($info->image) ? (string) $info->image : null; + $info_simplified->image = isset($info->image) && $info->image ? (string) $info->image : null; $info_simplified->keywords = (array) $info->keywords; $info_simplified->language = (string) $info->language; $info_simplified->languages = (array) $info->languages; @@ -116,7 +116,7 @@ class Embed extends Cache $info_simplified->favicon = $favicon && 200 === $code ? 'data:image/x-icon;base64,' . base64_encode($favicon) : ''; } - /** Repsonse code */ + /** Response code */ $ch = curl_init($info_simplified->url); curl_setopt_array($ch, $ch_options); diff --git a/src/classes/wish.php b/src/classes/wish.php index 0369acdf..356d2991 100644 --- a/src/classes/wish.php +++ b/src/classes/wish.php @@ -13,6 +13,8 @@ class Wish /** * Static */ + public const NO_IMAGE = '/src/assets/img/no-image.svg'; + public const STATUS_TEMPORARY = 'temporary'; public const STATUS_TEMPORARY_MINUTES = 30; public const STATUS_UNAVAILABLE = 'unavailable'; @@ -97,7 +99,7 @@ class Wish } if (empty($this->image)) { - $this->image = '/src/assets/img/no-image.svg'; + $this->image = self::NO_IMAGE; } } } diff --git a/src/pages/parts/wish-add.php b/src/pages/parts/wish-add.php index ed41a547..3d420658 100644 --- a/src/pages/parts/wish-add.php +++ b/src/pages/parts/wish-add.php @@ -18,10 +18,10 @@ $scriptPart = '/src/assets/js/parts/wish-add.js';
@@ -30,7 +30,7 @@ $scriptPart = '/src/assets/js/parts/wish-add.js'; @@ -42,10 +42,10 @@ $scriptPart = '/src/assets/js/parts/wish-add.js'; diff --git a/src/pages/wishlists.php b/src/pages/wishlists.php index ff0f5e2a..0f3959c6 100644 --- a/src/pages/wishlists.php +++ b/src/pages/wishlists.php @@ -196,8 +196,8 @@ $page->navigation();
- +