-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontact.html
More file actions
222 lines (192 loc) · 8.1 KB
/
Copy pathcontact.html
File metadata and controls
222 lines (192 loc) · 8.1 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Roundelay Farm - Contact</title>
<!-- SEO & Social -->
<meta name="description" content="Contact Roundelay Farm — phone, email, hours, pickup location, and a quick email form." />
<link rel="canonical" href="https://roundelay.farm/contact.html">
<meta property="og:title" content="Roundelay Farm — Contact" />
<meta property="og:description" content="Get in touch with Roundelay Farm in Byrdstown, TN." />
<meta property="og:type" content="website" />
<meta property="og:image" content="images/Roundelay_jelly_1_1000x667.jpg" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="color-scheme" content="light dark" />
<meta name="theme-color" content="#6c8a4a" />
<link rel="preload" href="images/front_yard_panos_animated_900x209.gif" as="image" />
<link rel="icon" href="images/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="common.css" />
</head>
<body>
<a class="skip-link" href="#main">Skip to content</a>
<nav class="topnav" aria-label="Primary">
<a href="index.html">Home</a>
<a href="products.html">Products</a>
<a href="news/">News</a>
<a aria-current="page" class="active">Contact</a>
<a href="about.html">About</a>
</nav>
<!-- Motion-friendly banner -->
<picture>
<source media="(prefers-reduced-motion: reduce)" srcset="images/front_yard_panos_static_900x209.jpg" />
<img
src="images/front_yard_panos_animated_900x209.gif"
alt="Changing seasons at Roundelay Farm"
class="banner-image"
width="900"
height="209"
decoding="async"
fetchpriority="high"
/>
</picture>
<main id="main" class="page-fade">
<h1>Contact Roundelay<sup>®</sup> Farm</h1>
<section class="contact-section" id="contact-section" aria-live="polite">
<!-- Content injected via JavaScript -->
</section>
<noscript>
<p style="text-align:center; padding: 0 20px 20px;">
JavaScript is required to load our contact details. Please enable JavaScript in your browser.
</p>
</noscript>
<footer class="footer" role="contentinfo">
© 2023 Roundelay LLC — All rights reserved
</footer>
</main>
<script>
// Keep mailto flow exactly as-is
function handleEmailForm(event) {
event.preventDefault();
const name = document.getElementById("name").value.trim();
const email = document.getElementById("email").value.trim();
const message = document.getElementById("message").value.trim();
const subject = encodeURIComponent(`Website Inquiry from ${name || 'Visitor'}`);
const body = encodeURIComponent(`Name: ${name}\nEmail: ${email}\n\n${message}`);
window.location.href = `mailto:info@roundelay.farm?subject=${subject}&body=${body}`;
}
fetch('jsons/contact.json', { cache: 'no-store' })
.then(response => {
if (!response.ok) throw new Error('Failed to load contact.json');
return response.json();
})
.then(data => {
const section = document.getElementById('contact-section');
const safe = (v) => (v ?? '').toString().trim();
const formatLabel = (key) =>
key.charAt(0).toUpperCase() + key.slice(1).replace(/_/g, ' ');
const phoneHTML = data.phone ? `
<h2>Phone</h2>
<ul>
${Object.entries(data.phone)
.filter(([_, number]) => safe(number))
.map(([key, number]) => `<li>${formatLabel(key)}: ${safe(number)}</li>`)
.join('')}
</ul>` : '';
const emailHTML = data.email ? `
<h2>Email</h2>
<ul>
${Object.entries(data.email)
.filter(([_, address]) => safe(address))
.map(([key, address]) => `<li>${formatLabel(key)}: <a href="mailto:${safe(address)}">${safe(address)}</a></li>`)
.join('')}
</ul>` : '';
// Stable weekday order regardless of JSON key order
const daysOrder = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
const groupHours = (hoursObj) => {
if (!hoursObj) return '';
const days = daysOrder.filter(d => d in hoursObj);
if (!days.length) return '';
const grouped = [];
let current = [];
const sameTime = (a, b) => safe(hoursObj[a]) === safe(hoursObj[b]);
for (let i = 0; i < days.length; i++) {
if (!current.length) {
current.push(days[i]);
continue;
}
if (sameTime(current[current.length - 1], days[i])) {
current.push(days[i]);
} else {
grouped.push([...current]);
current = [days[i]];
}
}
if (current.length) grouped.push([...current]);
return grouped.map(group => {
const label = group.length === 1
? group[0]
: `${group[0]} – ${group[group.length - 1]}`;
return `<li>${label}: ${safe(hoursObj[group[0]]) || 'Closed'}</li>`;
}).join('');
};
const hoursHTML = data.hours ? `
<h2>Business Hours</h2>
<ul>
${groupHours(data.hours)}
</ul>` : '';
const pickup = data.pickup || {};
const pickupHTML = (pickup.address || pickup.embed || pickup.description) ? `
<h2>Pickup Location</h2>
${pickup.description ? `<p>${pickup.description}</p>` : ''}
${pickup.address ? `
<ul>
<li>
Address: <a href="${safe(pickup.map)}" target="_blank" rel="noopener">
${safe(pickup.address)}
</a>
</li>
</ul>` : ''}
${pickup.embed ? `
<div class="map-container">
<iframe
src="${safe(pickup.embed)}"
width="100%" height="350" style="border:0;" allowfullscreen="" loading="lazy"
referrerpolicy="no-referrer-when-downgrade"
title="Pickup Location Map">
</iframe>
</div>` : ''}` : '';
const formHTML = `
<h2>Contact Form</h2>
<form class="contact-form" onsubmit="handleEmailForm(event)" novalidate>
<label for="name">Your Name:</label>
<input type="text" id="name" name="name" placeholder="Jane Doe" autocomplete="name" required />
<label for="email">Your Email:</label>
<input type="email" id="email" name="email" placeholder="you@example.com" autocomplete="email" inputmode="email" required />
<label for="message">Message:</label>
<textarea id="message" name="message" rows="5" placeholder="Type your message here..." required></textarea>
<button type="submit">Send Message</button>
</form>`;
let socialHTML = '';
if (data.social) {
const socialPlatforms = Object.entries(data.social)
.filter(([_, url]) => safe(url));
if (socialPlatforms.length) {
const links = socialPlatforms.map(([platform, url]) => {
const name = platform.charAt(0).toUpperCase() + platform.slice(1);
return `<a href="${safe(url)}" target="_blank" rel="noopener">${name}</a>`;
}).join('\n');
socialHTML = `
<h2>Follow Us</h2>
<div class="social-links" style="text-align: center; margin-top: 10px;">
${links}
</div>`;
}
}
section.innerHTML = `
<p>If you have any questions about our products, events, or availability, please reach out using the methods below.</p>
${phoneHTML}
${emailHTML}
${hoursHTML}
${pickupHTML}
${formHTML}
${socialHTML}`;
})
.catch(err => {
console.error(err);
document.getElementById('contact-section').innerHTML =
'<p style="text-align:center;">Sorry, we couldn’t load contact info right now. Please try again later.</p>';
});
</script>
</body>
</html>