-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
274 lines (229 loc) · 8.68 KB
/
index.php
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<!DOCTYPE html>
<?php
session_start();
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
header("Location: login.php");
exit;
}?>
<html>
<head>
<title>Trade Offers</title>
<?php include 'navbar.php'; ?>
<!-- DataTables CSS -->
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.12.1/css/dataTables.bootstrap5.min.css">
<!-- DataTables JS -->
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.12.1/js/dataTables.bootstrap5.min.js"></script>
<!-- DataTables Bootstrap 5 JS -->
<!-- Bootstrap 5 Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div class=".container-fluid">
<h1>Trade Offers</h1>
<div class="col-md-10 content-area" style="padding-left: 20px>
<div class="search-filter-section">
<div class="search-filter-section">
<form id="searchForm" class="search-form">
<input type="text" class="form-control search-input" placeholder="Search Item" id="searchInput">
<button class="btn btn-primary search-btn" type="submit">Filter</button>
</form>
<div class="currency-select">
<label for="currencyType" class="form-label">Display Prices In:</label>
<select id="currencyType" class="form-select">
<option value="diamonds">Diamonds</option>
<option value="diamond_blocks">Diamond Blocks</option>
<option value="lerokko_coins">Lerokko Coins</option>
</select>
</div>
</div>
</div>
<div class="my-datatable">
<div class="offers-table col-md-10" style="padding-left: 20px >
<div class="table-responsive" id="offersTableContainer">
</div>
</div>
</div>
<div class="map-container">
<img src="sd.png" alt="Trade Map" class="map-image" id="mapImage">
<div id="blinkingDot"></div>
</div>
</div>
</div>
<style>
/* Ensure the main content area does not cover the right 15% of the screen */
.content-area {
max-width: calc(100% - 25%);
float: left; /* Optional: Ensure it aligns to the left */
}
/* Adjust the map container to take up the right 15% of the screen */
.map-container {
width: 25%;
float: right; /* Ensure it aligns to the right */
}
html, body {
margin: 0;
padding: 0;
min-height: 100vh; /* Ensures the body takes at least the full height of the viewport */
width: 100%; /* Ensures the body takes the full width of the viewport */
}
/* Other styles remain the same */
body {
font-family: 'Arial', sans-serif;
}
.navbar {
background-color: #007bff;
/* Add more navbar styling here */
}
.search-form {
display: flex;
gap: 10px;
}
.search-input {
flex-grow: 1;
}
.search-btn {
/* Add more button styling here */
}
.currency-select {
max-width: 300px;
}
.offers-table .table {
margin-top: 20px;
/* Add more table styling here */
}
.map-container {
position: fixed; /* Fix the position relative to the viewport */
bottom: 5%; /* Adjust based on your navbar height and desired spacing */
right: 20px; /* Adjust for spacing from the right edge of the viewport */
width: 15%; /* Set the width to be 20% of the viewport width */
height: auto; /* Adjust height as needed or set to auto */
z-index: 1000; /* Ensure it's above other content */
}
.map-image {
width: 100%;
height: auto; /* Adjust based on your preference */
object-fit: cover; /* Ensures the image covers the container without stretching */
}
#blinkingDot {
position: absolute; /* Absolute positioning within .map-container */
width: 20px;
height: 20px;
background-color: red;
border-radius: 50%;
/* Ensure the dot is visible by setting a high z-index */
z-index: 10;
/* Remove left and top styles if set elsewhere */
animation: blink 1s infinite; /* Adjust duration as needed */
}
@keyframes blink {
0%, 100% { opacity: 1; }
50% { opacity: 0; }
}
.row {
/* Adjust these properties as needed */
display: block !important;
}
</style>
<script>
$(document).ready(function() {
function initializeMap() {
// Map-related JavaScript code here
// For example:
$('#minecraftMap').attr('src', 'sd.png'); // Ensure this path is correct
$('.map-hover').hover(function() {
// The hover functionality for map hover
}, function() {
$('.map-dot').remove(); // Remove the dot when not hovering
});
}
function loadOffersTable(searchTerm) {
var currencyType = $('#currencyType').val();
$("#offersTableContainer").load(`src-a/search_offers.php?search_item=${encodeURIComponent(searchTerm)}¤cy_type=${currencyType}`, function() {
initializeMap(); // Call the function after the content is loaded
$('#internalTable').DataTable({
"responsive": true, // For responsive tables
"autoWidth": false, // To prevent automatic column width adjustments
"searching": false, // Disable search bar
"lengthChange": false, // Disable page length change
});
});
}
// Update the currency and table when the currency type changes
$('#currencyType').change(function() {
loadOffersTable($('#searchInput').val());
});
// Initial load of the offers table without any search term
loadOffersTable('');
// Trigger search in real-time as the user types in the search input
$("#searchInput").on("keyup", function() {
var searchItem = $(this).val();
loadOffersTable(searchItem);
});
// Optional: If you want to keep the form submission functionality as a fallback
$("#searchForm").submit(function(event) {
event.preventDefault(); // Prevent the form from submitting via the browser
var searchItem = $("#searchInput").val(); // Get the search term
loadOffersTable(searchItem);
});
});
function switchMap(location, latitude, longitude) {
// Update the map image source based on the location
console.log(location)
var mapSrc = "sd.png"; // Default map image
if (location === "shopping district") {
mapSrc = "sd.png"; // Shopping district map image
} else if (location === "end") {
mapSrc = "end.png"; // End map image
}
$("#mapImage").attr("src", mapSrc);
// Ensure the blinking dot exists in the map container
if ($("#blinkingDot").length === 0) {
$("#map-container").append('<div id="blinkingDot"></div>');
}
// Calculate dot position based on latitude and longitude
var dotPosition = calculateDotPosition(mapSrc,latitude, longitude);
// Position the blinking dot within the map container
$("#blinkingDot").css({"left": dotPosition.x + "px", "top": dotPosition.y + "px"});
}
function calculateDotPosition(loc,latitude, longitude) {
console.log(loc)
// These constants represent the Minecraft coordinates corresponding to the map corners
var mapTopLeft = {lat: 0, longi: 0};
var mapBottomRight = {lat: 0, longi: 0};
if (loc === "sd.png") {
mapTopLeft = {lat: -1192, longi: 1657};
mapBottomRight = {lat: -1061, longi: 1831};
} else if (loc === "end.png") {
mapTopLeft = {lat: 13, longi: -50};
mapBottomRight = {lat: 99, longi: 44};
}
console.log("input: ",latitude,longitude)
// Calculate the relative position (0 to 1) within the map
var relativeY = (longitude - mapTopLeft.longi) / (mapBottomRight.longi - mapTopLeft.longi);
var relativeX = (latitude - mapTopLeft.lat) / (mapBottomRight.lat - mapTopLeft.lat);
console.log("rel xy: ",relativeX, relativeY);
// Convert to pixel position within the map container
var mapWidth = $("#mapImage").width();
var mapHeight = $("#mapImage").height();
console.log("withhight: ", mapWidth, mapHeight);
var x = relativeX * mapWidth;
var y = relativeY * mapHeight;
console.log("finalcords: ",x, y);
return {x: x, y: y};
}
// Modify the existing document.ready function to include hover event handlers
$(document).ready(function() {
// Existing code...
// Hover event for table rows
$(document).on('mouseenter', 'tr', function() {
var latitude = $(this).find('.map-hover').data('latitude');
var longitude = $(this).find('.map-hover').data('longitude');
var location = $(this).find('.map-hover').data('location'); // Added this line
switchMap(location, latitude, longitude);
console.log(latitude, longitude, location)
});
});
</script>
</body>
</html>