From 3ebe5ca02b0a56d8f4ff2fbd5371ec97fdb4ffe4 Mon Sep 17 00:00:00 2001 From: Michael Leon Putra Widhi <leonmichael463@gmail.com> Date: Sun, 8 Oct 2023 18:07:22 +0700 Subject: [PATCH] fix : bugs on video display and topup --- scripts/client/pages/detailProduct/index.php | 3 ++- .../client/public/css/pages/detailProduct.css | 2 +- scripts/client/public/js/admin-top-up.js | 18 +++++++++--------- scripts/client/public/js/detailProduct.js | 18 +++++++++++++++--- scripts/client/public/js/settings.js | 2 +- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/scripts/client/pages/detailProduct/index.php b/scripts/client/pages/detailProduct/index.php index e997507..a985e1c 100644 --- a/scripts/client/pages/detailProduct/index.php +++ b/scripts/client/pages/detailProduct/index.php @@ -4,7 +4,8 @@ <section id="detailProduct"> <div class="detailContainer"> <div class="detailImage"> - <img id="productImage"></img> + <img id="imageTag"></img> + <video id="videoTag" autoplay loop muted style="display: none;"></video> </div> <div class="productInfo"> <div id="productName"></div> diff --git a/scripts/client/public/css/pages/detailProduct.css b/scripts/client/public/css/pages/detailProduct.css index b900947..9ee4733 100644 --- a/scripts/client/public/css/pages/detailProduct.css +++ b/scripts/client/public/css/pages/detailProduct.css @@ -59,7 +59,7 @@ background-color: black; } -#productImage { +#imageTag, #videoTag { border-radius: 1.8rem; width: 100%; height: auto; diff --git a/scripts/client/public/js/admin-top-up.js b/scripts/client/public/js/admin-top-up.js index 603a4c5..6f3a1b6 100644 --- a/scripts/client/public/js/admin-top-up.js +++ b/scripts/client/public/js/admin-top-up.js @@ -65,7 +65,7 @@ let getTopUpsByPage = async (page) => { window.location.href = errorData.location; } } - } + }; xhr.open('GET', `/api/TopUpController/getTopUpsByPage/${page}`, true); xhr.setRequestHeader('Accept', 'application/json'); @@ -100,7 +100,7 @@ let setPagination = async (page) => { } } } - } + }; xhr.open('GET', `/api/TopUpController/getAllTopUps`, true); xhr.setRequestHeader('Accept', 'application/json'); @@ -131,7 +131,7 @@ let handleApproveClick = async (id) => { window.location.href = errorData.location; } } - } + }; xhr.open('PUT', `/api/TopUpController/approveTopUp/${id}`, true); xhr.setRequestHeader('Accept', 'application/json'); @@ -157,7 +157,7 @@ let handleRejectClick = async (id) => { window.location.href = errorData.location; } } - } + }; xhr.open('PUT', `/api/TopUpController/rejectTopUp/${id}`, true); xhr.setRequestHeader('Accept', 'application/json'); @@ -176,18 +176,18 @@ let deleteTopUp = async (id) => { xhr.onreadystatechange = function () { if (this.readyState == 4) { if (this.status == 200) { - let res = JSON.parse(this.responseText); + let res = JSON.parse(this.responseText); if (res["status"]) { window.location.href = "/pages/admin-top-up"; } else { alert("Failed to delete top up!"); } + } else { + var errorData = JSON.parse(xhr.responseText); + alert(errorData.message); + window.location.href = errorData.location; } - } else { - var errorData = JSON.parse(xhr.responseText); - alert(errorData.message); - window.location.href = errorData.location; } }; diff --git a/scripts/client/public/js/detailProduct.js b/scripts/client/public/js/detailProduct.js index 368771f..9128a3b 100644 --- a/scripts/client/public/js/detailProduct.js +++ b/scripts/client/public/js/detailProduct.js @@ -33,9 +33,21 @@ function getProduct() { } function appendData(productDetail) { - var div1 = document.getElementById("productImage"); - div1.src = "/../public/assets/images/" + productDetail.image; - div1.style.objectFit = "cover"; + var imageTag = document.getElementById("imageTag"); + var videoTag = document.getElementById("videoTag"); + + if (productDetail.image.includes('.mp4')) { + videoTag.src = "/../public/assets/videos/" + productDetail.image; + videoTag.style.display = "block"; + imageTag.style.display = "none"; + } else { + imageTag.src = "/../public/assets/images/" + productDetail.image; + imageTag.style.display = "block"; + videoTag.style.display = "none"; + } + + imageTag.style.objectFit = "cover"; + videoTag.style.objectFit = "cover"; var div2 = document.getElementById("productName"); div2.innerHTML += productDetail.product_name; diff --git a/scripts/client/public/js/settings.js b/scripts/client/public/js/settings.js index f2a50a5..8a24997 100644 --- a/scripts/client/public/js/settings.js +++ b/scripts/client/public/js/settings.js @@ -50,7 +50,7 @@ document.getElementById('settings-form').addEventListener('submit', function(eve if (xhr.status == 200) { var responseText = xhr.responseText; if (responseText.trim() === '') { - window.location.href = 'http://localhost:8000/client/pages/login'; + window.location.href = 'http://localhost:8000/pages/home'; } } else { var errorData = JSON.parse(xhr.responseText); -- GitLab