-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
153 lines (131 loc) · 5.32 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home</title>
<link rel="stylesheet" href="css/index.css">
<link rel="stylesheet" href="css/toast.css">
<link rel="icon" type="image/png" href="resource/home.png">
</head>
<body>
<header class="top">
<div class="top-left">
<div class="home-section">
<a class="home-button" href="index.html">
<img src="resource/home.png" alt="Homw" class="home-icon">
</a>
</div>
</div>
<div class="top-middle">
<div class="flex-NameAndSearch">
<div class="shopname">Welcome to Tech Shop</div>
<div class="search-container">
<input id="search_bar" type="search" class="search-input" placeholder="Search...">
</div>
</div>
</div>
<div class="top-right">
<div class="truck-section">
<a class="truck-button" href="php/track-order.php">
<img src="resource/truck.png" alt="tracking order" class="truck-icon">
</a>
</div>
<div class="cart-section">
<a class="cart-button" href="html/cartView.html">
<img src="resource/cart.png" alt="Search" class="cart-icon">
</a>
</div>
<div class="profile-section">
<a class="profile-button" href="php/profile-gateway.php">
<img src="resource/profile.png" alt="Profile" class="profile-icon">
</a>
</div>
</div>
</header>
<!--
<nav>
<a href="#">Home</a>
<a href="html/adminDash.html">Administration</a>
<a href="html/managerDash.html">Manager</a>
<a href="html/signin.html">#</a>
</nav> -->
<!-- Container to display search results -->
<div id="search_results"></div>
<main class="full">
<section class="left-section">
<div class="left-option">
<button class="btn-left-section" onclick="loadAllProducts()">Show All Products</button>
</div>
<div style="text-align: center;">
<h1>Notice</h1>
<div id="notice-container">
<!-- Notices will be dynamically loaded here -->
</div>
</div>
</section>
<section class="content-section">
<!-- Embed the product loader dynamically -->
<iframe id="productLoader" src="html/loadProduct.html" width="100%" height="1500px"
style="border: none;"></iframe>
</section>
</main>
<div id="toast-container"> </div>
</section>
</main>
<div id="toast-container"></div>
<script src="js/searchProduct.js"></script>
<script>
function loadAllProducts() {
const iframe = document.getElementById('productLoader');
iframe.contentWindow.location.reload();
}
// Select the search bar element
const searchBar = document.getElementById('search_bar');
// Add an event listener for the Enter key
searchBar.addEventListener('keydown', function (event) {
if (event.key === 'Enter') { // Check if the Enter key was pressed
const query = searchBar.value.trim(); // Get the input value and trim spaces
console.log("Enter pressed");
if (!query) {
alert("Search field cannot be empty!"); // Show an alert if empty
event.preventDefault(); // Prevent the default action (optional for keydown)
return; // Stop further execution
}
// Redirect to the target page
window.location.href = 'html/show-search-product.html';
}
});
</script>
<script>
// Fetch notices from the server
function fetchNotices() {
const container = document.getElementById('notice-container');
container.innerHTML = '<p>Loading notices...</p>'; // Show loading text
fetch('php/fetch_notice.php')
.then(response => response.json())
.then(data => {
container.innerHTML = ''; // Clear the loading text
if (data.length > 0) {
data.forEach(notice => {
const noticeDiv = document.createElement('div');
noticeDiv.className = 'notice-item';
noticeDiv.innerHTML = `
<p>${notice.notice_content}</p>
`;
container.appendChild(noticeDiv);
});
} else {
container.innerHTML = '<p>No notices found.</p>';
}
})
.catch(error => {
console.error('Error fetching notices:', error);
container.innerHTML = '<p>Failed to load notices.</p>';
});
}
// Load notices on page load
document.addEventListener('DOMContentLoaded', fetchNotices);
</script>
</body>
</html>