privateuserh commited on
Commit
2d81b68
·
verified ·
1 Parent(s): 3fc3335

Update main.js

Browse files
Files changed (1) hide show
  1. main.js +8 -57
main.js CHANGED
@@ -8,10 +8,7 @@ document.addEventListener('DOMContentLoaded', () => {
8
  let poisData = [];
9
  let arActive = false;
10
  let userSettings = {
11
- showHistorical: true,
12
- showMenus: true,
13
- showNavigation: false,
14
- voiceResponses: true
15
  };
16
 
17
  // --- DOM ELEMENT SELECTORS ---
@@ -32,17 +29,14 @@ document.addEventListener('DOMContentLoaded', () => {
32
  const aerodeckSection = document.getElementById('aerodeckSection');
33
  const aerodeckList = document.getElementById('aerodeckList');
34
 
35
- // --- CORE & UI FUNCTIONS ---
36
-
37
  function toggleARView(showAR) {
38
  arActive = showAR;
39
  if (arActive) {
40
  normalView.classList.add('hidden');
41
  arViewport.classList.remove('hidden');
42
  arToggle.innerHTML = '<i class="fas fa-times mr-1"></i> Exit AR';
43
- if (poisData.length === 0) {
44
- fetchPoisAndCreateAREntities();
45
- }
46
  } else {
47
  arViewport.classList.add('hidden');
48
  normalView.classList.remove('hidden');
@@ -86,7 +80,6 @@ document.addEventListener('DOMContentLoaded', () => {
86
  objectTitle.textContent = 'Loading...';
87
  objectDescription.textContent = '';
88
  aerodeckSection.classList.add('hidden');
89
-
90
  fetch(`${config.backendUrl}/api/pois/${poiId}`)
91
  .then(response => { if (!response.ok) throw new Error('POI not found'); return response.json(); })
92
  .then(data => {
@@ -99,23 +92,14 @@ document.addEventListener('DOMContentLoaded', () => {
99
  const itemElement = document.createElement('div');
100
  itemElement.className = 'flex justify-between items-center p-2 bg-gray-100 rounded';
101
  const statusColor = deck.status === 'Operational' ? 'text-green-500' : 'text-orange-500';
102
- itemElement.innerHTML = `
103
- <div>
104
- <div class="font-medium">${deck.deck_name}</div>
105
- <div class="text-sm text-gray-600">Size: ${deck.size_meters}m | Charging: ${deck.is_charging_available ? 'Yes' : 'No'}</div>
106
- </div>
107
- <div class="font-bold text-sm ${statusColor}">${deck.status}</div>
108
- `;
109
  aerodeckList.appendChild(itemElement);
110
  });
111
  aerodeckSection.classList.remove('hidden');
112
  }
113
  objectModal.classList.remove('hidden');
114
  })
115
- .catch(error => {
116
- console.error("Error fetching POI details:", error);
117
- alert("Could not load details for this location.");
118
- });
119
  }
120
 
121
  function addUserMessage(message) {
@@ -190,10 +174,10 @@ document.addEventListener('DOMContentLoaded', () => {
190
  }
191
 
192
  // --- EVENT LISTENERS ---
193
-
194
  arToggle.addEventListener('click', () => toggleARView(!arActive));
195
- if (document.querySelector('a-scene')) {
196
- document.querySelector('a-scene').addEventListener('click', (event) => {
 
197
  if (event.target.hasAttribute('data-poi-id')) {
198
  const poiId = parseInt(event.target.getAttribute('data-poi-id'), 10);
199
  showObjectInfo(poiId);
@@ -219,37 +203,4 @@ document.addEventListener('DOMContentLoaded', () => {
219
 
220
  // --- INITIALIZATION ---
221
  fetchPoisAndCreateAREntities();
222
- // --- FINAL SYSTEM CHECK ---
223
- const debugLog = document.getElementById('debug-log');
224
- if (debugLog) {
225
- let debugMessage = "--- FINAL SYSTEM CHECK ---\n\n";
226
- let testsPassed = true;
227
-
228
- // Test 1: Check for the settings button itself
229
- if (document.getElementById('settingsBtn')) {
230
- debugMessage += "✅ Test 1: Settings Button HTML (id='settingsBtn') was FOUND.\n";
231
- } else {
232
- debugMessage += "❌ Test 1: Settings Button HTML (id='settingsBtn') was NOT FOUND.\n";
233
- testsPassed = false;
234
- }
235
-
236
- // Test 2: Check for the settings modal window
237
- if (document.getElementById('settingsModal')) {
238
- debugMessage += "✅ Test 2: Settings Modal HTML (id='settingsModal') was FOUND.\n";
239
- } else {
240
- debugMessage += "❌ Test 2: Settings Modal HTML (id='settingsModal') was NOT FOUND.\n";
241
- testsPassed = false;
242
- }
243
-
244
- // Display the final results
245
- debugLog.textContent = debugMessage;
246
-
247
- if(testsPassed) {
248
- debugLog.style.borderColor = 'green';
249
- debugLog.style.color = 'green';
250
- debugLog.style.backgroundColor = '#DFF2BF';
251
- debugLog.textContent += "\nAll elements found. The button should be working.";
252
- }
253
- }
254
- // --- END OF SYSTEM CHECK ---
255
  });
 
8
  let poisData = [];
9
  let arActive = false;
10
  let userSettings = {
11
+ showHistorical: true, showMenus: true, showNavigation: false, voiceResponses: true
 
 
 
12
  };
13
 
14
  // --- DOM ELEMENT SELECTORS ---
 
29
  const aerodeckSection = document.getElementById('aerodeckSection');
30
  const aerodeckList = document.getElementById('aerodeckList');
31
 
32
+ // --- FUNCTIONS ---
 
33
  function toggleARView(showAR) {
34
  arActive = showAR;
35
  if (arActive) {
36
  normalView.classList.add('hidden');
37
  arViewport.classList.remove('hidden');
38
  arToggle.innerHTML = '<i class="fas fa-times mr-1"></i> Exit AR';
39
+ if (poisData.length === 0) fetchPoisAndCreateAREntities();
 
 
40
  } else {
41
  arViewport.classList.add('hidden');
42
  normalView.classList.remove('hidden');
 
80
  objectTitle.textContent = 'Loading...';
81
  objectDescription.textContent = '';
82
  aerodeckSection.classList.add('hidden');
 
83
  fetch(`${config.backendUrl}/api/pois/${poiId}`)
84
  .then(response => { if (!response.ok) throw new Error('POI not found'); return response.json(); })
85
  .then(data => {
 
92
  const itemElement = document.createElement('div');
93
  itemElement.className = 'flex justify-between items-center p-2 bg-gray-100 rounded';
94
  const statusColor = deck.status === 'Operational' ? 'text-green-500' : 'text-orange-500';
95
+ itemElement.innerHTML = `<div><div class="font-medium">${deck.deck_name}</div><div class="text-sm text-gray-600">Size: ${deck.size_meters}m | Charging: ${deck.is_charging_available ? 'Yes' : 'No'}</div></div><div class="font-bold text-sm ${statusColor}">${deck.status}</div>`;
 
 
 
 
 
 
96
  aerodeckList.appendChild(itemElement);
97
  });
98
  aerodeckSection.classList.remove('hidden');
99
  }
100
  objectModal.classList.remove('hidden');
101
  })
102
+ .catch(error => { console.error("Error fetching POI details:", error); alert("Could not load details for this location."); });
 
 
 
103
  }
104
 
105
  function addUserMessage(message) {
 
174
  }
175
 
176
  // --- EVENT LISTENERS ---
 
177
  arToggle.addEventListener('click', () => toggleARView(!arActive));
178
+ const sceneEl = document.querySelector('a-scene');
179
+ if (sceneEl) {
180
+ sceneEl.addEventListener('click', (event) => {
181
  if (event.target.hasAttribute('data-poi-id')) {
182
  const poiId = parseInt(event.target.getAttribute('data-poi-id'), 10);
183
  showObjectInfo(poiId);
 
203
 
204
  // --- INITIALIZATION ---
205
  fetchPoisAndCreateAREntities();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  });