From 38a58ee1bdbf09c47dbdf553967d9a7f1077fc4e Mon Sep 17 00:00:00 2001 From: JdM Date: Thu, 26 Sep 2024 17:57:26 +0200 Subject: [PATCH] Refactor script imports in index.php and admin.js --- admin/index.php | 2 +- api/recive_all.php | 2 +- scripts/admin.js | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/admin/index.php b/admin/index.php index 103e276..c941729 100644 --- a/admin/index.php +++ b/admin/index.php @@ -8,6 +8,6 @@
- + \ No newline at end of file diff --git a/api/recive_all.php b/api/recive_all.php index bc0ac80..aeb01a8 100644 --- a/api/recive_all.php +++ b/api/recive_all.php @@ -4,6 +4,6 @@ $mediaDir = __DIR__ . '/../medias/'; $files = array_diff(scandir($mediaDir), ['.', '..']); - +shuffle($files); echo json_encode(['success' => true, 'files' => array_values($files)]); ?> diff --git a/scripts/admin.js b/scripts/admin.js index f9cd6e2..a13a067 100644 --- a/scripts/admin.js +++ b/scripts/admin.js @@ -3,6 +3,7 @@ document.addEventListener('DOMContentLoaded', () => { const basePath = ".." const apiPath = `${basePath}/api/recive_all.php`; const mediaPath = `${basePath}/medias/`; + function fetchMedias() { fetch(apiPath) @@ -28,5 +29,6 @@ document.addEventListener('DOMContentLoaded', () => { .catch(error => console.error('Stupid error :', error)); } + fetchMedias(); });