Find det Perfekte Svenske Savværk

Over 100 svenske savværker - intelligent matchning af dine træbehov

100+
Svenske Savværker
25M m³
Årlig Kapacitet
100%
Certificerede
24-48t
Hurtig Levering

Filtrer Savværker

Tilføj Nyt Savværk

Mine Favorit Savværker

Du har ingen favoritter endnu. Klik på hjertet på et savværk for at tilføje det.

Min Profil

Profil funktionalitet kommer snart...

// Show selected page document.getElementById(pageName + '-page').classList.add('active'); // Update nav links document.querySelectorAll('.nav-links a').forEach(link => { link.classList.remove('active'); }); event.target.classList.add('active'); currentPage = pageName; // Initialize search results if on search page if (pageName === 'search' && document.getElementById('results-container').innerHTML === '') { searchSawmills(); } // Show favorites if on favorites page if (pageName === 'favorites') { showFavorites(); } } // Calculate match score function calculateMatchScore(sawmill, filters) { let score = 100; if (filters.woodType && !sawmill.woodTypes.includes(filters.woodType)) { score -= 30; } if (filters.quality && !sawmill.qualities.includes(filters.quality)) { score -= 25; } if (filters.certification) { if (filters.certification === 'both' && sawmill.certifications.length < 2) { score -= 20; } else if (filters.certification !== 'both' && !sawmill.certifications.includes(filters.certification)) { score -= 20; } } if (filters.company && sawmill.company !== filters.company) { score -= 35; } if (filters.region && sawmill.region !== filters.region) { score -= 15; } if (filters.volume && sawmill.capacity < parseInt(filters.volume)) { score -= 20; } return Math.max(0, score); } // Get static map image URL function getStaticMapUrl(lat, lng) { // Using placeholder map service - replace with actual Google Maps Static API when you have key return `https://via.placeholder.com/350x150/1e293b/cbd5e1?text=Map+${lat.toFixed(2)},${lng.toFixed(2)}`; } // Toggle favorite function toggleFavorite(id, event) { event.stopPropagation(); const index = favorites.indexOf(id); if (index > -1) { favorites.splice(index, 1); } else { favorites.push(id); } localStorage.setItem('favorites', JSON.stringify(favorites)); // Update UI if (currentPage === 'search') { searchSawmills(); } else if (currentPage === 'favorites') { showFavorites(); } } // Render sawmill card function renderSawmillCard(sawmill) { const certTags = sawmill.certifications.map(cert => `${cert}`).join(''); const specTags = sawmill.specializations.map(spec => `${spec}`).join(''); const isFavorite = favorites.includes(sawmill.id); return `
${sawmill.name}
${sawmill.company}
${sawmill.matchScore}% match
${isFavorite ? '❤️' : '🤍'}
Map
📍 ${sawmill.location.city}
Kapacitet: ${sawmill.capacity.toLocaleString('da-DK')} m³/år
Placering: ${sawmill.location.city}
Leveringstid: ${getDeliveryTimeText(sawmill.deliveryTime)}
Certificeringer:
${certTags}
`; } // Get delivery time text function getDeliveryTimeText(deliveryTime) { const texts = { 'immediate': 'Øjeblikkelig', '1-week': '1 uge', '2-weeks': '2 uger', '1-month': '1 måned' }; return texts[deliveryTime] || deliveryTime; } // Search sawmills function searchSawmills() { const filters = { woodType: document.getElementById('wood-type').value, quality: document.getElementById('quality').value, volume: document.getElementById('volume').value, company: document.getElementById('company').value, certification: document.getElementById('certification').value, region: document.getElementById('region').value }; // Calculate match scores const results = sawmills.map(sawmill => ({ ...sawmill, matchScore: calculateMatchScore(sawmill, filters) })).sort((a, b) => b.matchScore - a.matchScore); // Render results const container = document.getElementById('results-container'); container.innerHTML = results .filter(s => s.matchScore > 0) .map(renderSawmillCard) .join(''); if (results.filter(s => s.matchScore > 0).length === 0) { container.innerHTML = '

Ingen savværker matcher dine kriterier. Prøv at justere dine filtre.

'; } // Update map markers updateMapMarkers(results.filter(s => s.matchScore > 0)); } // Update map markers function updateMapMarkers(results) { // Clear existing markers markers.forEach(marker => map.removeLayer(marker)); markers = []; // Add new markers results.forEach(sawmill => { const marker = L.marker([sawmill.location.lat, sawmill.location.lng]) .addTo(map) .bindPopup(` ${sawmill.name}
${sawmill.company}
${sawmill.location.city}
Match: ${sawmill.matchScore}% `); markers.push(marker); }); } // Reset filters function resetFilters() { document.getElementById('wood-type').value = ''; document.getElementById('quality').value = ''; document.getElementById('volume').value = ''; document.getElementById('company').value = ''; document.getElementById('certification').value = ''; document.getElementById('region').value = ''; searchSawmills(); } // Show sawmill details function showSawmillDetails(id) { const sawmill = sawmills.find(s => s.id === id); const modal = document.getElementById('sawmill-modal'); const modalBody = document.getElementById('modal-body'); modalBody.innerHTML = `

${sawmill.name}

${sawmill.company}

Map

Kontaktinformation

Telefon: ${sawmill.contact.phone}
Email: ${sawmill.contact.email}
${sawmill.contact.website ? `
Hjemmeside: ${sawmill.contact.website}
` : ''}

Produktion

Kapacitet: ${sawmill.capacity.toLocaleString('da-DK')} m³/år
Træsorter: ${sawmill.woodTypes.map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(', ')}
Kvaliteter: ${sawmill.qualities.join(', ')}

Specialiseringer

${sawmill.specializations.map(spec => `${spec}`).join('')}
`; modal.style.display = 'flex'; } // Close modal function closeModal() { document.getElementById('sawmill-modal').style.display = 'none'; } // Show favorites function showFavorites() { const favoriteSawmills = sawmills.filter(s => favorites.includes(s.id)); const container = document.getElementById('favorites-container'); if (favoriteSawmills.length === 0) { container.innerHTML = '

Du har ingen favoritter endnu. Klik på hjertet på et savværk for at tilføje det.

'; } else { container.innerHTML = favoriteSawmills.map(s => ({ ...s, matchScore: 100 })).map(renderSawmillCard).join(''); } } // View toggles function showListView() { document.getElementById('results-container').style.display = 'grid'; document.getElementById('map').style.display = 'none'; document.querySelectorAll('.toggle-btn')[0].classList.add('active'); document.querySelectorAll('.toggle-btn')[1].classList.remove('active'); } function showMapView() { document.getElementById('results-container').style.display = 'none'; document.getElementById('map').style.display = 'block'; document.querySelectorAll('.toggle-btn')[0].classList.remove('active'); document.querySelectorAll('.toggle-btn')[1].classList.add('active'); if (!map) { initMap(); } setTimeout(() => { map.invalidateSize(); }, 100); } // Add sawmill form handling document.getElementById('add-sawmill-form').addEventListener('submit', function(e) { e.preventDefault(); // Get form values const newSawmill = { id: sawmills.length + 1, name: document.getElementById('sawmill-name').value, company: document.getElementById('sawmill-company').value, location: { lat: parseFloat(document.getElementById('sawmill-lat').value) || 59.0, lng: parseFloat(document.getElementById('sawmill-lng').value) || 15.0, city: document.getElementById('sawmill-city').value }, region: document.getElementById('sawmill-region').value, capacity: parseInt(document.getElementById('sawmill-capacity').value) || 100000, woodTypes: [], qualities: [], certifications: [], deliveryTime: document.getElementById('sawmill-delivery').value, specializations: document.getElementById('sawmill-specializations').value.split(',').map(s => s.trim()).filter(s => s), contact: { phone: document.getElementById('sawmill-phone').value, email: document.getElementById('sawmill-email').value, website: document.getElementById('sawmill-website').value } }; // Get wood types ['gran', 'fyr', 'contorta', 'lövträ'].forEach(type => { if (document.getElementById('wood-' + type).checked) { newSawmill.woodTypes.push(type); } }); // Get qualities ['i', 'ii', 'iii', 'iv', 'g41', 'g42'].forEach(qual => { if (document.getElementById('qual-' + qual).checked) { newSawmill.qualities.push(qual.toUpperCase().replace('41', '4-1').replace('42', '4-2')); } }); // Get certifications ['fsc', 'pefc'].forEach(cert => { if (document.getElementById('cert-' + cert).checked) { newSawmill.certifications.push(cert.toUpperCase()); } }); // Add to sawmills array sawmills.push(newSawmill); // Show success message const successDiv = document.createElement('div'); successDiv.className = 'success-message'; successDiv.style.display = 'block'; successDiv.textContent = 'Savværk tilføjet successfully! Du kan nu finde det i søgningen.'; document.getElementById('add-sawmill-form').parentNode.insertBefore(successDiv, document.getElementById('add-sawmill-form')); // Reset form document.getElementById('add-sawmill-form').reset(); // Remove success message after 5 seconds setTimeout(() => { successDiv.remove(); }, 5000); }); // Initialize on page load document.addEventListener('DOMContentLoaded', function() { // Show initial search results searchSawmills(); // Click outside modal to close window.onclick = function(event) { const modal = document.getElementById('sawmill-modal'); if (event.target == modal) { modal.style.display = 'none'; } } });