Initial commit

This commit is contained in:
ldy
2025-06-06 17:14:52 +08:00
parent 0465a9baef
commit f0aabfb5ac
91 changed files with 4466 additions and 0 deletions

44
indexes/search/iframe.js Normal file
View File

@@ -0,0 +1,44 @@
function details(tag){
var name = tag.id;
makeIFrame('../process/item_details.php?myParam=' + name);
}
function makeIFrame(url) {
var existence = document.getElementById("detail_window");
if (!existence) {
// Create the overlay div and add it to the page
var overlay = document.createElement("div");
overlay.id = "overlay";
document.body.appendChild(overlay);
// Create the iframe and add it to the overlay div
var iframe = document.createElement("iframe");
iframe.setAttribute("src", url);
iframe.id = "detail_window";
overlay.appendChild(iframe);
// Create the close button and add it to the overlay div
var closeButton = document.createElement("button");
closeButton.innerHTML = "x";
closeButton.title = "Close";
closeButton.id = "closebutton";
overlay.appendChild(closeButton);
// Add event listener to close the iframe when the close button is clicked
closeButton.addEventListener("click", closeIFrame);
// Add event listener to close the iframe when clicked outside
setTimeout(function() {
overlay.addEventListener("click", closeIFrame);
}, 100);
}
}
// Function to close the iframe and remove the overlay div from the page
function closeIFrame() {
var overlay = document.getElementById("overlay");
if (overlay) {
overlay.removeEventListener("click", closeIFrame);
overlay.parentNode.removeChild(overlay);
}
}

134
indexes/search/search.css Normal file
View File

@@ -0,0 +1,134 @@
#grid{
position:absolute;
display: flex;
justify-content: center;
flex-wrap: wrap;
margin: none;
border: none;
width: 100%;
left:1.5%;
font-family: Arial, Helvetica, sans-serif;
font-style: rgb(10, 22, 44);
user-select: none;
}
#items{
text-align: center;
background-color: rgba(255, 255, 255, 0.4);
color: black;
font-size: 200%;
border-radius: 12px;
backdrop-filter: blur(4px);
margin: 1%;
font-family: Arial, Helvetica, sans-serif;
font-style: rgb(10, 22, 44);
user-select: none;
width: 80%;
height: 5vw;
transition: 0.3s;
}
img{
border-radius: 12px;
width:80%;
height: 80%;
margin: none;
padding: none;
overflow:hidden;
background-position: center;
background-repeat: no-repeat;
-webkit-background-size:cover;
-moz-background-size:cover;
background-size:cover;
cursor: hand;
transition: 0.5s;
}
#icon{
border-radius: 12%;
width: 6%;
height: 6%;
overflow:hidden;
cursor: hand;
transition: 0.5s;
}
#items:hover{
box-shadow: 0px 0px 10px rgb(106, 104, 104);
}
img:hover{
box-shadow: 0px 0px 10px rgb(106, 104, 104);
}
p,h5:hover{
cursor: hand;
}
input{
text-align: left;
margin-left: 2%;
font-size: 200%;
width: 96%;
background-color: #00000000;
border: none;
border-bottom: 2px solid black;
outline: none;
}
#detail_window{
position: absolute;
text-align: center;
/* 垂直居中 */
top: 0;
bottom: 0;
height: 100%;
/* 水平居中 */
left: 0%;
right: 0%;
width: 100%;
margin: auto;
user-select: none;
background-color: rgba(239, 230, 230, 0.5);
border: 0px;
backdrop-filter: blur(20px);
}
#overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(109, 103, 103, 0.6);
backdrop-filter: blur(4px);
z-index: 100000;
}
body{
height: 100%;
width: 99%;
z-index: 1;
}
/* Hide scrollbar when not needed */
body::-webkit-scrollbar {
width: 0.5em;
}
body::-webkit-scrollbar-thumb {
width: 0.5em;
background: #00000000;
border-radius: 0.25em;
}
#search_window{
width: 100%;
height: 100%;
border: none;
}
#closebutton{
position: absolute;
text-align: center;
transform: scale(1.6);
top: 2%;
height: 3%;
margin-left: 95%;
width: 2.2%;
font-size: 80%;
user-select: none;
border: 0px;
border-radius: 12px;
box-shadow: 0px 0px 16px rgb(142, 142, 142);
}
#closebutton:hover{
background-color: red;
}

32
indexes/search/search.php Normal file
View File

@@ -0,0 +1,32 @@
<html>
<head>
<title>Search</title>
<script src="./iframe.js"></script>
<link rel="stylesheet" href="search.css" type="text/css" />
</head>
<body>
<br><br><br><br><br><br><br><br>
<div style="position: sticky;">
<input type="text" id="search" placeholder="search any fruit you want"
oninput="searchDB()">
</div>
<script>
var existence = document.getElementById("search_window");
if (!existence) {
// Create the iframe and add it to the overlay div
var iframe = document.createElement("iframe");
iframe.setAttribute("src", "./search_item.php");
iframe.id = "search_window";
document.body.appendChild(iframe);
}
function searchDB(){
var text = document.getElementById("search").value;
iframe.setAttribute("src", './search_item.php?text=' + text);
}
</script>
</body>
</html>

View File

@@ -0,0 +1,51 @@
<link rel="stylesheet" href="./search.css" type="text/css" />
<script src="./iframe.js"></script>
<?php
include "../ConnectDB.php";
session_start();
$usertype = mysqli_real_escape_string($conn, $_SESSION['user_type']);
if ($usertype == 'seller') {
$m = "seller_price";
} else {
$m = "buyer_price";
}
if(isset($_GET["text"])) {
$name = $_GET["text"];
if($name == null){
return;
}
$sql_find = "SELECT DISTINCT * FROM inventory WHERE name LIKE '%{$name}%' GROUP BY id";
$res = mysqli_query($conn, $sql_find);
$row = mysqli_num_rows($res);
$goods = mysqli_fetch_assoc($res);
if(!$goods){
echo '<h1 style="text-align: center;">item not found</h1>';
return;
}
echo '<div id="grid">';
for ($i = 0; $i < $row; $i++) {
echo '<table id="items">';
echo '<tr>';
echo '<td width="25%">';
echo '<img src="data:image/jpeg;base64,' . base64_encode($goods['img']) . '" id="' . $goods['name'] . '" onclick="details(this)">';
echo '</td>';
echo '<td width="50%">';
echo '<h4 style="margin: 0%;" id="' . $goods['name'] . '" onclick="details(this)">' . $goods['name'] . '</h4>';
echo '</td>';
echo '<td width="25%">';
echo '<p style="margin: 0%;" >¥' . $goods[$m] . '/kg</p>';
echo '</td>';
echo '</tr>';
echo '</table>';
}
echo '</div>';
}
else{
return;
}
?>