diff --git a/scripts/client/pages/detailProduct/index.php b/scripts/client/pages/detailProduct/index.php index e997507ede05d28560826124553ad3e99bcd62d9..a985e1c8332a3d56100760da88a6498fe6c29cf6 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 b9009470761d25f7738c72ec0663b6d313f814d1..9ee4733ff7ec0088f6ea4a91095b52cb33dba1ea 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 603a4c5e1cc5c95e56418d5da7bbdb3df5bd50eb..6f3a1b667dc916769dfccab91160e1f469630494 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 368771fa5ffa09958f18d6d8ae3ae282aee9f8b9..9128a3bb2fc0ae5906a2781548cc4de8393055cf 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 f2a50a5147adc73902b839113cd41a8ee94d5e2e..8a2499771bbe18fd3d96c9ef4765171bc7f861a5 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);