From dd862cf84c09307d56f7b805a6a295f8951b90f2 Mon Sep 17 00:00:00 2001 From: grandeljay Date: Wed, 27 Sep 2023 09:39:45 +0200 Subject: [PATCH] refactor: use real urls instead of pretty --- src/assets/js/home.js | 4 ++-- src/assets/js/html2canvas.js | 2 +- src/assets/js/install.js | 2 +- src/assets/js/parts/wish.js | 10 +++++----- src/assets/js/parts/wishlists.js | 18 +++++++++--------- src/assets/js/wishlist.js | 8 ++++---- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/assets/js/home.js b/src/assets/js/home.js index e2beaf16..e37d26cf 100644 --- a/src/assets/js/home.js +++ b/src/assets/js/home.js @@ -2,7 +2,7 @@ $(function() { /** * Statistics */ - fetch('/api/statistics/all', { + fetch('/index.php?page=api&module=statistics&table=all', { method: 'GET' }) .then(handleFetchError) @@ -56,7 +56,7 @@ $(function() { /** * News */ - fetch('/api/blog', { + fetch('/index.php?page=api&module=blog', { method: 'GET' }) .then(handleFetchError) diff --git a/src/assets/js/html2canvas.js b/src/assets/js/html2canvas.js index 3af996ce..7c5cb9fe 100644 --- a/src/assets/js/html2canvas.js +++ b/src/assets/js/html2canvas.js @@ -20,7 +20,7 @@ window.addEventListener("load", (event) => { data.append('page', wishthis.$_GET.page); /** Save page preview */ - fetch('/api/save-preview', { + fetch('/index.php?page=api&module=save-preview', { method : 'POST', body : data }) diff --git a/src/assets/js/install.js b/src/assets/js/install.js index 2da6ef97..c1dd88fc 100644 --- a/src/assets/js/install.js +++ b/src/assets/js/install.js @@ -9,7 +9,7 @@ $(function() { form.addClass('loading'); - fetch('/api/database-test', { + fetch('/index.php?page=api&module=database-test', { method : 'POST', body : formDatabase }) diff --git a/src/assets/js/parts/wish.js b/src/assets/js/parts/wish.js index 4648f77b..97352a07 100644 --- a/src/assets/js/parts/wish.js +++ b/src/assets/js/parts/wish.js @@ -93,7 +93,7 @@ $(function () { } ); - fetch('/?' + get_wish, { method: 'GET' }) + fetch('/index.php?' + get_wish, { method: 'GET' }) .then(handleFetchError) .then(handleFetchResponse) .then(function(response) { @@ -147,7 +147,7 @@ $(function () { $(this).addClass('disabled loading'); - fetch('/api/wishes', mark_as_fulfilled) + fetch('/index.php?page=api&module=wishes', mark_as_fulfilled) .then(handleFetchError) .then(handleFetchResponse) .then(function(response) { @@ -177,7 +177,7 @@ $(function () { $(this).addClass('disabled loading'); - fetch('/api/wishes', mark_as_fulfilled) + fetch('/index.php?page=api&module=wishes', mark_as_fulfilled) .then(handleFetchError) .then(handleFetchResponse) .then(function(response) { @@ -277,7 +277,7 @@ $(function () { ) ); - fetch('/api/wishes', { + fetch('/index.php?page=api&module=wishes', { 'method' : 'POST', 'body' : wish_data, }) @@ -335,7 +335,7 @@ $(function () { 'wish_id' : wish_local.id }); - fetch('/api/wishes', { + fetch('/index.php?page=api&module=wishes', { 'method' : 'DELETE', 'body' : wish_delete, }) diff --git a/src/assets/js/parts/wishlists.js b/src/assets/js/parts/wishlists.js index 64211f79..53f78c8c 100644 --- a/src/assets/js/parts/wishlists.js +++ b/src/assets/js/parts/wishlists.js @@ -53,7 +53,7 @@ $(function () { if (wishlist_id) { /** Get wishlist */ - fetch('/api/wishlists/' + wishlist_id, { method: 'GET' }) + fetch('/index.php?page=api&module=wishlists&id=' + wishlist_id, { method: 'GET' }) .then(handleFetchError) .then(handleFetchResponse) .then(function(response) { @@ -110,7 +110,7 @@ $(function () { 'wish_priority' : -1, } ); - fetch('/?' + get_wishes, { method: 'GET' }) + fetch('/index.php?' + get_wishes, { method: 'GET' }) .then(handleFetchError) .then(handleFetchResponse) .then(function(response) { @@ -201,7 +201,7 @@ $(function () { var formData = new URLSearchParams(new FormData(formRename[0])); formData.append('wishlist_id', wishthis.$_GET.id); - fetch('/api/wishlists', { + fetch('/index.php?page=api&module=wishlists', { method : 'PUT', body : formData, }) @@ -283,7 +283,7 @@ $(function () { 'wishlist_id' : wishlist_id, } ); - fetch('/api/wishlists', { + fetch('/index.php?page=api&module=wishlists', { 'method' : 'DELETE', 'body' : delete_wishlist, }) @@ -390,7 +390,7 @@ $(function () { var formData = new URLSearchParams(new FormData(formWishlistCreate[0])); - fetch('/api/wishlists', { + fetch('/index.php?page=api&module=wishlists', { method : 'POST', body : formData }) @@ -454,7 +454,7 @@ $(function () { } ); - fetch('/?' + params_url, { + fetch('/index.php?' + params_url, { method: 'GET' }) .then(handleFetchError) @@ -491,7 +491,7 @@ $(function () { } ); - fetch('/?page=api&module=wishes', { + fetch('/index.php?page=api&module=wishes', { method : 'PUT', body : formData }) @@ -527,7 +527,7 @@ $(function () { var formData = new URLSearchParams(new FormData(formAddOrEdit[0])); formData.append('wishlist_id', wishthis.$_GET.id); - fetch('/api/wishes', { + fetch('/index.php?page=api&module=wishes', { 'method' : 'POST', 'body' : formData, }) @@ -555,7 +555,7 @@ $(function () { * Update URL */ function updateURL() { - fetch('/api/url/' + window.btoa('/?' + urlParams.toString()), { method: 'GET' }) + fetch('/index.php?page=api&module=url&url=' + window.btoa('/?' + urlParams.toString()), { method: 'GET' }) .then(handleFetchError) .then(handleFetchResponse) .then(function(response) { diff --git a/src/assets/js/wishlist.js b/src/assets/js/wishlist.js index fe0264c0..c1415599 100644 --- a/src/assets/js/wishlist.js +++ b/src/assets/js/wishlist.js @@ -38,7 +38,7 @@ $(function() { if (!wishlist && wishthis.$_GET.hash) { var wishlistId = $('.wishlist-cards[data-wishlist]').attr('data-wishlist'); - fetch('/api/wishlists/' + wishlistId, { method: 'GET' }) + fetch('/index.php?page=api&module=wishlists&id=' + wishlistId, { method: 'GET' }) .then(handleFetchError) .then(handleFetchResponse) .then(function(response) { @@ -104,7 +104,7 @@ $(function() { } ); - fetch('/api/wishlists-saved', { + fetch('/index.php?page=api&module=wishlists-saved', { method : 'POST', body : formData }) @@ -127,7 +127,7 @@ $(function() { }); /** Determine if list is saved */ - fetch('/api/wishlists-saved', { + fetch('/index.php?page=api&module=wishlists-saved', { method : 'GET', }) .then(handleFetchError) @@ -175,7 +175,7 @@ $(function() { buttonRequest.addClass('disabled loading'); - fetch('/api/wishlists', { + fetch('/index.php?page=api&module=wishlists', { method : 'POST', body : formData })