From c7c710cd28299423ef11665ff5d996cb0452b739 Mon Sep 17 00:00:00 2001 From: CXM <chenzixin202209@163.com> Date: Thu, 21 Mar 2024 17:20:37 +0000 Subject: [PATCH] Optimisation page --- Admin/admin_page.php | 18 ++++++++++++++---- Admin/brs_manage.php | 6 +++--- Logic/responses.php | 8 -------- Presentation/chatPage.php | 2 +- Presentation/city.php | 2 +- Presentation/interface.php | 19 +++++++++++++++---- Presentation/map.php | 2 +- Presentation/settings.php | 3 --- 8 files changed, 35 insertions(+), 25 deletions(-) delete mode 100644 Logic/responses.php diff --git a/Admin/admin_page.php b/Admin/admin_page.php index 93930df..a72a169 100644 --- a/Admin/admin_page.php +++ b/Admin/admin_page.php @@ -13,8 +13,9 @@ if (!isset($_SESSION['user_type'])) { <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> - <title>管理员管理页面</title> + <title>Admin Page</title> <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet"> + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"> </head> <body class="bg-gray-100"> <div class="flex h-screen"> @@ -29,15 +30,24 @@ if (!isset($_SESSION['user_type'])) { </ul> </div> <!-- 主内容区 --> - <div class="flex-1"> + <div class="flex-1 items-center justify-center"> <iframe id="mainContent" class="w-full h-full overflow-auto" src="about:blank"></iframe> </div> </div> + +<div class="fixed bottom-0 left-0 p-4"> + <a href="http://localhost/zhushou/Presentation/interface.php" id="return-home-btn" class="inline-block bg-black p-4 rounded-md"> + <i class="fas fa-arrow-left text-white text-xl"></i> + </a> +</div> + <script> document.querySelectorAll('a').forEach(link => { link.addEventListener('click', function(event) { - event.preventDefault(); - document.getElementById('mainContent').src = this.getAttribute('data-src'); + if (this.hasAttribute('data-src')) { + event.preventDefault(); + document.getElementById('mainContent').src = this.getAttribute('data-src'); + } }); }); </script> diff --git a/Admin/brs_manage.php b/Admin/brs_manage.php index eb63913..97b32d3 100644 --- a/Admin/brs_manage.php +++ b/Admin/brs_manage.php @@ -248,7 +248,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { addButtons.forEach(button => { button.addEventListener('click', function () { modalContent.innerHTML = ` - <h2 class="text-lg font-bold mb-4">Edit Building Info</h2> + <h2 class="text-lg font-bold mb-4">Add Building</h2> <form id="addBuildingForm" class="space-y-4" action="../Admin/brs_manage.php" method="post"> <input type="hidden" name="formType" value="addBuildingForm"> <div class="flex"> @@ -275,11 +275,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { </div> <div> <label class="block text-sm font-medium text-gray-700" for="latitude">Latitude</label> - <input type="text" name="latitude" id="latitude" class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + <input type="text" name="latitude" id="latitude" class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" required> </div> <div> <label class="block text-sm font-medium text-gray-700" for="longitude">Longitude</label> - <input type="text" name="longitude" id="longitude" class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"> + <input type="text" name="longitude" id="longitude" class="mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" required> </div> <div> <label class="block text-sm font-medium text-gray-700" for="address">Address</label> diff --git a/Logic/responses.php b/Logic/responses.php deleted file mode 100644 index 15aad7e..0000000 --- a/Logic/responses.php +++ /dev/null @@ -1,8 +0,0 @@ -<?php -//\b来指定单词边界,确保只匹配整个单词,而不是字符串中的子字符串 -//i修饰符使得匹配不区分大小写 -return [ - '/\b(体育中心|UWE)\b/i' => 'UWE的体育中心提供了多种体育和健身设施,包括健身房,多功能球场,壁球场,攀岩,并且开设多种课程:瑜伽,篮球,拳击等...', - '/\b(bye|farewell|goodbye)\b/i' => 'Goodbye! Looking forward to our next conversation!', - // 其他预定义的回答 -]; diff --git a/Presentation/chatPage.php b/Presentation/chatPage.php index 9130fec..495fc30 100644 --- a/Presentation/chatPage.php +++ b/Presentation/chatPage.php @@ -27,7 +27,7 @@ </div> </div> -<a href="interface.php" id="return-home-btn"><i class="fas fa-arrow-left"></i></a> +<!--<a href="interface.php" id="return-home-btn"><i class="fas fa-arrow-left"></i></a>--> <script src="../Logic/chat.js"></script> </body> diff --git a/Presentation/city.php b/Presentation/city.php index 52b8aaa..54ba70a 100644 --- a/Presentation/city.php +++ b/Presentation/city.php @@ -106,7 +106,7 @@ $buildings = $stmt->fetchAll(PDO::FETCH_ASSOC); </div> -<a href="interface.php" id="return-home-btn"><i class="fas fa-arrow-left"></i></a> +<!--<a href="interface.php" id="return-home-btn"><i class="fas fa-arrow-left"></i></a>--> <script src="../Logic/city.js"></script> </body> diff --git a/Presentation/interface.php b/Presentation/interface.php index cf90c96..6603b68 100644 --- a/Presentation/interface.php +++ b/Presentation/interface.php @@ -7,6 +7,7 @@ <title>Chat Interface with Aligned Messages</title> <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"> + <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet"> <link rel="stylesheet" href="../css/interface.css"> </head> <body> @@ -19,10 +20,10 @@ </div> <div id="sidebar"> - <a href="map.php" class="sidebar-item" target="contentFrame">Around Frenchay Campus</a> - <a href="city.php" class="sidebar-item" target="contentFrame">Around Bristol</a> - <a href="chatPage.php" class="sidebar-item" target="contentFrame">Campus Voices</a> - <a href="settings.php" class="sidebar-item" target="contentFrame"><i class="fas fa-home"></i> User Profile</a> + <a href="#" class="sidebar-item" target="contentFrame" data-src="map.php">Around Frenchay Campus</a> + <a href="#" class="sidebar-item" target="contentFrame" data-src="city.php">Around Bristol</a> + <a href="#" class="sidebar-item" target="contentFrame" data-src="chatPage.php">Campus Voices</a> + <a href="#" class="sidebar-item" target="contentFrame" data-src="settings.php">User Profile</a> <?php if (isset($userType) && $userType === 'admin') { echo '<a href="../Admin/admin_page.php" class="sidebar-item" target="contentFrame">Admin Page</a>'; @@ -36,5 +37,15 @@ </div> +<script> + document.querySelectorAll('a').forEach(link => { + link.addEventListener('click', function(event) { + if (this.hasAttribute('data-src')) { + event.preventDefault(); + document.getElementById('contentFrame').src = this.getAttribute('data-src'); + } + }); + }); +</script> </body> </html> diff --git a/Presentation/map.php b/Presentation/map.php index cd1836b..531e339 100644 --- a/Presentation/map.php +++ b/Presentation/map.php @@ -37,7 +37,7 @@ $buildings = $stmt->fetchAll(PDO::FETCH_ASSOC); <div id="place-info"></div> -<a href="interface.php" id="return-home-btn"><i class="fas fa-arrow-left"></i></a> +<!--<a href="interface.php" id="return-home-btn"><i class="fas fa-arrow-left"></i></a>--> <script src="../Logic/map.js"></script> </body> diff --git a/Presentation/settings.php b/Presentation/settings.php index f83c8ed..d3785cc 100644 --- a/Presentation/settings.php +++ b/Presentation/settings.php @@ -177,9 +177,6 @@ $user = $stmt->fetch(PDO::FETCH_ASSOC); <!-- </form>再加一个模态框来确定用户是否退出账号--> </div> - -<a href="interface.php" id="return-home-btn"><i class="fas fa-arrow-left"></i></a> - <!--src="js/settings.js"--> <script src="../Logic/settings.js"></script> </body> -- GitLab