Files
TenerifeProp/public/js/navigation.js
TenerifeProp Dev 503eb8a62f feat: implement property page navigation and security fixes
- Fix XSS vulnerabilities with escapeHtml() utility
- Fix SQL injection in admin endpoints with column whitelisting
- Add CSRF protection middleware
- Remove hardcoded password backdoor
- Implement property navigation functions
- Add test coverage

Closes #9
2026-04-05 01:34:48 +01:00

67 lines
1.9 KiB
JavaScript

// Navigation functions for property pages
// Function to navigate to property detail page
function navigateToPropertyDetail(slug) {
// This function should exist and work
window.location.href = `/property/${slug}`;
}
// Function to get property by slug (already partially implemented in API)
async function getPropertyBySlug(slug, lang = 'es') {
// This function should exist and work
try {
const response = await fetch(`/api/properties/${slug}?lang=${lang}`);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const result = await response.json();
return result;
} catch (error) {
throw new Error(`Failed to fetch property: ${error.message}`);
}
}
// Function to switch language
function switchLanguage(lang) {
// This function should exist and work
localStorage.setItem('lang', lang);
location.reload();
}
// Function to go back with filters preservation
function goBackWithFilters() {
// This function should exist and work
// Restore filters from session storage and go back
const filterData = sessionStorage.getItem('propertyFilters');
if (filterData) {
try {
const filters = JSON.parse(filterData);
// Navigate back
window.history.back();
return true;
} catch (e) {
console.warn('Failed to restore filters:', e);
}
}
// If no filters to restore, just go back
window.history.back();
return true;
}
// Function to toggle mobile menu
function toggleMobileMenu() {
// This function should exist and work
const navbarCollapse = document.getElementById('navbarNav');
if (navbarCollapse) {
navbarCollapse.classList.toggle('show');
return true;
}
return false;
}
// Export functions for global access
window.navigateToPropertyDetail = navigateToPropertyDetail;
window.getPropertyBySlug = getPropertyBySlug;
window.switchLanguage = switchLanguage;
window.goBackWithFilters = goBackWithFilters;
window.toggleMobileMenu = toggleMobileMenu;