Download script.js from zytensor/dreamkey-estates-fixer-upper-edition: direct link, hf CLI and curl.
- Browser
- Download file 9.93 kB
-
https://huggingface.co/spaces/zytensor/dreamkey-estates-fixer-upper-edition/resolve/main/script.js
- Command line
-
hf download hf://spaces/zytensor/dreamkey-estates-fixer-upper-edition/script.js
-
curl -L -o script.js https://huggingface.co/spaces/zytensor/dreamkey-estates-fixer-upper-edition/resolve/main/script.js
9.93 kB
| // Global Functions for DreamKey Estates | |
| // Property Data (Mock API) | |
| const properties = [ | |
| { | |
| id: 1, | |
| title: "Modern Lakeside Villa", | |
| location: "234 Lakeview Dr, Seattle, WA", | |
| price: 875000, | |
| bedrooms: 4, | |
| bathrooms: 3, | |
| sqft: 3200, | |
| image: "http://static.photos/real-estate/640x360/101", | |
| virtualTour: true, | |
| featured: true | |
| }, | |
| { | |
| id: 2, | |
| title: "Downtown Penthouse", | |
| location: "501 Skyline Ave, New York, NY", | |
| price: 2450000, | |
| bedrooms: 3, | |
| bathrooms: 3.5, | |
| sqft: 2800, | |
| image: "http://static.photos/real-estate/640x360/102", | |
| virtualTour: true, | |
| featured: true | |
| }, | |
| { | |
| id: 3, | |
| title: "Suburban Family Home", | |
| location: "789 Maple St, Austin, TX", | |
| price: 625000, | |
| bedrooms: 5, | |
| bathrooms: 4, | |
| sqft: 3800, | |
| image: "http://static.photos/real-estate/640x360/103", | |
| virtualTour: false, | |
| featured: true | |
| }, | |
| { | |
| id: 4, | |
| title: "Mountain Retreat Cabin", | |
| location: "123 Alpine Way, Denver, CO", | |
| price: 425000, | |
| bedrooms: 3, | |
| bathrooms: 2, | |
| sqft: 1800, | |
| image: "http://static.photos/real-estate/640x360/104", | |
| virtualTour: true, | |
| featured: true | |
| }, | |
| { | |
| id: 5, | |
| title: "Urban Loft Studio", | |
| location: "456 Art District, Chicago, IL", | |
| price: 350000, | |
| bedrooms: 1, | |
| bathrooms: 1, | |
| sqft: 1200, | |
| image: "http://static.photos/real-estate/640x360/105", | |
| virtualTour: false, | |
| featured: true | |
| }, | |
| { | |
| id: 6, | |
| title: "Beachfront Condo", | |
| location: "789 Ocean Blvd, Miami, FL", | |
| price: 950000, | |
| bedrooms: 2, | |
| bathrooms: 2, | |
| sqft: 1600, | |
| image: "http://static.photos/real-estate/640x360/106", | |
| virtualTour: true, | |
| featured: true | |
| } | |
| ]; | |
| // Agent Data | |
| const agents = [ | |
| { | |
| id: 1, | |
| name: "Sarah Chen", | |
| title: "Senior Real Estate Specialist", | |
| experience: "12 years", | |
| specialties: ["Luxury Homes", "Investment Properties"], | |
| image: "http://static.photos/people/200x200/201", | |
| phone: "(555) 123-4567", | |
| email: "sarah@dreamkeyestates.com" | |
| }, | |
| { | |
| id: 2, | |
| name: "Marcus Johnson", | |
| title: "Commercial Property Expert", | |
| experience: "8 years", | |
| specialties: ["Commercial", "Development"], | |
| image: "http://static.photos/people/200x200/202", | |
| phone: "(555) 234-5678", | |
| email: "marcus@dreamkeyestates.com" | |
| }, | |
| { | |
| id: 3, | |
| name: "Elena Rodriguez", | |
| title: "First-Time Homebuyer Advisor", | |
| experience: "6 years", | |
| specialties: ["First-Time Buyers", "Condos"], | |
| image: "http://static.photos/people/200x200/203", | |
| phone: "(555) 345-6789", | |
| email: "elena@dreamkeyestates.com" | |
| } | |
| ]; | |
| // Neighborhood Data | |
| const neighborhoods = [ | |
| { | |
| id: 1, | |
| name: "Westside Heights", | |
| city: "Los Angeles, CA", | |
| rating: 4.8, | |
| highlights: ["Top Schools", "Parks", "Low Crime"], | |
| image: "http://static.photos/cityscape/320x240/301" | |
| }, | |
| { | |
| id: 2, | |
| name: "Riverfront District", | |
| city: "Portland, OR", | |
| rating: 4.6, | |
| highlights: ["Walkable", "Art Scene", "Restaurants"], | |
| image: "http://static.photos/cityscape/320x240/302" | |
| }, | |
| { | |
| id: 3, | |
| name: "Historic Old Town", | |
| city: "Charleston, SC", | |
| rating: 4.9, | |
| highlights: ["Historic", "Community", "Waterfront"], | |
| image: "http://static.photos/cityscape/320x240/303" | |
| } | |
| ]; | |
| // Load Featured Listings | |
| function loadFeaturedListings() { | |
| const container = document.getElementById('featuredListings'); | |
| if (!container) return; | |
| container.innerHTML = ''; | |
| const featured = properties.filter(p => p.featured).slice(0, 3); | |
| featured.forEach(property => { | |
| const card = document.createElement('property-card'); | |
| card.setAttribute('data-property', JSON.stringify(property)); | |
| card.classList.add('fade-in'); | |
| container.appendChild(card); | |
| }); | |
| } | |
| // Load Agent Profiles | |
| function loadAgentProfiles() { | |
| const container = document.getElementById('agentProfiles'); | |
| if (!container) return; | |
| container.innerHTML = ''; | |
| agents.forEach(agent => { | |
| const card = document.createElement('agent-card'); | |
| card.setAttribute('data-agent', JSON.stringify(agent)); | |
| card.classList.add('fade-in'); | |
| container.appendChild(card); | |
| }); | |
| } | |
| // Load Neighborhood Guides | |
| function loadNeighborhoodGuides() { | |
| const container = document.getElementById('neighborhoodGuides'); | |
| if (!container) return; | |
| container.innerHTML = ''; | |
| neighborhoods.forEach(neighborhood => { | |
| const card = document.createElement('neighborhood-card'); | |
| card.setAttribute('data-neighborhood', JSON.stringify(neighborhood)); | |
| card.classList.add('fade-in'); | |
| container.appendChild(card); | |
| }); | |
| } | |
| // Initialize Mortgage Calculator | |
| function initMortgageCalculator() { | |
| const priceSlider = document.getElementById('priceSlider'); | |
| const downSlider = document.getElementById('downSlider'); | |
| const rateSlider = document.getElementById('rateSlider'); | |
| const termButtons = document.querySelectorAll('.term-btn'); | |
| const priceValue = document.getElementById('priceValue'); | |
| const downValue = document.getElementById('downValue'); | |
| const rateValue = document.getElementById('rateValue'); | |
| const monthlyPayment = document.getElementById('monthlyPayment'); | |
| const totalLoan = document.getElementById('totalLoan'); | |
| const totalDown = document.getElementById('totalDown'); | |
| if (!priceSlider) return; | |
| let termYears = 15; | |
| // Update display values | |
| function updateDisplay() { | |
| const price = parseInt(priceSlider.value); | |
| const downPercent = parseInt(downSlider.value); | |
| const rate = parseFloat(rateSlider.value); | |
| const downAmount = price * (downPercent / 100); | |
| const loanAmount = price - downAmount; | |
| const monthlyRate = rate / 100 / 12; | |
| const payments = termYears * 12; | |
| // Calculate monthly payment | |
| let monthly; | |
| if (monthlyRate === 0) { | |
| monthly = loanAmount / payments; | |
| } else { | |
| monthly = loanAmount * monthlyRate * Math.pow(1 + monthlyRate, payments) / | |
| (Math.pow(1 + monthlyRate, payments) - 1); | |
| } | |
| // Update display | |
| priceValue.textContent = `$${price.toLocaleString()}`; | |
| downValue.textContent = `${downPercent}%`; | |
| rateValue.textContent = `${rate}%`; | |
| monthlyPayment.textContent = `$${monthly.toFixed(0)}`; | |
| totalLoan.textContent = `$${loanAmount.toLocaleString()}`; | |
| totalDown.textContent = `$${downAmount.toLocaleString()}`; | |
| } | |
| // Event Listeners | |
| priceSlider.addEventListener('input', updateDisplay); | |
| downSlider.addEventListener('input', updateDisplay); | |
| rateSlider.addEventListener('input', updateDisplay); | |
| termButtons.forEach(button => { | |
| button.addEventListener('click', function() { | |
| termButtons.forEach(btn => btn.classList.remove('active')); | |
| this.classList.add('active'); | |
| termYears = parseInt(this.textContent); | |
| updateDisplay(); | |
| }); | |
| }); | |
| // Initial calculation | |
| updateDisplay(); | |
| } | |
| // Initialize Contact Form | |
| function initContactForm() { | |
| const form = document.getElementById('contactForm'); | |
| if (!form) return; | |
| form.addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| // Get form data | |
| const formData = new FormData(form); | |
| const data = Object.fromEntries(formData); | |
| // In a real app, you would send this to a server | |
| console.log('Form submitted:', data); | |
| // Show success message | |
| alert('Thank you for your message! We\'ll get back to you within 24 hours.'); | |
| form.reset(); | |
| // Reset consent checkbox | |
| const consent = document.getElementById('consent'); | |
| if (consent) consent.checked = false; | |
| }); | |
| } | |
| // Initialize Search Functionality | |
| function initSearch() { | |
| const searchBtn = document.getElementById('searchBtn'); | |
| if (!searchBtn) return; | |
| searchBtn.addEventListener('click', function() { | |
| // Get filter values | |
| const location = document.querySelector('input[placeholder*="City"]').value; | |
| const minPrice = document.querySelector('input[placeholder="Min"]').value; | |
| const maxPrice = document.querySelector('input[placeholder="Max"]').value; | |
| const bedrooms = document.querySelector('select').value; | |
| // In a real app, this would filter properties and update display | |
| console.log('Search filters:', { location, minPrice, maxPrice, bedrooms }); | |
| alert('Search functionality would filter properties here. In a real application, this would connect to a backend API.'); | |
| }); | |
| } | |
| // Initialize on page load | |
| document.addEventListener('DOMContentLoaded', function() { | |
| initSearch(); | |
| // Add loading animation to buttons | |
| const buttons = document.querySelectorAll('button, a[href]'); | |
| buttons.forEach(button => { | |
| button.addEventListener('click', function(e) { | |
| if (this.tagName === 'A' && this.getAttribute('href').startsWith('#')) { | |
| return; // Don't animate anchor links | |
| } | |
| this.classList.add('opacity-75'); | |
| setTimeout(() => { | |
| this.classList.remove('opacity-75'); | |
| }, 300); | |
| }); | |
| }); | |
| }); |